Title: | A Fast Implementation of Distance Covariance |
---|---|
Description: | Efficient methods for computing distance covariance and relevant statistics. See Székely et al.(2007) <doi:10.1214/009053607000000505>; Székely and Rizzo (2013) <doi:10.1016/j.jmva.2013.02.012>; Székely and Rizzo (2014) <doi:10.1214/14-AOS1255>; Huo and Székely (2016) <doi:10.1080/00401706.2015.1054435>. |
Authors: | Hang Weiqiang <[email protected]> |
Maintainer: | Hang Weiqiang <[email protected]> |
License: | GPL-2 |
Version: | 0.1.1 |
Built: | 2024-11-27 06:42:37 UTC |
Source: | CRAN |
Centering method This method implements the double centering and U-centering during computing distance covariance.
centering(D, type = c("V", "U")) centering_from_data(x, type = c("V", "U"))
centering(D, type = c("V", "U")) centering_from_data(x, type = c("V", "U"))
D |
the pairwise distance matrix |
type |
"V" or "U". "V" for double centering. "U" for U-centering. |
x |
the matrix of x |
x = matrix(rnorm(200),100,2) D = as.matrix(dist(x)) A = centering(D,'U') A = centering_from_data(x)
x = matrix(rnorm(200),100,2) D = as.matrix(dist(x)) A = centering(D,'U') A = centering_from_data(x)
Simple independence test based on data permutation using distance correlation and partial distance correlation.
dcor.test(x, y, R = 500, type = c("V", "U")) pdcor.test(x, y, z, R = 500, type = c("U", "V"))
dcor.test(x, y, R = 500, type = c("V", "U")) pdcor.test(x, y, z, R = 500, type = c("U", "V"))
x |
the data of x |
y |
the data of y |
R |
the number of replicates |
type |
"U" or "V" |
z |
the data of controlling variables. Given z, pdcor between x and y is calculated. |
n = 200 z = rnorm(n) x = rnorm(n)*z y = rnorm(n)*z res1 = dcor.test(x,y,R=500) res2 = pdcor.test(x,y,z,R=500)
n = 200 z = rnorm(n) x = rnorm(n)*z y = rnorm(n)*z res1 = dcor.test(x,y,R=500) res2 = pdcor.test(x,y,z,R=500)
Distance correlation T-test It uses the result of U-statistic distance correlation to test independence for high dimensional data
dcor.ttest(x, y)
dcor.ttest(x, y)
x |
data of x |
y |
data of y |
n = 200 x = rnorm(n) y = rnorm(n) res = dcor.ttest(x,y)
n = 200 x = rnorm(n) y = rnorm(n) res = dcor.ttest(x,y)
This method implements the method to compute the value of distance covariance proposed by Székely et al.(2007) and Székely and Rizzo(2013) by Armadillo library. For distance covariance between two one dimensional variables, the fast algorithm proposed by Huo and Székely(2016) is used.
dcov(x, y, type = c("V", "U")) dcor(x, y, type = c("V", "U"))
dcov(x, y, type = c("V", "U")) dcor(x, y, type = c("V", "U"))
x |
the matrix of x |
y |
the matrix of y |
type |
"V" or "U", for V- or U-statistics of distance covariance or correlation. The default value is "V". |
Note that the result of dcov(x,y,"V")
and dcor(x,y,"V")
is same with the result of energy::dcov(x,y)^2 and energy::dcor(x,y)^2.
The result of dcov(x,y,'U')
and dcor(x,y,'U')
is same with
the result of energy::dcovU(x,y)
and energy::bcdcor(x,y)
.
Székely, G. J., Rizzo, M. L., & Bakirov, N. K. (2007). Measuring and testing dependence by correlation of distances. The annals of statistics, 35(6), 2769-2794.
Székely, G. J., & Rizzo, M. L. (2013). The distance correlation t-test of independence in high dimension. Journal of Multivariate Analysis, 117, 193-213.
Huo, X., & Székely, G. J. (2016). Fast computing for distance covariance. Technometrics, 58(4), 435-447.
dcov2d
x = matrix(rnorm(200),100,2) y = matrix(rnorm(200),100,2) dcov(x,y) dcor(x,y)
x = matrix(rnorm(200),100,2) y = matrix(rnorm(200),100,2) dcov(x,y) dcor(x,y)
This method implements the fast algorithm proposed by Huo and Székely. The
result of dcov2d
and dcor2d
is same with the result of
energy::dcov2d
and energy::dcor2d
dcov2d(x, y, type = c("V", "U")) dcor2d(x, y, type = c("V", "U"))
dcov2d(x, y, type = c("V", "U")) dcor2d(x, y, type = c("V", "U"))
x |
the vector of x |
y |
the vector of y |
type |
"V" or "U", for V- or U-statistics of distance covariance or correlation. The default value is "V". |
Székely, G. J., Rizzo, M. L., & Bakirov, N. K. (2007). Measuring and testing dependence by correlation of distances. The annals of statistics, 35(6), 2769-2794.
Székely, G. J., & Rizzo, M. L. (2013). The distance correlation t-test of independence in high dimension. Journal of Multivariate Analysis, 117, 193-213.
Huo, X., & Székely, G. J. (2016). Fast computing for distance covariance. Technometrics, 58(4), 435-447.
x = rnorm(200) y = rnorm(200) dcov2d(x,y) dcor2d(x,y)
x = rnorm(200) y = rnorm(200) dcov2d(x,y) dcor2d(x,y)
Marginal distance covariance This function implements the method of calculating distance covariance between y and each column in x
mdcov(y, x, type = c("V", "U")) mdcor(y, x, type = c("V", "U"))
mdcov(y, x, type = c("V", "U")) mdcor(y, x, type = c("V", "U"))
y |
the matrix of y |
x |
the matrix of x, distance covariance is calculated for each variable in x with y. |
type |
"V" or "U", for V- or U-statistics of distance covariance or correlation. The default value is "V". |
n = 200; p = 10 y = matrix(rnorm(n*2),n,2) x = matrix(rnorm(n*p),n,p) res1 = mdcov(y,x) res2 = numeric(p) for(j in 1:p){res2[j] = dcov::dcov(y,x[,j])} # res1 is same with res2 res1 - res2 res3 = mdcor(y,x) res4 = numeric(p) for(j in 1:p){res4[j] = dcov::dcor(y,x[,j])} # res3 is same with res4 res3-res4
n = 200; p = 10 y = matrix(rnorm(n*2),n,2) x = matrix(rnorm(n*p),n,p) res1 = mdcov(y,x) res2 = numeric(p) for(j in 1:p){res2[j] = dcov::dcov(y,x[,j])} # res1 is same with res2 res1 - res2 res3 = mdcor(y,x) res4 = numeric(p) for(j in 1:p){res4[j] = dcov::dcor(y,x[,j])} # res3 is same with res4 res3-res4
Projection covariance between two random vectors This function implements the projection correlation in Zhu et al.(2017)
pcov(x, y)
pcov(x, y)
x |
the matrix of x |
y |
the matrix of y |
Zhu, L., Xu, K., Li, R., & Zhong, W. (2017). Projection correlation between two random vectors. Biometrika, 104(4), 829-843.
x = matrix(rnorm(200),100,2) y = matrix(rnorm(200),100,2) pcov(x,y)
x = matrix(rnorm(200),100,2) y = matrix(rnorm(200),100,2) pcov(x,y)
This method implements the method to compute the value of partial distance covariance proposed by Székely and Rizzo, 2014.
pdcov(x, y, z, type = c("U", "V")) pdcor(x, y, z, type = c("U", "V"))
pdcov(x, y, z, type = c("U", "V")) pdcor(x, y, z, type = c("U", "V"))
x |
the matrix of x |
y |
the matrix of y |
z |
the matrix of z. Given the value of z, pdcov or pdcor between x and y is calcuated. |
type |
"V" or "U", for V- or U-statistics of partial distance covariance or correlation. The default value is "U". |
Székely, G. J., & Rizzo, M. L. (2014). Partial distance correlation with methods for dissimilarities. The Annals of Statistics, 42(6), 2382-2412.
z = matrix(rnorm(400),200,2) x = matrix(rnorm(400),200,2)*z y = matrix(rnorm(400),200,2)*z pdcov(x,y,z) pdcor(x,y,z)
z = matrix(rnorm(400),200,2) x = matrix(rnorm(400),200,2)*z y = matrix(rnorm(400),200,2)*z pdcov(x,y,z) pdcor(x,y,z)