arXiv reader

Quantifying and testing dependence to categorical variables

Siegfried Hörmann and Daniel Strenger-Galvis

arXiv
2509.10268v2 · PDF · 2 October 2025
Categories
math.ST, stat.TH
Licence
CC BY 4.0 The site shows the text.

Abstract

We suggest a dependence coefficient between a categorical variable and some general variable taking values in a metric space. We derive important theoretical properties and study the large sample behaviour of our suggested estimator. Moreover, we develop an independence test which has an asymptotic \chi^2-distribution if the variables are independent and prove that this test is consistent against any violation of independence. The test is also applicable to the classical K-sample problem with possibly high- or infinite-dimensional distributions. We discuss some extensions, including a variant of the coefficient for measuring conditional dependence.

Items 42

Proposition

Proposition 1

YNT8

For some categorical variable Y let \mathcal{L}_Y be the class of bijections between the K levels of Y and the integers \{1,\ldots, K\}. For any \varepsilon>0 there exists a categorical variable Y and a random variable X such that

\max_{\ell\in\mathcal{L}_Y}\xi(X,\ell(Y))-\min_{\ell\in\mathcal{L}_Y}\xi(X,\ell(Y))>1-\varepsilon.
Lemma

Lemma 1

HH3X

Let U be uniformly distributed on the interval (0,1) and independent of X. Set {Q_k(X)=P(Y=k|X)} and define the variable

\widetilde Y = f(X,U)\vcentcolon=\min\left\lbrace k\in \{1,\ldots, K\} \colon\sum_{j=1}^k Q_j(X)>U\right\rbrace.

Then (\widetilde Y,X) and (Y,X) are identically distributed.

Lemma

Lemma 2

FY38

(i) The variables X and Y are independent if and only if Y and Y' are independent. (ii) There exists f\colon \mathcal{H}\to \{1,\ldots, K\} such that Y=f(X), if and only if there is a function \ell\in\mathcal{L}_Y such that Y=\ell(Y').

Remark

Remark 1

42BT

Note that p_{j}=q_{j}. Hence, in the population version we will replace the q_j’s by p_j’s.

Remark

Remark 2

LTR3

The statement of our Lemma 2 is analogue to Theorem 1 of [fuchs_quantifying_2024], where it is formulated for continuous variables in terms of copulas.

Remark

Remark 3

3U7N

It can be readily verified that  

p_{i,j}-p_{i}p_{j}=\mathrm{Cov}(Q_i(X),Q_j(X)). ~

Thus, setting Q(X)=(Q_1(X),\ldots, Q_K(X))' and defining D=\mathrm{diag}(p_{1},\ldots, p_{K}), we may alternatively write

\begin{aligned} (K-1)\psi(X,Y)&=\|D^{-1/2}\,\mathrm{Var}(Q(X))\,D^{-1/2}\|_F^2\\ &=\mathrm{vec}(\mathrm{Var}(Q(X)))' \ (D\otimes D)^{-1} \ \mathrm{vec}(\mathrm{Var}(Q(X))). \end{aligned}

We will refer later to the alternative representations (3) and (3).

Theorem

Theorem 1

IJEK

The dependence coefficient {\psi(X,Y)} satisfies properties ?–?. Moreover, \psi(X,Y)=\psi(X,\ell(Y)) for any \ell\in\mathcal{L}_Y.

Remark

Remark 4

YFCR

Nearest neighbours have also been used by [azadkia_simple_2021] in the construction of their estimator for \xi.

Remark

Remark 5

2LDY

We have been tacitly assuming that the nearest neighbours are unique. Essentially this means that the distance between two variables d(X_1,X_2) has a continuous distribution. From a technical point of view uniqueness of N(i) is not important for our results, but it allows to avoid some extra discussions (e.g. how to break ties) which are not essential for conveying the main ideas. Hence, for the rest of this paper this assumption is supposed to hold.

Remark

Remark 6

630C

The computationally most intensive part in the calculation of \widehat\psi is finding the nearest neighbour indices {N(i)}. Since (approximate) nearest neighbour search can be done in {O(n\log n)} time, the computation time for \widehat\psi is {O(n\log n)} as well.

Assumption

Assumption 1

5MY5

Assume that one of the following conditions holds:
(a) For almost all u we have f(X_{N(1)},u)\stackrel{P}{\to} f(X_1,u) for n\to\infty.
(b) For all k=1,\ldots,K, the mapping x\mapsto Q_k(x) is P_X-almost everywhere continuous.

Lemma

Lemma 4

NHL1

Let \mathcal{V}_k=\{(x,u)\in \mathcal{H}\times (0,1)\colon f(x,u)=k\}. If we have

P\left((X,U)\in \bigcup_{k=1}^K\partial\mathcal{V}_k\right)=0,

then Assumption 1 holds.

Theorem

Theorem 3

8MA3

Let Assumption 1 hold and assume that there is a sequence (k_n) such that

\sum_{n\geq 1}P(L_n\geq k_n)<\infty,\quad k_n P(L_n\geq k_n)\to 0 \quad\text{and}\quad k_n=o\left(\sqrt{n/\log n}\right),

then the estimator \widehat\psi(X,Y) is strongly consistent.

Uses Assumption 1 · Used by Remark 11
Remark

Remark 7

UN7H

In finite dimensional spaces, L_n is known to be bounded by a constant which depends only on the dimension of \mathcal{H}, and thus Condition (3) is trivially satisfied. Along with Lemma 3 we conclude that our estimator is strongly consistent if \mathrm{dim}(\mathcal{H})<\infty.

Remark

Remark 8

7RO8

While L_n remains bounded if X takes values in \mathbb{R}^p, this is typically not the case in infinite dimensional vector spaces. Indeed, as demonstrated in Theorem 2 of [hormann_azadkiachatterjees_2024], one can give explicit examples of distributions for which the sequence L_n diverges at a polynomial rate, but Assumption 2 is satisfied.

Theorem

Theorem 4

WGFI

Assume that X and Y are independent, set

P_n=\sqrt{n}\,\mathrm{vec}\Big(((\widehat p_{k,l} -\widehat p_{k}\widehat{ q_{l}}))_{k,l=1}^{K-1}\Big),

and let  \Sigma_n=\mathrm{Var}(P_n|X_1,\ldots,X_n).

(i) Then under Assumption 1

\begin{aligned} &\Sigma_n((k_1,l_1), (k_2,l_2))\\ &\qquad=p_{k_1}p_{l_1}p_{k_2}p_{l_2}(1+W_{n})\\ &\qquad\quad- p_{k_1}p_{l_1}p_{l_2}(1\lbrace k_1=k_2\rbrace + W_{n} 1\lbrace l_1=k_2\rbrace)\\ &\qquad\quad-p_{k_1}p_{l_1}p_{k_2}(1\lbrace l_1=l_2\rbrace + W_{n} 1\lbrace k_1=l_2\rbrace)\\ &\qquad\quad+p_{k_1}p_{l_1}(1\lbrace k_1=k_2, l_1=l_2\rbrace + W_{n} 1\lbrace k_1=l_2, l_1=k_2\rbrace)+o_P(1), \end{aligned}

with

W_{n}\vcentcolon=\frac{1}{n}\sum_{i=1}^n I\{N(N(i))=i\}.

(ii) Let Assumption 2 hold and suppose that we have some b>0 such that

P(W_n\leq 1-b)\to 1.

Then for large enough n the matrix \Sigma_n is invertible and

\mathcal{I}_n^0\vcentcolon=P_n'\Sigma_n^{-1}P_n \stackrel{\mathcal{D}}{\longrightarrow} \chi^2((K-1)^2),\quad (n\to\infty).

If \widehat \Sigma_n denotes the empirical analogue to \Sigma_n with p_k replaced by their estimators \widehat p_k, then we also have

\mathcal{I}_n\vcentcolon=P_n'\widehat\Sigma_n^{-1}P_n \stackrel{\mathcal{D}}{\longrightarrow} \chi^2((K-1)^2).
Remark

Remark 9

KM7O

To clarify the relationship between \mathcal{I}_n and \widehat\psi(X,Y), we refer to the representation of \psi(X,Y) given in (3). Observe that P_n/\sqrt{n} serves as the sample analogue of \mathrm{vec}(\mathrm{Var}(Q^{[-K]}(X))), where Q^{[-K]}(X) excludes the redundant component

Q_K(X) = 1 - Q_1(X) - \cdots - Q_{K-1}(X)

from Q(X). To account for dependencies between the coordinates of P_n and to obtain a pivotal limit distribution, the weighting matrix of the quadratic form is suitably adjusted.

Lemma

Lemma 5

G0MT

Suppose \mathcal{H}=\mathbb{R}^d and assume that X_i have a continuous density. Then we have W_{n}\stackrel{\mathcal{P}}{\longrightarrow} \gamma_d\vcentcolon=\frac{\mathrm{vol}(\mathcal{S}_d)}{\mathrm{vol}(\mathcal{S}_d\cup \mathcal{S}_{1,d})}, where \mathcal{S}_d is the unit-sphere in \mathbb{R}^d and \mathcal{S}_{1,d} is an affine shift of \mathcal{S}_d by distance 1. It holds that \gamma_d\in (1/2, 2/3], with \gamma_1=2/3 and \gamma_d\searrow 1/2 for d\to\infty.

Corollary

Corollary 1

TCN0

Suppose that Y is a binary variable and that X takes values in \mathbb{R}^d. Then if X and Y are independent we have

\mathcal{I}_n^d\vcentcolon=\frac{n}{1+\gamma_d}\left(\frac{\widehat p_{1,1}-\widehat p_1\widehat q_1}{\widehat{p}_1\widehat{q}_1}\right)^2\stackrel{\mathcal{D}}{\longrightarrow} \chi^2(1).
Corollary

Corollary 2

BBIQ

Let Assumptions 1 and 2 hold. Assume that X and Y are not independent. Then \mathcal{I}_n\stackrel{\mathcal{P}}{\longrightarrow}\infty as n\to\infty. The divergence rate is of order \sqrt{n}.

Remark

Remark 10

XQ4H

As outlined in Section ?, testing independence between X and Y is equivalent to testing whether the K subsamples of X associated with different levels of Y originate from the same distribution. The test proposed above therefore also contributes to the K-sample problem, with particular relevance in the challenging setting of high- or even infinite-dimensional distributions.

Theorem

Theorem 5

0CIC

The dependence coefficient {\psi(X,Y)} satisfies ?–?.

Theorem

Theorem 6

BQKM

The conditional dependence measure \psi(Z,Y|X) satisfies properties ?–?. Moreover, {\psi(Z,Y|X)=\psi(Z,\ell(Y)|X)} for any {\ell\in\mathcal{L}_Y}.

Remark

Remark 11

CMXE

If the conditions of Theorems 2 or 3 are fulfilled (for {\mathcal H, \mathcal{H}'}), the conditional dependence measure {\psi(Z,Y|X)} can be consistently estimated by plugging the estimators for {\psi((X,Z),Y)} and {\psi(X,Y)} into (?).

Remark

Remark 12

3IMK

One can also use \widehat\psi to get a test for conditional dependence by using the conditional randomization testing [candes_panning_2018] or conditional permutation testing [berrett_conditional_2020] frameworks.

Theorem

Theorem 7

OT9G

If {\|.\|} is a strictly monotone norm and \gamma is a function as described above, then the measure \psi_{\|.\|,\gamma} satisfies the properties ?–? as well as ?–?.

Used by Lemma 8
Remark

Remark 13

5RUR

Theorem 7 provides some intuition about the nature of our approach. Determining whether alternative norms yield more powerful independence tests necessitates an investigation into the large-sample behaviour of these coefficients. This analysis lies beyond the scope of the current study and is left for future research.

Remark

Remark 14

VPAZ

Note that in the extreme case \varepsilon=0 we have Y=B almost surely, and hence a degenerate case. As noted by [chatterjee_new_2021], in this case Y is both, independent of X and equal to a function of X and the measure \xi is undefined, as the denominator in (?) is equal to zero. In this specific example, each of the two encodings captures the “closeness” to this case of combined full dependence and independence from a different perspective. In turn, one can easily derive that {\psi(X,Y)=1/2} for all {\varepsilon\in (0,1)}.

Lemma

Lemma 6

WHJR

(i) Under Assumption 1 it holds for all {k,l} that

\widehat p_{k,l}\stackrel{\mathcal{P}}{\longrightarrow} p_{k,l},\quad (n\to\infty).

(ii) If we additionally impose (3), then convergence in probability can be strengthened to almost sure convergence.

Lemma

Lemma 7

MVMN

We denote \Sigma_{g,n}=\mathrm{Var}(P_n|\mathcal{G}_n=g) and let \mathcal{K}_n, n\geq 1, be a sequence of collections of nearest neighbour graphs g with n vertices, such that

\sup_{g\in \mathcal{K}_n}\mathrm{deg}(g)= o\left(n^{1/4}\right)

and such that the coefficient W_{n} defined in (?) and corresponding to g is at most {1-b/2}. Then, for any vector c on the (K-1)^2-dimensional unit sphere it holds that

\sup_{g\in\mathcal K_n}\sup_{z\in\mathbb{R}} \left|P\left(c'\Sigma_{g,n}^{-1/2}P_n\leq z\middle| \mathcal G_n = g\right)-\Phi(z)\right|\to 0,\quad (n\to \infty).
Lemma

Lemma 8

B1SH

Under the assumptions of Theorem 7 it holds that

\|\operatorname{Var}(Q(X,Z))\|\geq \|\operatorname{Var}(Q(X))\|,

with equality if and only if Y is independent of Z conditionally on X.

Lemma

Lemma S1

VRYG

Let X_i be i.i.d. random elements in a separable metric space \mathcal{H}. Then as n\to\infty we have (i) X_{N(1)}\stackrel{a.s.}{\longrightarrow} X_1 and (ii) P(N(1)=N(2))=o(1).

Lemma

Lemma S2

3NCB

Suppose Assumption 1 holds. Then for n\to\infty, we have

(Y_1,Y_{N(1)}, Y_2, Y_{N(2)})\stackrel{\mathcal{D}}{\longrightarrow} (Y_1, Y_1', Y_2, Y_2').
Lemma

Lemma S3

NHB5

Let \mathcal{X}_1,\ldots, \mathcal{X}_n be a collection of arbitrary metric spaces and set {\mathcal{X}=\mathcal{X}_1\times\ldots\times\mathcal{X}_n}. Let \mathcal{Y}\subset \mathcal{X} and let X be an \mathcal{X}-valued random variable. Denote {p=P(X\notin \mathcal Y)}. If f:\mathcal{X}\to\mathbb{R} is such that for all pairs x,y\in\mathcal Y which are only distinct in the i-th coordinate we have

|f(x)-f(y)|\leq c_i,

then it holds that

P(|f(X)-\mathbb{E}\,\left(f(X)|X\in\mathcal Y\right)|\geq \varepsilon)\leq 2p+2\exp\left(-\frac{2\left(\varepsilon-p\sum_{i=1}^n c_i\right))^2}{\sum_{i=1}^n c_i^2}\right).
Remark

Remark 15

QLP2

[combes_extension_2023] states Lemma S3 for \mathcal{X}_i = \mathbb{R}^p, but this is not relevant for the proof and it remains valid for any metric spaces.

Lemma

Lemma S4

I4EG

It holds that

\begin{aligned} \mathrm{det}\left(\Sigma_{n}\right)&=\left(1+W_{n}\right)^{K(K-1)/2}\left(1-W_{n}\right)^{(K-1)(K-2)/2}\prod_{i=1}^{K} p_i^{2(K-1)}. \end{aligned}
Lemma

Lemma S5

FKLS

[[rinott_normal_1994], Thm. 2.2] Let V_1,\ldots,V_n be random variables having a dependence graph whose maximal degree is strictly less than k and satisfy

  1. |V_i|\leq~B almost surely for i=1,\ldots,n,

  2. \mathbb{E}\, V_i =0 and

  3. \operatorname{Var}(\sum_{i=1}^n V_i)=1.

Then

\left|P\left(\sum_{i=1} V_i\leq~z\right)-\Phi(z)\right|\leq~\sqrt{\frac{1}{2\pi}}kB+16\sqrt{n}k^{3/2}B^2+10nk^2B^3.
Remark

Remark 16

KFRH

Note that the term W_{n}' doesn’t appear in \Sigma_n. The corresponding summands cancel.

Lemma

Lemma S6

IVCD

Fix K and let {E\in \mathbb{R}^{(K-1)\times (K-1)}} be a matrix with all entries equal to 1 and {I} be the identity matrix in {\mathbb{R}^{(K-1)\times (K-1)}}. Let D=\mathrm{diag}(p_1,\ldots, p_{K-1}) and denote A^{2\otimes}=A\otimes A. Finally, define the matrix {\mathcal{W}_n\in\mathbb{R}^{(K-1)^2\times (K-1)^2}} with

\mathcal{W}_n((k_1,l_1),(k_2,l_2))=1\lbrace k_1=k_2, l_1=l_2\rbrace + W_{n} 1\lbrace k_1=l_2, l_1=k_2\rbrace,

for 1\leq k_1,l_1,k_2,l_2\leq K-1. Then the following factorization holds:

\Sigma_n=D^{\otimes 2}\cdot \mathcal{W}_n\cdot (I-E D)^{2\otimes}.

Source and licence

The text on this page is from arXiv:2509.10268v2 by Siegfried Hörmann and Daniel Strenger-Galvis, under the licence CC BY 4.0. The corpus made these changes: it read the items out of the LaTeX source, it expanded the macros of the paper, it put each proof after its statement, and it converted the text to HTML. The formulas are the TeX of the paper, and KaTeX renders them. A formula or a reference can look different from the PDF. The page is published under CC BY 4.0.

The record of each item is in analysis/objects/2509/2509.10268.jsonl.