pcm: Projected covariance measure test for conditional mean...

View source: R/pcm.R

pcmR Documentation

Projected covariance measure test for conditional mean independence

Description

Projected covariance measure test for conditional mean independence

Usage

pcm(
  Y,
  X,
  Z,
  rep = 1,
  est_vhat = TRUE,
  reg_YonXZ = "rf",
  reg_YonZ = "rf",
  reg_YhatonZ = "rf",
  reg_VonXZ = "rf",
  reg_RonZ = "rf",
  args_YonXZ = NULL,
  args_YonZ = NULL,
  args_YhatonZ = NULL,
  args_VonXZ = NULL,
  args_RonZ = NULL,
  frac = 0.5,
  indices = NULL,
  coin = FALSE,
  cointrol = NULL,
  return_fitted_models = FALSE,
  ...
)

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.

rep

Number of repetitions with which to repeat the PCM test

est_vhat

Logical; whether to estimate the variance functional

reg_YonXZ

Character string or function specifying the regression for Y on X and Z, default is "rf" for random forest. See ?regressions for more detail.

reg_YonZ

Character string or function specifying the regression for Y on Z, default is "rf" for random forest. See ?regressions for more detail.

reg_YhatonZ

Character string or function specifying the regression for the predicted values of reg_YonXZ on Z, default is "rf" for random forest. See ?regressions for more detail.

reg_VonXZ

Character string or function specifying the regression for estimating the conditional variance of Y given X and Z, default is "rf" for random forest. See ?regressions for more detail.

reg_RonZ

Character string or function specifying the regression for the estimated transformation of Y, X, and Z on Z, default is "rf" for random forest. See ?regressions for more detail.

args_YonXZ

A list of named arguments passed to reg_YonXZ.

args_YonZ

A list of named arguments passed to reg_YonZ.

args_YhatonZ

A list of named arguments passed to reg_YhatonZ.

args_VonXZ

A list of named arguments passed to reg_VonXZ.

args_RonZ

A list of named arguments passed to reg_RonZ.

frac

Relative size of train split.

indices

A numeric vector of indices specifying the observations used for estimating the estimating the direction (the other observations will be used for computing the final test statistic). Default is NULL and the indices will be generated randomly using frac. When using rep larger than 1, a list (of length rep) of indices can be supplied.

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

cointrol

List; further arguments passed to independence_test.

return_fitted_models

Logical; whether to return the fitted regressions (default is FALSE).

...

Additional arguments currently ignored.

Details

The projected covariance measure test tests whether the conditional mean of Y given X and Z is independent of X.

Value

Object of class 'pcm' 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

Null hypothesis of conditional mean independence.

null.value

Null hypothesis of conditional mean independence.

method

The string "Projected covariance measure test".

data.name

A character string giving the name(s) of the data.

check.data

A data.frame containing the residuals for plotting.

models

List of fitted regressions if return_fitted_models is TRUE.

References

Lundborg, A. R., Kim, I., Shah, R. D., & Samworth, R. J. (2022). The Projected Covariance Measure for assumption-lean variable significance testing. arXiv preprint. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.48550/arXiv.2211.02039")}

Examples

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)
(pcm1 <- pcm(Y, X, Z))


comets documentation built on April 4, 2025, 1:24 a.m.

Related to pcm in comets...