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.
The classical measure of dependence, the Pearson correlation coefficient, 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. It was proved that distance covariance is the same as the Brownian covariance. 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.
Let us start with the definition of the sample distance covariance. Let (Xk, Yk), k = 1, 2, ..., n be a statistical sample from a pair of real valued or vector valued random variables (X, Y). First, compute the n by n distance matrices (aj, k) and (bj, k) containing all pairwise distances
\begin{align} aj,&=\|Xj-Xk\|, j,k=1,2,\ldots,n, \ bj,&=\|Yj-Yk\|, j,k=1,2,\ldots,n, \end{align}
where ||⋅ ||denotes Euclidean norm. Then take all doubly centered distances
Aj,:=aj,-\overline{a}j ⋅ -\overline{a} ⋅ +\overline{a} ⋅ ⋅ , Bj,:=bj,-\overline{b}j ⋅ -\overline{b} ⋅ +\overline{b} ⋅ ⋅ ,
where
style\overline{a}j ⋅
style\overline{a} ⋅
style\overline{a} ⋅ ⋅
2 | |
\operatorname{dCov} | |
n(X,Y) |
:=
1 | |
n2 |
n | |
\sum | |
j=1 |
n | |
\sum | |
k=1 |
Aj,Bj,.
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.
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
a\mu(x):=\operatorname{E}[\|X-x\|], D(\mu):=\operatorname{E}[a\mu(X)], d\mu(x,x'):=\|x-x'\|-a\mu(x)-a\mu(x')+D(\mu).
Finally, define the population value of squared distance covariance of X and Y as
\operatorname{dCov}2(X,Y):=\operatorname{E}[d\mu(X,X')d\nu(Y,Y')].
One can show that this is equivalent to the following definition:
\begin{align} \operatorname{dCov}2(X,Y):={}&\operatorname{E}[\|X-X'\|\|Y-Y'\|]+\operatorname{E}[\|X-X'\|]\operatorname{E}[\|Y-Y'\|]\\ & {}-\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'\|]\\ & {}-2\operatorname{E}[\|X-X'\|\|Y-Y''\|], \end{align}
where E denotes expected value, and
style(X,Y),
style(X',Y'),
style(X'',Y'')
style(X',Y')
style(X'',Y'')
X
Y
\operatorname{dCov}2(X,Y)=\operatorname{cov}(\|X-X'\|,\|Y-Y'\|)-2\operatorname{cov}(\|X-X'\|,\|Y-Y''\|).
This identity shows that the distance covariance is not the same as the covariance of distances,). 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:[1]
\operatorname{dCov}2(X,Y)=
1 | |
cpcq |
\int | |
Rp+q |
\left|\varphiX,Y(s,t)-\varphiX(s)\varphiY(t)\right|2 | |||||||||||||||
|
dtds
where
\varphiX,Y(s,t)
\varphiX(s)
\varphiY(t)
({cpcq}{|s|
1+p | |
p |
1+q | |
|t| | |
q |
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
\operatorname{dVar}2(X):=\operatorname{E}[\|X-X'\|2]+\operatorname{E}2[\|X-X'\|]-2\operatorname{E}[\|X-X'\|\|X-X''\|],
where
X
X'
X''
\operatorname{E}
f2( ⋅ )=(f( ⋅ ))2
f( ⋅ )
\operatorname{E}2[ ⋅ ]=(\operatorname{E}[ ⋅ ])2
The sample distance variance is the square root of
2 | |
\operatorname{dVar} | |
n(X) |
:=
2 | |
\operatorname{dCov} | |
n(X,X) |
=
2}\sum | |
\tfrac{1}{n | |
k,\ell |
2, | |
A | |
k,\ell |
which is a relative of Corrado Gini's mean difference introduced in 1912 (but Gini did not work with centered distances).
The distance standard deviation is the square root of the distance variance.
The distance correlation 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
\operatorname{dCor}2(X,Y)=
\operatorname{dCov | |
2(X,Y)}{\sqrt{\operatorname{dVar} |
2(X)\operatorname{dVar}2(Y)}},
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.
This last property is the most important effect of working with centered distances.
The statistic
2 | |
\operatorname{dCov} | |
n(X,Y) |
\operatorname{dCov}2(X,Y)
2 | |
\begin{align} \operatorname{E}[\operatorname{dCov} | |
n(X,Y)] |
&=
n-1 | |
n2 |
\left\{(n-2)\operatorname{dCov}2(X,Y)+\operatorname{E}[\|X-X'\|]\operatorname{E}[\|Y-Y'\|]\right\}\\[6pt] &=
n-1 | |
n2 |
\operatorname{E}[\|X-X'\|]\operatorname{E}[\|Y-Y'\|]. \end{align}
An unbiased estimator of
\operatorname{dCov}2(X,Y)
Equality holds in (iv) if and only if one of the random variables or is a constant.
Distance covariance can be generalized to include powers of Euclidean distance. Define
\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]\\ & {}-2\operatorname{E}[\|X-X'\|\alpha\|Y-Y''\|\alpha]. \end{align}
Then for every
0<\alpha<2
X
Y
\operatorname{dCov}2(X,Y;\alpha)=0
\alpha=2
(X,Y)
\operatorname{dCor}(X,Y;\alpha=2)
ak,\ell
bk,\ell
\alpha
0<\alpha\leq2
\alpha
2 | |
\operatorname{dCov} | |
n(X, |
Y;\alpha):=
1 | |
n2 |
\sumk,\ellAk,\ellBk,\ell.
One can extend
\operatorname{dCov}
X
Y
X
\mu
d
a\mu(x):=\operatorname{E}[d(X,x)]
D(\mu):=\operatorname{E}[a\mu(X)]
a\mu
X
d\mu(x,x'):=d(x,x')-a\mu(x)-a\mu(x')+D(\mu)
Y
\nu
\operatorname{dCov}2(X,Y):=\operatorname{E}[d\mu(X,X')d\nu(Y,Y')].
X,Y
(M,d)
(M,d1/2)
\operatorname{dCov}2(X,Y)=0
X,Y
The original distance covariance has been defined as the square root of
\operatorname{dCov}2(X,Y)
\operatorname{dCov}(X,Y)
\operatornameX,Y
\operatornameX
Alternately, one could define distance covariance to be the square of the energy distance:
\operatorname{dCov}2(X,Y).
X
X
Under these alternate definitions, the distance correlation is also defined as the square
\operatorname{dCor}2(X,Y)
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:
\operatorname{cov}(X,Y)2=\operatorname{E}\left[ (X-\operatorname{E}(X)) (X'-\operatorname{E}(X')) (Y-\operatorname{E}(Y)) (Y'-\operatorname{E}(Y')) \right]
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
XU:=U(X)-\operatorname{E}X\left[U(X)\mid\left\{U(t)\right\}\right]
whenever the subtracted conditional expected value exists and denote by YV the V-centered version of Y. The (U,V) covariance of (X,Y) is defined as the nonnegative number whose square is
2(X,Y) | |
\operatorname{cov} | |
U,V |
:=\operatorname{E}\left[XU
' | |
X | |
U |
YV
'\right] | |
Y | |
V |
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 (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
\operatorname{cov}W(X,Y).
There is a surprising coincidence: The Brownian covariance is the same as the distance covariance:
\operatorname{cov}W(X,Y)=\operatorname{dCov}(X,Y),
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,
\operatorname{cov}id(X,Y)=\left\vert\operatorname{cov}(X,Y)\right\vert.
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.