# dCov: Distance Covariance Statistic In GiniDistance: A New Gini Correlation Between Quantitative and Qualitative Variables

## Description

Computes distance covariance statistic, in which Xs are quantitative and Y are categorical and return the measures of dependence.

## Usage

 1  dCov(x, y, alpha) 

## Arguments

 x data y label of data or response variable alpha exponent on Euclidean distance, in (0,2]

## Details

dCov calls dcov function from energy package to compute distance covariance statistic. The sample size (number of rows) of the data must agree with the length of the label vector, and samples must not contain missing values. Arguments x, y are treated as data and labels.

The distance covariance (Sezekley07) is extended from Euclidean space to general metric spaces by Lyons (2013). Based on that idea, we define the discrete metric

d(y, y^\prime) =|y-y^\prime|:= I(y\neq y^\prime),

where I (\cdot) is the indicator function. Equipped with this set difference metric on the support of Y and Euclidean distance on the support of \mathbf{X}, the corresponding distance covariance and distance correlation for numerical \mathbf{X} and categorical Y variables are as follows.

Let A=(a_{ij}) be a symmetric, n \times n, centered distance matrix of sample \bf x_1,\cdots, \bf x_n. The (i,j)-th entry of A is a_{ij}-\frac{1}{n-2}a_{i\cdot}-\frac{1}{n-2}a_{\cdot j} + \frac{1}{(n-1)(n-2)}a_{\cdot \cdot} if i \neq j and 0 if i=j, where a_{ij} = \|\bf x_i-\bf x_j\|^{α}, a_{i\cdot} = ∑_{j=1}^n a_{ij}, a_{\cdot j} = ∑_{i=1}^n a_{ij}, and a_{\cdot \cdot}=∑_{i,j=1}^n a_{ij}. Similarly, using the set difference metric, a symmetric, n \times n, centered distance matrix is calculated for samples y_1,\cdots, y_n and denoted by B = (b_{ij}). Unbiased estimators of \mbox{dCov}(\bf X,Y;α) is

\frac{1}{n(n-3)}∑_{i\ne j}A_{ij}B_{ij}.

## Value

dCov returns the sample distance covariance between data x and label y.

## References

Lyons, R. (2013). Distance covariance in metric spaces. The Annals of Probability, 41 (5), 3284-3305.

Rizzo, M.L. and Szekely, G.J., (2017). Energy: E-Statistics: Multivariate Inference via the Energy of Data (R Package), Version 1.7-0.

Szekely, G. J., Rizzo, M. L. and Bakirov, N. (2007). Measuring and testing dependence by correlation of distances. Annals of Statistics, 35 (6), 2769-2794.

dCor KdCov KdCor
 1 2 3  x <- iris[,1:4] y <- unclass(iris[,5]) dCov(x, y, alpha = 1)