<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Sequential Invariant Causal Prediction for an individual set...</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="R.css" />
</head><body>

<table width="100%" summary="page for seqICP.s"><tr><td>seqICP.s</td><td style="text-align: right;">R Documentation</td></tr></table>

<h2>Sequential Invariant Causal Prediction for an individual
set S</h2>

<h3>Description</h3>

<p>Tests whether the conditional distribution of Y given X^S is
invariant across time, by assuming a linear dependence model.
</p>


<h3>Usage</h3>

<pre>
seqICP.s(X, Y, S, test = "decoupled", par.test = list(grid = c(0,
  round(nrow(X)/2), nrow(X)), complements = FALSE, link = sum, alpha = 0.05, B =
  100, permutation = FALSE), model = "iid", par.model = list(pknown = FALSE,
  p = 0, max.p = 10))
</pre>


<h3>Arguments</h3>

<table summary="R argblock">
<tr valign="top"><td><code>X</code></td>
<td>
<p>matrix of predictor variables. Each column corresponds to
one predictor variable.</p>
</td></tr>
<tr valign="top"><td><code>Y</code></td>
<td>
<p>vector of target variable, with length(Y)=nrow(X).</p>
</td></tr>
<tr valign="top"><td><code>S</code></td>
<td>
<p>vector containing the indicies of predictors to be tested</p>
</td></tr>
<tr valign="top"><td><code>test</code></td>
<td>
<p>string specifying the hypothesis test used to test for
invariance of a parent set S (i.e. the null hypothesis
H0_S). The following tests are available: &quot;decoupled&quot;,
&quot;combined&quot;, &quot;trend&quot;, &quot;variance&quot;, &quot;block.mean&quot;, &quot;block.variance&quot;,
&quot;block.decoupled&quot;, &quot;smooth.mean&quot;, &quot;smooth.variance&quot;,
&quot;smooth.decoupled&quot; and &quot;hsic&quot;.</p>
</td></tr>
<tr valign="top"><td><code>par.test</code></td>
<td>
<p>parameters specifying hypothesis test. The
following parameters are available: <code>grid</code>,
<code>complements</code>, <code>link</code>, <code>alpha</code>, <code>B</code> and
<code>permutation</code>. The parameter <code>grid</code> is an increasing
vector of gridpoints used to construct enviornments for change
point based tests. If the parameter <code>complements</code> is 'TRUE'
each environment is compared against its complement if it is
'FALSE' all environments are compared pairwise. The parameter
<code>link</code> specifies how to compare the pairwise test
statistics, generally this is either max or sum. The parameter
<code>alpha</code> is a numeric value in (0,1) indicting the
significance level of the hypothesis test. The parameter
<code>B</code> is an integer and specifies the number of Monte-Carlo
samples (or permutations) used in the approximation of the null
distribution. If the parameter <code>permutation</code> is 'TRUE' a
permuatation based approach is used to approximate the null
distribution, if it is 'FALSE' the scaled residuals approach is
used.</p>
</td></tr>
<tr valign="top"><td><code>model</code></td>
<td>
<p>string specifying the underlying model class. Either
&quot;iid&quot; if Y consists of independent observations or &quot;ar&quot; if Y has
a linear time dependence structure.</p>
</td></tr>
<tr valign="top"><td><code>par.model</code></td>
<td>
<p>parameters specifying model. The following
parameters are available: <code>pknown</code>, <code>p</code> and
<code>max.p</code>. If <code>pknown</code> is 'FALSE' the number of lags will be
determined by comparing all fits up to <code>max.p</code> lags using
the AIC criterion. If <code>pknown</code> is 'TRUE' the procedure will fit
<code>p</code> lags.</p>
</td></tr>
</table>


<h3>Details</h3>

<p>The function can be applied to two types of models<br />
(1) a linear model (model=&quot;iid&quot;)<br /> Y_i = a X_i^S + N_i<br /> with iid noise N_i and <br />
(2) a linear autoregressive model (model=&quot;ar&quot;)<br /> Y_t = a_0 X_t^S + ... + a_p (Y_(t-p),X_(t-p)) + N_t<br /> with iid noise N_t.
</p>
<p>For both models the hypothesis test specified by the <code>test</code>
parameter is used to test whether the set S leads to an invariant
model. For futher details see the references.
</p>


<h3>Value</h3>

<p>list containing the following elements
</p>
<table summary="R valueblock">
<tr valign="top"><td><code>test.stat</code></td>
<td>
<p>value of the test statistic.</p>
</td></tr>
<tr valign="top"><td><code>crit.value</code></td>
<td>
<p>critical value computed using a Monte-Carlo
simulation of the null distribution.</p>
</td></tr>
<tr valign="top"><td><code>p.value</code></td>
<td>
<p>p-value.</p>
</td></tr>
<tr valign="top"><td><code>p</code></td>
<td>
<p>number of lags that were used.</p>
</td></tr>
<tr valign="top"><td><code>model.fit</code></td>
<td>
<p>'lm' object of linear model fit.</p>
</td></tr>
</table>


<h3>Author(s)</h3>

<p>Niklas Pfister and Jonas Peters
</p>


<h3>References</h3>

<p>Pfister, N., P. BÃ¼hlmann and J. Peters (2017).
Invariant Causal Prediction for Sequential Data. ArXiv e-prints (1706.08058).
</p>
<p>Peters, J., P. BÃ¼hlmann, and N. Meinshausen (2016).
Causal inference using invariant prediction: identification and confidence intervals.
Journal of the Royal Statistical Society, Series B (with discussion) 78 (5), 947â€“1012.
</p>


<h3>See Also</h3>

<p>To estimate the set of causal parents use the function
<code>seqICP</code>. For non-linear models use the
corresponding functions <code>seqICPnl</code> and
<code>seqICPnl.s</code>.
</p>


<h3>Examples</h3>

<pre>
set.seed(1)

# environment 1
na &lt;- 130
X1a &lt;- rnorm(na,0,0.1)
Ya &lt;- 5*X1a+rnorm(na,0,0.5)
X2a &lt;- Ya+rnorm(na,0,0.1)

# environment 2
nb &lt;- 70
X1b &lt;- rnorm(nb,-1,1)
Yb &lt;- 5*X1b+rnorm(nb,0,0.5)
X2b &lt;- rnorm(nb,0,0.1)

# combine environments
X1 &lt;- c(X1a,X1b)
X2 &lt;- c(X2a,X2b)
Y &lt;- c(Ya,Yb)
Xmatrix &lt;- cbind(X1, X2)

# apply seqICP.s to all possible sets - only the true parent set S=1
# is invariant in this example
seqICP.s(Xmatrix, Y, S=numeric(), par.test=list(grid=c(0,50,100,150,200)))
seqICP.s(Xmatrix, Y, S=1, par.test=list(grid=c(0,50,100,150,200)))
seqICP.s(Xmatrix, Y, S=2, par.test=list(grid=c(0,50,100,150,200)))
seqICP.s(Xmatrix, Y, S=c(1,2), par.test=list(grid=c(0,50,100,150,200)))
</pre>


</body></html>
