mdcov: Computation of the multidimensional distance covariance...

Description Usage Arguments Value Author(s) References Examples

View source: R/mdcov.R

Description

Computation of the multidimensional distance covariance statistic for mutual independence using characteristic functions. Compute the eigenvalues associated with the empirical covariance of the limiting Gaussian procces. Compute the p-value associated with the test statistic, using the Imhof procedure.

Usage

1
2
3
mdcov(X, vecd, a = 1, weight.choice = 1, N = 200, cubature = FALSE, K =
100, epsrel = 10 ^ -6, norming = TRUE, thresh.eigen = 10 ^ -8, estim.a =
FALSE, Cpp = TRUE, pval.comp = TRUE)

Arguments

X

Data.frame or matrix with observations corresponding to rows and variables to columns.

vecd

a vector giving the sizes of each subvector.

a

parameter for the weight function.

weight.choice

Integer value in 1, 2, 3, 4, 5 corresponding to the choice in our paper.

N

Number of Monte-Carlo samples.

cubature

Logical. If FALSE, a Monte-Carlo approach is used. If TRUE, a cubature approach is used.

K

Number of eigenvalues to compute.

epsrel

relative accuracy requested for the Imhof procedure.

norming

Logical. Should we normalize the test statistic with H_n.

thresh.eigen

We will not compute eigenvalues (involved in the limiting distribution) below that threshold.

estim.a

Logical. Should we automatically estimate the value of a.

Cpp

Logical. If TRUE computations will be done using a fast C code. The use of FALSE is only useful to compare the results with the one given by the C code.

pval.comp

Logical. If FALSE do not compute the p-values and lambdas.

Value

A list with the following components:

mdcov

the value of the statistic n * Tn(w) (this value has been normed if norming = TRUE)

Hn

the denominator of nTn(w), namely H_n

pvalue

the p-value of the test

lambdas

the vector of eigenvalues computed (they have not been divided by their sum)

Author(s)

Lafaye de Micheaux P.

References

Fan Y., Lafaye de Micheaux P., Penev S. and Salopek D. (2017). Multivariate nonparametric test of independence, Journal of Multivariate Analysis, 153, 189-210.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
a <- 1

# 4.1 Dependence among four discrete variables
set.seed(1)
n <- 100
w1 <- rpois(n, 1)
w3 <- rpois(n, 1)
w4 <- rpois(n, 1)
w6 <- rpois(n, 1)
w2 <- rpois(n, 3)
w5 <- rpois(n, 3)
x1 <- w1 + w2
x2 <- w2 + w3
x3 <- w4 + w5
x4 <- w5 + w6

X <- cbind(x1, x2, x3, x4)
mdcov(X, vecd = c(2, 2), a, weight.choice = 1, N = 100, cubature = TRUE)
mdcov(X, vecd = c(1, 1, 1, 1), a, weight.choice = 1, N = 100, cubature = TRUE)

X <- cbind(x1, x2)
mdcov(X, vecd = c(1, 1), a, weight.choice = 1, N = 100, cubature = TRUE)

X <- cbind(x3, x4)
mdcov(X, vecd = c(1, 1), a, weight.choice = 1, N = 100, cubature = TRUE)

# 4.2 Dependence between three bivariate vectors
set.seed(2)
n <- 200
Sigma <- matrix(c(
1 , 0 ,  0 ,  0 ,  0 ,  0 ,
0 , 1 ,  0 ,  0 ,  0 ,  0 ,
0 , 0 ,  1 ,  0 , .4 , .5 ,
0 , 0 ,  0 ,  1 , .1 , .2 ,
0 , 0 , .4 , .1 ,  1 ,  0 ,
0 , 0 , .5 , .2 ,  0 ,  1 ) ,
nrow = 6 , ncol = 6)   
W <- mvrnorm(n = n, mu = rep(0,6), Sigma = Sigma, tol = 1e-6, empirical = FALSE, EISPACK = FALSE)
mdcov(W, vecd = c(2, 2, 2), a, weight.choice = 1, N = 100, cubature = TRUE, epsrel = 10 ^ -7)

 # X^{(1)} with X^{(2)}^2
mdcov(W[,1:4], vecd = c(2, 2), a, weight.choice = 1, N = 100, cubature = TRUE)

# X^{(2)} with X^{(3)}^2
mdcov(W[,2:6], vecd = c(2, 2), a, weight.choice = 1, N = 100, cubature = TRUE)

# X^{(1)} with X^{(3)}^2
mdcov(W[,c(1:2, 4:6)], vecd = c(2, 2), a, weight.choice = 1, N = 100, cubature = TRUE)

# 4.3 Four-dependent variables which are 2-independent and 3-independent
set.seed(3)
n <- 300
W <- sample(1:8, n, replace = TRUE)
X1 <- W %in% c(1, 2, 3, 5)
X2 <- W %in% c(1, 2, 4, 6)
X3 <- W %in% c(1, 3, 4, 7)
X4 <- W %in% c(2, 3, 4, 8)
X <- cbind(X1, X2, X3, X4)
   # pairwise independence
mdcov(X[,c(1, 2)], vecd = c(1, 1), a, weight.choice = 1, cubature = TRUE)
mdcov(X[,c(1, 3)], vecd = c(1, 1), a, weight.choice = 1, N = 100, cubature = TRUE)
mdcov(X[,c(1, 4)], vecd = c(1, 1), a, weight.choice = 1, cubature = TRUE)
mdcov(X[,c(2, 3)], vecd = c(1, 1), a, weight.choice = 1, cubature = TRUE)
mdcov(X[,c(2, 4)], vecd = c(1, 1), a, weight.choice = 1, cubature = TRUE)
mdcov(X[,c(3, 4)], vecd = c(1, 1), a, weight.choice = 1, cubature = TRUE)
   # 3-independence
mdcov(X[,c(1, 2, 3)], vecd = c(1, 1, 1), a, weight.choice =
                  1, cubature = TRUE)
mdcov(X[,c(1, 2, 4)], vecd = c(1, 1, 1), a, weight.choice =
                  1, cubature = TRUE)
mdcov(X[,c(1, 3, 4)], vecd = c(1, 1, 1), a, weight.choice =
                  1, cubature = TRUE)
mdcov(X[,c(2, 3, 4)], vecd = c(1, 1, 1), a, weight.choice =
                  1, cubature = TRUE)
   # 4-dependence
mdcov(X, vecd = c(1, 1, 1, 1), a, weight.choice = 1, cubature = TRUE)

IndependenceTests documentation built on Dec. 18, 2020, 5:08 p.m.