Description Usage Arguments Details Value References See Also Examples
Nonlinear Invariant Causal Prediction
1 2 3 4 5 6 7  nonlinearICP(X, Y, environment,
condIndTest = InvariantResidualDistributionTest, argsCondIndTest = NULL,
alpha = 0.05, varPreSelectionFunc = NULL,
argsVarPreSelectionFunc = NULL, maxSizeSets = ncol(X),
condIndTestNames = NULL, speedUp = FALSE, subsampleSize = c(0.1, 0.25,
0.5, 0.75, 1), retrieveDefiningsSets = TRUE, seed = 1,
stopIfEmpty = TRUE, testAdditionalSet = NULL, verbose = FALSE)

X 
A (nxp)dimensional matrix (or data frame) with n observations of p variables. 
Y 
A (nx1)dimensional response vector. 
environment 
Environment variable(s) in an (n x k)dimensional matrix or dataframe. Note that not all nonlinear conditional independence tests may support more than one environmental variable. 
condIndTest 
Function implementing a conditional independence test (see below
for the required interface). Defaults to 
argsCondIndTest 
Arguments of 
alpha 
Significance level to be used. Defaults to 
varPreSelectionFunc 
Variable selection function that is applied
to preselect a set of variables before running the ICP procedure on the resulting
subset. Should be used with care as causal parents might be excluded in this step.
Defaults to 
argsVarPreSelectionFunc 
Arguments of 
maxSizeSets 
Maximal size of sets considered as causal parents.
Defaults to 
condIndTestNames 
Name of conditional independence test, used for printing.
Defaults to 
speedUp 
Use subsamples of sizes specified in 
subsampleSize 
Size of subsamples used in 
retrieveDefiningsSets 
Boolean variable to indicate whether defining sets
should be retrieved. Defaults to 
seed 
Random seed. 
stopIfEmpty 
Stop ICP procedure if retrieved set is empty. If

testAdditionalSet 
If a particular set should be tested, the corresponding indices can be provided via this argument. 
verbose 
Boolean variable to indicate whether messages should be printed. 
The function provided as condIndTest
needs to take the following
arguments in the given order: Y, environment, X, alpha, verbose
. Additional
arguments can then be provided via argsCondIndTest
.
A list with the following elements:
retrievedCausalVars
Indices of variables in \hat{S}
acceptedSets
List of accepted sets.
definingSets
List of defining sets.
acceptedModels
List of accepted models if specified in argsCondIndTest
.
pvalues.accepted
Pvalues of accepted sets.
rejectedSets
List of rejected sets.
pvalues.rejected
Pvalues of rejected sets.
settings
Settings provided to nonlinearICP
.
Please cite C. HeinzeDeml, J. Peters and N. Meinshausen: "Invariant Causal Prediction for Nonlinear Models", arXiv:1706.08576.
The function CondIndTest
from the package
CondIndTests
is a wrapper for a variety of nonlinear conditional independence
tests that can be used in condIndTest
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24  # Example 1
require(CondIndTests)
data("simData")
targetVar < 2
# choose environments where we did not intervene on var
useEnvs < which(simData$interventionVar[,targetVar] == 0)
ind < is.element(simData$environment, useEnvs)
X < simData$X[ind,targetVar]
Y < simData$X[ind,targetVar]
E < as.factor(simData$environment[ind])
result < nonlinearICP(X = X, Y = Y, environment = E)
cat(paste("Variable",result$retrievedCausalVars, "was retrieved as the causal
parent of target variable", targetVar))
###################################################
# Example 2
E < rep(c(1,2), each = 500)
X1 < E + 0.1*rnorm(1000)
X1 < rnorm(1000)
X2 < X1 + E^2 + 0.1*rnorm(1000)
Y < X1 + X2 + 0.1*rnorm(1000)
resultnonlinICP < nonlinearICP(cbind(X1,X2), Y, as.factor(E))
summary(resultnonlinICP)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.