Learn R Programming

grpss (version 3.0.1)

distcor: Compute the distance correlation

Description

Computes the distance correlation between two random variables.

Usage

distcor(X, y)

Arguments

X
A numeric vector or matrix.
y
A numeric vector or matrix.

Value

A sample distance correlation.

Details

Distance correlation measures the statistical dependence between two random variables or two random vectors. The important property is that the distance correlation is zero if and only if two random variables are independent. The details of computing the distance correlation can be seen in Szekely, Rizzo and Bakirov (2007) or https://en.wikipedia.org/wiki/Distance_correlation. This function is the same as dcor in energy package.

References

Szekely, G.J., Rizzo, M.L., and Bakirov, N.K. (2007), Measuring and Testing Dependence by Correlation of Distances, Annals of Statistics, Vol. 35 No. 6, pp. 2769-2794.

Examples

Run this code
X <- matrix(rnorm(200),ncol = 2)
y <- X%*%matrix(c(1.5,4),ncol = 1) + rnorm(100) # univariate y
distcor(X,y)

X <- iris[1:50, 1:4]
Y <- iris[51:100, 1:4]   # multiple response y
distcor(X,Y)

Run the code above in your browser using DataLab