Learn R Programming

energy (version 1.7-12)

indep.test: Energy-tests of Independence

Description

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

Usage

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

Value

indep.test returns a list with class

htest containing

method

description of test

statistic

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

estimate

\(\mathcal V_n\) or \(\mathcal I_n\)

estimates

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

replicates

replicates of the test statistic

p.value

approximate p-value of the test

data.name

description of data

Arguments

x

matrix: first sample, observations in rows

y

matrix: second sample, observations in rows

method

a character string giving the name of the test

index

exponent on Euclidean distances

R

number of replicates

Author

Maria L. Rizzo mrizzo@bgsu.edu and Gabor J. Szekely

Details

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).

References

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.)
tools:::Rd_expr_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.
tools:::Rd_expr_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,
tools:::Rd_expr_doi("10.1016/j.jmva.2005.10.005")

See Also

dcov.test mvI.test dcov mvI

Examples

Run this code
# \donttest{
 ## 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)
    }
  # }

Run the code above in your browser using DataLab