gcm {comets}R Documentation

Generalised covariance measure test

Description

Generalised covariance measure test

Usage

gcm(
  Y,
  X,
  Z,
  alternative = c("two.sided", "less", "greater"),
  reg_YonZ = "rf",
  reg_XonZ = "rf",
  args_XonZ = NULL,
  type = c("quadratic", "max"),
  B = 499L,
  coin = FALSE,
  cointrol = list(distribution = "asymptotic"),
  ...
)

Arguments

Y

Vector or matrix of response values.

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 "two.sided" (default), "greater" or "less". Only applies if type = "quadratic" and Y and X are one-dimensional.

reg_YonZ

Character string or function specifying the regression for Y on Z. See ?regressions for more detail.

reg_XonZ

Character string or function specifying the regression for X on Z. See ?regressions for more detail.

args_XonZ

Additional arguments passed to reg_XonZ.

type

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.

B

Number of bootstrap samples. Only applies if type = "max" is used.

coin

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 FALSE.

cointrol

List; further arguments passed to independence_test.

...

Additional arguments passed to reg_YonZ.

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 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.

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

n <- 150
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))


[Package comets version 0.0-2 Index]