Generalised covariance measure test
gcm(
Y,
X,
Z,
alternative = c("two.sided", "less", "greater"),
reg_YonZ = "rf",
reg_XonZ = "rf",
args_YonZ = NULL,
args_XonZ = NULL,
type = c("quadratic", "max", "scalar"),
B = 499L,
coin = TRUE,
cointrol = list(distribution = "asymptotic"),
return_fitted_models = FALSE,
multivariate = c("none", "YonZ", "XonZ", "both"),
...
)
Object of class 'gcm
' and 'htest
' with the following
components:
statistic
The value of the test statistic.
p.value
The p-value for the hypothesis
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 "Generalised covariance measure test"
.
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.
models
List of fitted regressions if return_fitted_models
is TRUE
.
Vector or matrix of response values.
Matrix or data.frame of covariates.
Matrix or data.frame of covariates.
A character string specifying the alternative hypothesis,
must be one of "two.sided"
(default), "greater"
or
"less"
. Only applies if type = "quadratic"
and Y
and
X
are one-dimensional.
Character string or function specifying the regression for
Y on Z. See ?regressions
for more detail.
Character string or function specifying the regression for
X on Z. See ?regressions
for more detail.
A list of named arguments passed to reg_YonZ
.
A list of named arguments passed to reg_XonZ
.
Type of test statistic, either "quadratic"
(default) or
"max"
. If "max"
is specified, the p-value is computed
based on a bootstrap approximation of the null distribution with
B
samples.
Number of bootstrap samples. Only applies if type = "max"
is
used.
Logical; whether or not to use the coin
package for
computing the test statistic and p-value. The coin
package
computes variances with n - 1 degrees of freedom.
The default is TRUE
.
List; further arguments passed to
independence_test
.
Logical; whether to return the fitted regressions
(default is FALSE
).
Character; specifying which regression can handle
multivariate outcomes ("none"
, "YonZ"
, "XonZ"
, or
"both"
). If "none"
, then the regression is run using each
column in Y (or X) as the response.
Additional arguments passed to reg_YonZ
.
The generalised covariance measure test tests whether the conditional covariance of Y and X given Z is zero.
Rajen D. Shah, Jonas Peters "The hardness of conditional independence testing and the generalised covariance measure," The Annals of Statistics, 48(3), 1514-1538. tools:::Rd_expr_doi("10.1214/19-aos1857")
n <- 1e2
X <- matrix(rnorm(2 * n), ncol = 2)
colnames(X) <- c("X1", "X2")
Z <- matrix(rnorm(2 * n), ncol = 2)
colnames(Z) <- c("Z1", "Z2")
Y <- X[, 2]^2 + Z[, 2] + rnorm(n)
(gcm1 <- gcm(Y, X, Z))
Run the code above in your browser using DataLab