indep.test {energy}R Documentation

Energy-tests of Independence


Computes a multivariate nonparametric test of independence. The default method implements the distance covariance test dcov.test.


indep.test(x, y, method = c("dcov","mvI"), index = 1, R)



matrix: first sample, observations in rows


matrix: second sample, observations in rows


a character string giving the name of the test


exponent on Euclidean distances


number of replicates


indep.test with the default method = "dcov" computes the distance covariance test of independence. index is an exponent on the Euclidean distances. Valid choices for index are in (0,2], with default value 1 (Euclidean distance). The arguments are passed to the dcov.test function. See the help topic dcov.test for the description and documentation and also see the references below.

indep.test with method = "mvI" computes the coefficient \mathcal I_n and performs a nonparametric \mathcal E-test of independence. The arguments are passed to mvI.test. The index argument is ignored (index = 1 is applied). See the help topic mvI.test and also see the reference (2006) below for details.

The test decision is obtained via bootstrap, with R replicates. The sample sizes (number of rows) of the two samples must agree, and samples must not contain missing values.

These energy tests of independence are based on related theoretical results, but different test statistics. The dcov method is faster than mvI method by approximately a factor of O(n).


indep.test returns a list with class htest containing


description of test


observed value of the test statistic n \mathcal V_n^2 or n \mathcal I_n^2


\mathcal V_n or \mathcal I_n


a vector [dCov(x,y), dCor(x,y), dVar(x), dVar(y)] (method dcov)


replicates of the test statistic


approximate p-value of the test

description of data


As of energy-1.1-0, indep.etest is deprecated and replaced by indep.test, which has methods for two different energy tests of independence. indep.test applies the distance covariance test (see dcov.test) by default (method = "dcov"). The original indep.etest applied the independence coefficient \mathcal I_n, which is now obtained by method = "mvI".


Maria L. Rizzo and Gabor J. Szekely


Szekely, G.J. and Rizzo, M.L. (2009), Brownian Distance Covariance, Annals of Applied Statistics, Vol. 3 No. 4, pp. 1236-1265. (Also see discussion and rejoinder.)
doi: 10.1214/09-AOAS312

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.
doi: 10.1214/009053607000000505

Bakirov, N.K., Rizzo, M.L., and Szekely, G.J. (2006), A Multivariate Nonparametric Test of Independence, Journal of Multivariate Analysis 93/1, 58-80,
doi: 10.1016/j.jmva.2005.10.005

See Also

dcov.test mvI.test dcov mvI


 ## independent multivariate data
 x <- matrix(rnorm(60), nrow=20, ncol=3)
 y <- matrix(rnorm(40), nrow=20, ncol=2)
 indep.test(x, y, method = "dcov", R = 99)
 indep.test(x, y, method = "mvI", R = 99)

 ## dependent multivariate data
 if (require(MASS)) {
   Sigma <- matrix(c(1, .1, 0, 0 , 1, 0, 0 ,.1, 1), 3, 3)
   x <- mvrnorm(30, c(0, 0, 0), diag(3))
   y <- mvrnorm(30, c(0, 0, 0), Sigma) * x
   indep.test(x, y, R = 99)    #dcov method
   indep.test(x, y, method = "mvI", R = 99)

[Package energy version 1.7-10 Index]