Distance correlation

From HandWiki

In statistics and in probability theory, distance correlation or distance covariance is a measure of dependence between two paired random vectors of arbitrary, not necessarily equal, dimension. The population distance correlation coefficient is zero if and only if the random vectors are independent. Thus, distance correlation measures both linear and nonlinear association between two random variables or random vectors. This is in contrast to Pearson's correlation, which can only detect linear association between two random variables. Distance correlation can be used to perform a statistical test of dependence with a permutation test. One first computes the distance correlation (involving the re-centering of Euclidean distance matrices) between two random vectors, and then compares this value to the distance correlations of many shuffles of the data.

Several sets of (xy) points, with the distance correlation coefficient of x and y for each set. Compare to the graph on correlation

Background

The classical measure of dependence, the Pearson correlation coefficient,[1] is mainly sensitive to a linear relationship between two variables. Distance correlation was introduced in 2005 by Gábor J. Székely in several lectures to address this deficiency of Pearson's correlation, namely that it can easily be zero for dependent variables. Correlation = 0 (uncorrelatedness) does not imply independence while distance correlation = 0 does imply independence. The first results on distance correlation were published in 2007 and 2009.[2][3] It was proved that distance covariance is the same as the Brownian covariance.[3] These measures are examples of energy distances.

The distance correlation is derived from a number of other quantities that are used in its specification, specifically: distance variance, distance standard deviation, and distance covariance. These quantities take the same roles as the ordinary moments with corresponding names in the specification of the Pearson product-moment correlation coefficient.

Definitions

Distance covariance

Let us start with the definition of the sample distance covariance. Let (XkYk), k = 1, 2, ..., n be a statistical sample from a pair of real valued or vector valued random variables (XY). First, compute the n by n distance matrices (aj, k) and (bj, k) containing all pairwise distances

[math]\displaystyle{ \begin{align} a_{j, k} &= \|X_j-X_k\|, \qquad j, k =1,2,\ldots,n, \\ b_{j, k} &= \|Y_j-Y_k\|, \qquad j, k=1,2,\ldots,n, \end{align} }[/math]

where ||⋅ ||denotes Euclidean norm. Then take all doubly centered distances

[math]\displaystyle{ A_{j, k} := a_{j, k}-\overline{a}_{j\cdot}-\overline{a}_{\cdot k} + \overline{a}_{\cdot\cdot}, \qquad B_{j, k} := b_{j, k} - \overline{b}_{j\cdot} -\overline{b}_{\cdot k} + \overline{b}_{\cdot\cdot}, }[/math]

where [math]\displaystyle{ \textstyle \overline{a}_{j\cdot} }[/math] is the j-th row mean, [math]\displaystyle{ \textstyle \overline{a}_{\cdot k} }[/math] is the k-th column mean, and [math]\displaystyle{ \textstyle \overline{a}_{\cdot\cdot} }[/math] is the grand mean of the distance matrix of the X sample. The notation is similar for the b values. (In the matrices of centered distances (Aj, k) and (Bj,k) all rows and all columns sum to zero.) The squared sample distance covariance (a scalar) is simply the arithmetic average of the products Aj, k Bj, k:

[math]\displaystyle{ \operatorname{dCov}^2_n(X,Y) := \frac 1 {n^2} \sum_{j = 1}^n \sum_{k = 1}^n A_{j, k} \, B_{j, k}. }[/math]

The statistic Tn = n dCov2n(X, Y) determines a consistent multivariate test of independence of random vectors in arbitrary dimensions. For an implementation see dcov.test function in the energy package for R.[4]

The population value of distance covariance can be defined along the same lines. Let X be a random variable that takes values in a p-dimensional Euclidean space with probability distribution μ and let Y be a random variable that takes values in a q-dimensional Euclidean space with probability distribution ν, and suppose that X and Y have finite expectations. Write

[math]\displaystyle{ a_\mu(x):= \operatorname{E}[\|X-x\|], \quad D(\mu) := \operatorname{E}[a_\mu(X)], \quad d_\mu(x, x') := \|x-x'\|-a_\mu(x)-a_\mu(x')+D(\mu). }[/math]

Finally, define the population value of squared distance covariance of X and Y as

[math]\displaystyle{ \operatorname{dCov}^2(X, Y) := \operatorname{E}\big[d_\mu(X,X')d_\nu(Y,Y')\big]. }[/math]

One can show that this is equivalent to the following definition:

[math]\displaystyle{ \begin{align} \operatorname{dCov}^2(X,Y) := {} & \operatorname{E}[\|X-X'\|\,\|Y-Y'\|] + \operatorname{E}[\|X-X'\|]\,\operatorname{E}[\|Y-Y'\|] \\ &\qquad {} - \operatorname{E}[\|X-X'\|\,\|Y-Y''\|] - \operatorname{E}[\|X-X''\|\,\|Y-Y'\|] \\ = {} & \operatorname{E}[\|X-X'\|\,\|Y-Y'\|] + \operatorname{E}[\|X-X'\|]\,\operatorname{E}[\|Y-Y'\|] \\ &\qquad {} - 2\operatorname{E}[\|X-X'\|\,\|Y-Y''\|], \end{align} }[/math]

where E denotes expected value, and [math]\displaystyle{ \textstyle (X, Y), }[/math] [math]\displaystyle{ \textstyle (X', Y'), }[/math] and [math]\displaystyle{ \textstyle (X'',Y'') }[/math] are independent and identically distributed. The primed random variables [math]\displaystyle{ \textstyle (X', Y') }[/math] and [math]\displaystyle{ \textstyle (X'',Y'') }[/math] denote independent and identically distributed (iid) copies of the variables [math]\displaystyle{ X }[/math] and [math]\displaystyle{ Y }[/math] and are similarly iid.[5] Distance covariance can be expressed in terms of the classical Pearson's covariance, cov, as follows:

[math]\displaystyle{ \operatorname{dCov}^2(X,Y) = \operatorname{cov}(\|X-X'\|,\|Y-Y'\|) - 2\operatorname{cov}(\|X-X'\|,\|Y-Y''\|). }[/math]

This identity shows that the distance covariance is not the same as the covariance of distances, cov(||XX' ||, ||YY' ||). This can be zero even if X and Y are not independent.

Alternatively, the distance covariance can be defined as the weighted L2 norm of the distance between the joint characteristic function of the random variables and the product of their marginal characteristic functions:[6]

[math]\displaystyle{ \operatorname{dCov}^2(X,Y)= \frac 1 {c_p c_q} \int_{\mathbb{R}^{p+q}} \frac{\left|\varphi_{X,Y}(s, t) - \varphi_X(s)\varphi_Y(t) \right|^2}{|s|_p^{1+p} |t|_q^{1+q}} \,dt\,ds }[/math]

where [math]\displaystyle{ \varphi_{X,Y}(s,t) }[/math], [math]\displaystyle{ \varphi_{X}(s) }[/math], and [math]\displaystyle{ \varphi_{Y}(t) }[/math] are the characteristic functions of (X, Y), X, and Y, respectively, p, q denote the Euclidean dimension of X and Y, and thus of s and t, and cp, cq are constants. The weight function [math]\displaystyle{ ({c_p c_q}{|s|_p^{1+p} |t|_q^{1+q}})^{-1} }[/math] is chosen to produce a scale equivariant and rotation invariant measure that doesn't go to zero for dependent variables.[6][7] One interpretation of the characteristic function definition is that the variables eisX and eitY are cyclic representations of X and Y with different periods given by s and t, and the expression ϕX, Y(s, t) − ϕX(s) ϕY(t) in the numerator of the characteristic function definition of distance covariance is simply the classical covariance of eisX and eitY. The characteristic function definition clearly shows that dCov2(X, Y) = 0 if and only if X and Y are independent.

Distance variance and distance standard deviation

The distance variance is a special case of distance covariance when the two variables are identical. The population value of distance variance is the square root of

[math]\displaystyle{ \operatorname{dVar}^2(X) := \operatorname{E}[\|X-X'\|^2] + \operatorname{E}^2[\|X-X'\|] - 2\operatorname{E}[\|X-X'\|\,\|X-X''\|], }[/math]

where [math]\displaystyle{ X }[/math], [math]\displaystyle{ X' }[/math], and [math]\displaystyle{ X'' }[/math] are independent and identically distributed random variables, [math]\displaystyle{ \operatorname{E} }[/math] denotes the expected value, and [math]\displaystyle{ f^2(\cdot)=(f(\cdot))^2 }[/math] for function [math]\displaystyle{ f(\cdot) }[/math], e.g., [math]\displaystyle{ \operatorname{E}^2[\cdot] = (\operatorname{E}[\cdot])^2 }[/math].

The sample distance variance is the square root of

[math]\displaystyle{ \operatorname{dVar}^2_n(X) := \operatorname{dCov}^2_n(X,X) = \tfrac{1}{n^2}\sum_{k,\ell}A_{k,\ell}^2, }[/math]

which is a relative of Corrado Gini's mean difference introduced in 1912 (but Gini did not work with centered distances).[8]

The distance standard deviation is the square root of the distance variance.

Distance correlation

The distance correlation [2][3] of two random variables is obtained by dividing their distance covariance by the product of their distance standard deviations. The distance correlation is the square root of

[math]\displaystyle{ \operatorname{dCor}^2(X,Y) = \frac{\operatorname{dCov}^2(X,Y)}{\sqrt{\operatorname{dVar}^2(X)\,\operatorname{dVar}^2(Y)}}, }[/math]

and the sample distance correlation is defined by substituting the sample distance covariance and distance variances for the population coefficients above.

For easy computation of sample distance correlation see the dcor function in the energy package for R.[4]

Properties

Distance correlation

  1. [math]\displaystyle{ 0\leq\operatorname{dCor}_n(X,Y)\leq1 }[/math] and [math]\displaystyle{ 0\leq\operatorname{dCor}(X,Y)\leq1 }[/math]; this is in contrast to Pearson's correlation, which can be negative.
  2. [math]\displaystyle{ \operatorname{dCor}(X,Y) = 0 }[/math] if and only if X and Y are independent.
  3. [math]\displaystyle{ \operatorname{dCor}_n(X,Y) = 1 }[/math] implies that dimensions of the linear subspaces spanned by X and Y samples respectively are almost surely equal and if we assume that these subspaces are equal, then in this subspace [math]\displaystyle{ Y = A + b\,\mathbf{C}X }[/math] for some vector A, scalar b, and orthonormal matrix [math]\displaystyle{ \mathbf{C} }[/math].

Distance covariance

  1. [math]\displaystyle{ \operatorname{dCov}(X,Y)\geq0 }[/math] and [math]\displaystyle{ \operatorname{dCov}_n(X,Y)\geq0 }[/math];
  2. [math]\displaystyle{ \operatorname{dCov}^2(a_1 + b_1\,\mathbf{C}_1\,X, a_2 + b_2\,\mathbf{C}_2\,Y) = |b_1\,b_2|\operatorname{dCov}^2(X,Y) }[/math] for all constant vectors [math]\displaystyle{ a_1, a_2 }[/math], scalars [math]\displaystyle{ b_1, b_2 }[/math], and orthonormal matrices [math]\displaystyle{ \mathbf{C}_1, \mathbf{C}_2 }[/math].
  3. If the random vectors [math]\displaystyle{ (X_1, Y_1) }[/math] and [math]\displaystyle{ (X_2, Y_2) }[/math] are independent then
    [math]\displaystyle{ \operatorname{dCov}(X_1 + X_2, Y_1 + Y_2) \leq \operatorname{dCov}(X_1, Y_1) + \operatorname{dCov}(X_2, Y_2). }[/math]
    Equality holds if and only if [math]\displaystyle{ X_1 }[/math] and [math]\displaystyle{ Y_1 }[/math] are both constants, or [math]\displaystyle{ X_2 }[/math] and [math]\displaystyle{ Y_2 }[/math] are both constants, or [math]\displaystyle{ X_1, X_2, Y_1, Y_2 }[/math] are mutually independent.
  4. [math]\displaystyle{ \operatorname{dCov}(X,Y) = 0 }[/math] if and only if X and Y are independent.

This last property is the most important effect of working with centered distances.

The statistic [math]\displaystyle{ \operatorname{dCov}^2_n(X,Y) }[/math] is a biased estimator of [math]\displaystyle{ \operatorname{dCov}^2(X,Y) }[/math]. Under independence of X and Y [9]

[math]\displaystyle{ \begin{align} \operatorname{E}[\operatorname{dCov}^2_n(X,Y)] & = \frac{n-1}{n^2} \left\{(n-2) \operatorname{dCov}^2(X,Y)+ \operatorname{E}[\|X-X'\|]\,\operatorname{E}[\|Y-Y'\|] \right\} \\[6pt] & = \frac{n-1}{n^2}\operatorname {E}[\|X-X'\|]\,\operatorname{E}[\|Y-Y'\|]. \end{align} }[/math]

An unbiased estimator of [math]\displaystyle{ \operatorname{dCov}^2(X,Y) }[/math] is given by Székely and Rizzo.[10]

Distance variance

  1. [math]\displaystyle{ \operatorname{dVar}(X) = 0 }[/math] if and only if [math]\displaystyle{ X = \operatorname{E}[X] }[/math] almost surely.
  2. [math]\displaystyle{ \operatorname{dVar}_n(X) = 0 }[/math] if and only if every sample observation is identical.
  3. [math]\displaystyle{ \operatorname{dVar}(A + b\,\mathbf{C}\,X) = |b|\operatorname{dVar}(X) }[/math] for all constant vectors A, scalars b, and orthonormal matrices [math]\displaystyle{ \mathbf{C} }[/math].
  4. If X and Y are independent then [math]\displaystyle{ \operatorname{dVar}(X + Y) \leq\operatorname{dVar}(X) + \operatorname{dVar}(Y) }[/math].

Equality holds in (iv) if and only if one of the random variables X or Y is a constant.

Generalization

Distance covariance can be generalized to include powers of Euclidean distance. Define

[math]\displaystyle{ \begin{align} \operatorname{dCov}^2(X, Y; \alpha) := {} & \operatorname{E}[\|X-X'\|^\alpha\,\|Y-Y'\|^\alpha] + \operatorname{E}[\|X-X'\|^\alpha]\,\operatorname{E}[\|Y-Y'\|^\alpha]\\ &\qquad {} - 2\operatorname{E}[\|X-X'\|^\alpha\,\|Y-Y''\|^\alpha]. \end{align} }[/math]

Then for every [math]\displaystyle{ 0\lt \alpha\lt 2 }[/math], [math]\displaystyle{ X }[/math] and [math]\displaystyle{ Y }[/math] are independent if and only if [math]\displaystyle{ \operatorname{dCov}^2(X, Y; \alpha) = 0 }[/math]. It is important to note that this characterization does not hold for exponent [math]\displaystyle{ \alpha=2 }[/math]; in this case for bivariate [math]\displaystyle{ (X, Y) }[/math], [math]\displaystyle{ \operatorname{dCor}(X, Y; \alpha=2) }[/math] is a deterministic function of the Pearson correlation.[2] If [math]\displaystyle{ a_{k,\ell} }[/math] and [math]\displaystyle{ b_{k,\ell} }[/math] are [math]\displaystyle{ \alpha }[/math] powers of the corresponding distances, [math]\displaystyle{ 0\lt \alpha\leq2 }[/math], then [math]\displaystyle{ \alpha }[/math] sample distance covariance can be defined as the nonnegative number for which

[math]\displaystyle{ \operatorname{dCov}^2_n(X, Y; \alpha):= \frac{1}{n^2}\sum_{k,\ell}A_{k,\ell}\,B_{k,\ell}. }[/math]

One can extend [math]\displaystyle{ \operatorname{dCov} }[/math] to metric-space-valued random variables [math]\displaystyle{ X }[/math] and [math]\displaystyle{ Y }[/math]: If [math]\displaystyle{ X }[/math] has law [math]\displaystyle{ \mu }[/math] in a metric space with metric [math]\displaystyle{ d }[/math], then define [math]\displaystyle{ a_\mu(x):= \operatorname{E}[d(X, x)] }[/math], [math]\displaystyle{ D(\mu) := \operatorname{E}[a_\mu(X)] }[/math], and (provided [math]\displaystyle{ a_\mu }[/math] is finite, i.e., [math]\displaystyle{ X }[/math] has finite first moment), [math]\displaystyle{ d_\mu(x, x') := d(x, x')-a_\mu(x)-a_\mu(x')+D(\mu) }[/math]. Then if [math]\displaystyle{ Y }[/math] has law [math]\displaystyle{ \nu }[/math] (in a possibly different metric space with finite first moment), define

[math]\displaystyle{ \operatorname{dCov}^2(X, Y) := \operatorname{E}\big[d_\mu(X,X')d_\nu(Y,Y')\big]. }[/math]

This is non-negative for all such [math]\displaystyle{ X, Y }[/math] iff both metric spaces have negative type.[11] Here, a metric space [math]\displaystyle{ (M, d) }[/math] has negative type if [math]\displaystyle{ (M, d^{1/2}) }[/math] is isometric to a subset of a Hilbert space.[12] If both metric spaces have strong negative type, then [math]\displaystyle{ \operatorname{dCov}^2(X, Y)= 0 }[/math] iff [math]\displaystyle{ X, Y }[/math] are independent.[11]

Alternative definition of distance covariance

The original distance covariance has been defined as the square root of [math]\displaystyle{ \operatorname{dCov}^2(X,Y) }[/math], rather than the squared coefficient itself. [math]\displaystyle{ \operatorname{dCov}(X,Y) }[/math] has the property that it is the energy distance between the joint distribution of [math]\displaystyle{ \operatorname X, Y }[/math] and the product of its marginals. Under this definition, however, the distance variance, rather than the distance standard deviation, is measured in the same units as the [math]\displaystyle{ \operatorname X }[/math] distances.

Alternately, one could define distance covariance to be the square of the energy distance: [math]\displaystyle{ \operatorname{dCov}^2(X,Y). }[/math] In this case, the distance standard deviation of [math]\displaystyle{ X }[/math] is measured in the same units as [math]\displaystyle{ X }[/math] distance, and there exists an unbiased estimator for the population distance covariance.[10]

Under these alternate definitions, the distance correlation is also defined as the square [math]\displaystyle{ \operatorname{dCor}^2(X,Y) }[/math], rather than the square root.

Alternative formulation: Brownian covariance

Brownian covariance is motivated by generalization of the notion of covariance to stochastic processes. The square of the covariance of random variables X and Y can be written in the following form:

[math]\displaystyle{ \operatorname{cov}(X,Y)^2 = \operatorname{E}\left[ \big(X - \operatorname{E}(X)\big) \big(X^\mathrm{'} - \operatorname{E}(X^\mathrm{'})\big) \big(Y - \operatorname{E}(Y)\big) \big(Y^\mathrm{'} - \operatorname{E}(Y^\mathrm{'})\big) \right] }[/math]

where E denotes the expected value and the prime denotes independent and identically distributed copies. We need the following generalization of this formula. If U(s), V(t) are arbitrary random processes defined for all real s and t then define the U-centered version of X by

[math]\displaystyle{ X_U := U(X) - \operatorname{E}_X\left[ U(X) \mid \left \{ U(t) \right \} \right] }[/math]

whenever the subtracted conditional expected value exists and denote by YV the V-centered version of Y.[3][13][14] The (U,V) covariance of (X,Y) is defined as the nonnegative number whose square is

[math]\displaystyle{ \operatorname{cov}_{U,V}^2(X,Y) := \operatorname{E}\left[X_U X_U^\mathrm{'} Y_V Y_V^\mathrm{'}\right] }[/math]

whenever the right-hand side is nonnegative and finite. The most important example is when U and V are two-sided independent Brownian motions /Wiener processes with expectation zero and covariance |s| + |t| − |st| = 2 min(s,t) (for nonnegative s, t only). (This is twice the covariance of the standard Wiener process; here the factor 2 simplifies the computations.) In this case the (U,V) covariance is called Brownian covariance and is denoted by

[math]\displaystyle{ \operatorname{cov}_W(X,Y). }[/math]

There is a surprising coincidence: The Brownian covariance is the same as the distance covariance:

[math]\displaystyle{ \operatorname{cov}_{\mathrm{W}}(X, Y) = \operatorname{dCov}(X, Y), }[/math]

and thus Brownian correlation is the same as distance correlation.

On the other hand, if we replace the Brownian motion with the deterministic identity function id then Covid(X,Y) is simply the absolute value of the classical Pearson covariance,

[math]\displaystyle{ \operatorname{cov}_{\mathrm{id}}(X,Y) = \left\vert\operatorname{cov}(X,Y)\right\vert. }[/math]

Related metrics

Other correlational metrics, including kernel-based correlational metrics (such as the Hilbert-Schmidt Independence Criterion or HSIC) can also detect linear and nonlinear interactions. Both distance correlation and kernel-based metrics can be used in methods such as canonical correlation analysis and independent component analysis to yield stronger statistical power.

See also

Notes

References

External links