CondIndTest: Wrapper function for conditional independence tests.

Description Usage Arguments Value References Examples

View source: R/CondIndTest.R

Description

Tests the null hypothesis that Y and E are independent given X.

Usage

1
2
CondIndTest(Y, E, X, method = "KCI", alpha = 0.05,
  parsMethod = list(), verbose = FALSE)

Arguments

Y

An n-dimensional vector or a matrix or dataframe with n rows and p columns.

E

An n-dimensional vector or a matrix or dataframe with n rows and p columns.

X

An n-dimensional vector or a matrix or dataframe with n rows and p columns.

method

The conditional indepdence test to use, can be one of "KCI", "InvariantConditionalQuantilePrediction", "InvariantEnvironmentPrediction", "InvariantResidualDistributionTest", "InvariantTargetPrediction", "ResidualPredictionTest".

alpha

Significance level. Defaults to 0.05.

parsMethod

Named list to pass options to method.

verbose

If TRUE, intermediate output is provided. Defaults to FALSE.

Value

A list with the p-value of the test (pvalue) and possibly additional entries, depending on the output of the chosen conditional independence test in method.

References

Please cite C. Heinze-Deml, J. Peters and N. Meinshausen: "Invariant Causal Prediction for Nonlinear Models", arXiv:1706.08576 and the corresponding reference for the conditional independence test.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# Example 1
set.seed(1)
n <- 100
Z <- rnorm(n)
X <- 4 + 2 * Z + rnorm(n)
Y <- 3 * X^2 + Z + rnorm(n)
test1 <- CondIndTest(X,Y,Z, method = "KCI")
cat("These data come from a distribution, for which X and Y are NOT
cond. ind. given Z.")
cat(paste("The p-value of the test is: ", test1$pvalue))

# Example 2
set.seed(1)
Z <- rnorm(n)
X <- 4 + 2 * Z + rnorm(n)
Y <- 3 + Z + rnorm(n)
test2 <- CondIndTest(X,Y,Z, method = "KCI")
cat("The data come from a distribution, for which X and Y are cond.
ind. given Z.")
cat(paste("The p-value of the test is: ", test2$pvalue))

CondIndTests documentation built on Nov. 12, 2019, 9:07 a.m.