Learn R Programming

kpcalg (version 1.0.1)

hsic.test: Hilber Schmidt Independence Criterion test

Description

Test to check the independence between two variables x and y using HSIC. The hsic.test() function, uses Hilbert-Schmidt independence criterion to test for independence between two random variables.

Usage

hsic.test(x, y, p = 0, hsic.method = c("gamma", "perm"), sig = 1, numCol = floor(length(x)/10))

Arguments

x
data of first sample
y
data of second sample
p
number of replicates, if 0
hsic.method
method for HSIC test, either gamma test hsic.gamma or permutation test hsic.perm
sig
Gaussian kernel width for HSIC. Default is 1
numCol
number of columns in the Incomplete Cholesky Decomposition of Gram matrices. Default is floor(length(x)/10)

Value

hsic.gamma() returns a list with class htest containing hsic.gamma() returns a list with class htest containing

Details

Let x and y be two samples of length n. Gram matrices K and L are defined as: $K_{i,j} =exp((x_i-x_j)^2/sig^2)$ and $L_{i,j} =exp((y_i-y_j)^2/sig^2)$. $H_{i,j} = delta_{i,j} - 1/n$. Let $A=HKH$ and $B=HLH$, then $HSIC(x,y)=Tr(AB)/n^2$.

References

A. Gretton et al. (2005). Kernel Methods for Measuring Independence. JMLR 6 (2005) 2075-2129.

See Also

hsic.perm, hsic.clust, kernelCItest

Examples

Run this code
library(energy)
set.seed(10)
#independence
x <- runif(300)
y <- runif(300)

hsic.gamma(x,y)
hsic.perm(x,y)
dcov.gamma(x,y)
dcov.test(x,y)

#uncorelated but not dependent
z <- 10*(runif(300)-0.5)
w <- z^2 + 10*runif(300)

cor(z,w)
hsic.gamma(z,w)
hsic.perm(z,w)
dcov.gamma(z,w)
dcov.test(z,w)

Run the code above in your browser using DataLab