Description Usage Arguments Value References See Also Examples
Performs the nonparametric conditional distance covariance test for conditional independence assumption
1 2 | cdcov.test(x, y, z, num.bootstrap = 99, width, distance = FALSE,
index = 1, seed = 1, num.threads = 1)
|
x |
a numeric vector, matrix, or |
y |
a numeric vector, matrix, or |
z |
|
num.bootstrap |
the number of local bootstrap procedure replications. Default: |
width |
a user-specified positive value (univariate conditional variable) or vector (multivariate conditional variable) for
gaussian kernel bandwidth. Its default value is relies on |
distance |
if |
index |
exponent on Euclidean distance, in (0,2] |
seed |
the random seed |
num.threads |
number of threads. Default |
cdcov.test
returns a list with class "htest" containing the following components:
|
conditional distance covariance statistic. |
|
the p-value for the test. |
|
the number of local bootstrap procedure replications. |
|
sample sizes. |
|
a character string describing the alternative hypothesis. |
|
a character string indicating what type of test was performed. |
|
description of data. |
Wang, X., Pan, W., Hu, W., Tian, Y. and Zhang, H., 2015. Conditional distance correlation. Journal of the American Statistical Association, 110(512), pp.1726-1734.
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 | ## Not run:
library(cdcsis)
set.seed(1)
num <- 50
################# Conditional Independent #################
## Case 1:
cov_mat <- matrix(c(1, 0.36, 0.6, 0.36, 1, 0.6, 0.6, 0.6, 1), nrow = 3)
dat <- mvtnorm::rmvnorm(n = num, sigma = cov_mat)
x <- dat[, 1]
y <- dat[, 2]
z <- dat[, 3]
cdcov.test(x, y, z)
## Case 2:
z <- rnorm(num)
x <- 0.5 * (z^3 / 7 + z / 2) + tanh(rnorm(num))
x <- x + x^3 / 3
y <- (z^3 + z) / 3 + rnorm(num)
y <- y + tanh(y / 3)
cdcov.test(x, y, z, num.bootstrap = 99)
################# Conditional Dependent #################
## Case 3:
cov_mat <- matrix(c(1, 0.7, 0.6, 0.7, 1, 0.6, 0.6, 0.6, 1), nrow = 3)
dat <- mvtnorm::rmvnorm(n = num, sigma = cov_mat)
x <- dat[, 1]
y <- dat[, 2]
z <- dat[, 3]
cdcov.test(x, y, z, width = 0.5)
## Case 4:
z <- matrix(rt(num * 4, df = 2), nrow = num)
x <- z
y <- cbind(sin(z[, 1]) + cos(z[, 2]) + (z[, 3])^2 + (z[, 4])^2,
(z[, 1])^2 + (z[, 2])^2 + z[, 3] + z[, 4])
z <- z[, 1:2]
cdcov.test(x, y, z, seed = 2)
################# Distance Matrix Input #################
x <- dist(x)
y <- dist(y)
cdcov.test(x, y, z, seed = 2, distance = TRUE)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.