gcm {comets} | R Documentation |
Generalised covariance measure test using random forests
Description
Generalised covariance measure test using random forests
Usage
gcm(
Y,
X,
Z,
alternative = c("two.sided", "less", "greater"),
reg_YonZ = "rf",
reg_XonZ = "rf",
args_XonZ = NULL,
...
)
Arguments
Y |
Vector of response values. Can be supplied as a numeric vector or a single column matrix. |
X |
Matrix or data.frame of covariates. |
Z |
Matrix or data.frame of covariates. |
alternative |
A character string specifying the alternative hypothesis,
must be one of |
reg_YonZ |
Character string or function specifying the regression for Y on Z. |
reg_XonZ |
Character string or function specifying the regression for X on Z. |
args_XonZ |
Additional arguments passed to |
... |
Additional arguments passed to |
Details
The generalised covariance measure test tests whether the conditional covariance of Y and X given Z is zero.
Value
Object of class 'gcm
' and 'htest
' with the following
components:
statistic |
The value of the test statistic. |
p.value |
The p-value for the |
parameter |
In case X is multidimensional, this is the degrees of freedom used for the chi-squared test. |
hypothesis |
String specifying the null hypothesis . |
null.value |
String specifying the null hypothesis. |
method |
The string |
data.name |
A character string giving the name(s) of the data. |
rY |
Residuals for the Y on Z regression. |
rX |
Residuals for the X on Z regression. |
References
Rajen D. Shah, Jonas Peters "The hardness of conditional independence testing and the generalised covariance measure," The Annals of Statistics, 48(3), 1514-1538. doi: 10.1214/19-aos1857
Examples
X <- matrix(rnorm(3e2), ncol = 2)
colnames(X) <- c("X1", "X2")
Z <- matrix(rnorm(3e2), ncol = 2)
colnames(Z) <- c("Z1", "Z2")
Y <- rnorm(150) # X[, 2] + Z[, 2] + rnorm(150)
(gcm1 <- gcm(Y, X, Z))