InvariantResidualDistributionTest {CondIndTests}R Documentation

Invariant residual distribution test.

Description

Tests the null hypothesis that Y and E are independent given X.

Usage

InvariantResidualDistributionTest(Y, E, X, alpha = 0.05,
  verbose = FALSE, fitWithGam = TRUE,
  test = leveneAndWilcoxResidualDistributions, colNameNoSmooth = NULL,
  mtry = sqrt(NCOL(X)), ntree = 100, nodesize = 5, maxnodes = NULL,
  returnModel = FALSE)

Arguments

Y

An n-dimensional vector.

E

An n-dimensional vector. E needs to be a factor.

X

A matrix or dataframe with n rows and p columns.

alpha

Significance level. Defaults to 0.05.

verbose

If TRUE, intermediate output is provided. Defaults to FALSE.

fitWithGam

If TRUE, a GAM is used for the nonlinear regression, else a random forest is used. Defaults to TRUE.

test

Unconditional independence test that tests whether residual distribution is invariant across different levels of E. Defaults to leveneAndWilcoxResidDistributions.

colNameNoSmooth

Gam parameter: Name of variables that should enter linearly into the model. Defaults to NULL.

mtry

Random forest parameter: Number of variables randomly sampled as candidates at each split. Defaults to sqrt(NCOL(X)).

ntree

Random forest parameter: Number of trees to grow. Defaults to 100.

nodesize

Random forest parameter: Minimum size of terminal nodes. Defaults to 5.

maxnodes

Random forest parameter: Maximum number of terminal nodes trees in the forest can have. Defaults to NULL.

returnModel

If TRUE, the fitted quantile regression forest model will be returned. Defaults to FALSE.

Value

A list with the following entries:

Examples


# Example 1
n <- 1000
E <- rbinom(n, size = 1, prob = 0.2)
X <- 4 + 2 * E + rnorm(n)
Y <- 3 * (X)^2 + rnorm(n)
InvariantResidualDistributionTest(Y, as.factor(E), X)
InvariantResidualDistributionTest(Y, as.factor(E), X, test = ksResidualDistributions)

# Example 2
E <- rbinom(n, size = 1, prob = 0.2)
X <- 4 + 2 * E + rnorm(n)
Y <- 3 * E + rnorm(n)
InvariantResidualDistributionTest(Y, as.factor(E), X)
InvariantResidualDistributionTest(Y, as.factor(E), X, test = ksResidualDistributions)

[Package CondIndTests version 0.1.5 Index]