regrXonS: Regress set of variables on its parents

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/regrXonS.R

Description

Uses the generalised additive model gam to non-linearly and non-parametrically regress set of variables X on a set of variables S and returns residuals of X.

Usage

1
regrXonS(X, S)

Arguments

X

numeric matrix, set of variables to be regressed. Each column represents separate variable

S

numeric matrix, set of variables we will regress on. Each column represents separate variable

Details

If the number of variables in S is <= 5 we use frml.full.smooth as formula for gam to regress X on S, otherwise we use frml.additive.smooth.

Value

regrXonS() returns the residuals of X regressed on S.

Author(s)

Petras Verbyla (petras.verbyla@mrc-bsu.cam.ac.uk)

See Also

kernelCItest

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
set.seed(10)
library(energy)
z <- 10*runif(300)
w <- 10*runif(300)
x <- sin(z) + runif(300)
y <- cos(z) + runif(300)
data <- cbind(x,y,z,w)

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

resid <- regrXonS(cbind(x,y),cbind(z,w))

hsic.gamma(resid[,1],resid[,2])
hsic.perm(resid[,1],resid[,2])
dcov.test(resid[,1],resid[,2])

Example output

	HSIC test of independence

data:  Gamma approximation
HSIC = 0.0037736, p-value = 0.0001712
sample estimates:
       HSIC 
0.003773572 


	HSIC test of independence

data:  Permutation approximation
HSIC = 0.0037736, p-value = 0.0198
sample estimates:
       HSIC 
0.003773572 


	Specify the number of replicates R (R > 0) to perform the test of
	independence

data:  index 1, replicates 0
nV^2 = 1.7572, p-value = NA
sample estimates:
      dCov 
0.07653368 


	HSIC test of independence

data:  Gamma approximation
HSIC = 2.8165e-05, p-value = 0.5805
sample estimates:
        HSIC 
2.816463e-05 


	HSIC test of independence

data:  Permutation approximation
HSIC = 2.8165e-05, p-value = 0.5941
sample estimates:
        HSIC 
2.816463e-05 


	Specify the number of replicates R (R > 0) to perform the test of
	independence

data:  index 1, replicates 0
nV^2 = 0.078235, p-value = NA
sample estimates:
      dCov 
0.01614876 

kpcalg documentation built on May 2, 2019, 12:39 p.m.