Package 'dcov'

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

Help Index


Centering method This method implements the double centering and U-centering during computing distance covariance.

Description

Centering method This method implements the double centering and U-centering during computing distance covariance.

Usage

centering(D, type = c("V", "U"))

centering_from_data(x, type = c("V", "U"))

Arguments

D

the pairwise distance matrix

type

"V" or "U". "V" for double centering. "U" for U-centering.

x

the matrix of x

Examples

x = matrix(rnorm(200),100,2)
D = as.matrix(dist(x))
A = centering(D,'U')
A = centering_from_data(x)

Permutation test of distance correlation and partial distance correlation

Description

Simple independence test based on data permutation using distance correlation and partial distance correlation.

Usage

dcor.test(x, y, R = 500, type = c("V", "U"))

pdcor.test(x, y, z, R = 500, type = c("U", "V"))

Arguments

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.

Examples

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

Description

Distance correlation T-test It uses the result of U-statistic distance correlation to test independence for high dimensional data

Usage

dcor.ttest(x, y)

Arguments

x

data of x

y

data of y

Examples

n = 200
x = rnorm(n)
y = rnorm(n)
res = dcor.ttest(x,y)

Distance covariance

Description

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.

Usage

dcov(x, y, type = c("V", "U"))

dcor(x, y, type = c("V", "U"))

Arguments

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

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

References

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.

See Also

dcov2d

Examples

x = matrix(rnorm(200),100,2)
y = matrix(rnorm(200),100,2)
dcov(x,y)
dcor(x,y)

Fast distance covariance for two bivariate variables

Description

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

Usage

dcov2d(x, y, type = c("V", "U"))

dcor2d(x, y, type = c("V", "U"))

Arguments

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

References

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.

Examples

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

Description

Marginal distance covariance This function implements the method of calculating distance covariance between y and each column in x

Usage

mdcov(y, x, type = c("V", "U"))

mdcor(y, x, type = c("V", "U"))

Arguments

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

Examples

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)

Description

Projection covariance between two random vectors This function implements the projection correlation in Zhu et al.(2017)

Usage

pcov(x, y)

Arguments

x

the matrix of x

y

the matrix of y

References

Zhu, L., Xu, K., Li, R., & Zhong, W. (2017). Projection correlation between two random vectors. Biometrika, 104(4), 829-843.

Examples

x = matrix(rnorm(200),100,2)
y = matrix(rnorm(200),100,2)
pcov(x,y)

Partial distance covariance

Description

This method implements the method to compute the value of partial distance covariance proposed by Székely and Rizzo, 2014.

Usage

pdcov(x, y, z, type = c("U", "V"))

pdcor(x, y, z, type = c("U", "V"))

Arguments

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

References

Székely, G. J., & Rizzo, M. L. (2014). Partial distance correlation with methods for dissimilarities. The Annals of Statistics, 42(6), 2382-2412.

Examples

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)