Description Usage Arguments Value Examples
View source: R/ResidualPredictionTest.R
Tests the null hypothesis that Y and E are independent given X.
1 2 3 4 5 6 7 8 | ResidualPredictionTest(Y, E, X, alpha = 0.05, verbose = FALSE,
degree = 4, basis = c("nystrom", "nystrom_poly", "fourier",
"polynomial", "provided")[1], resid_type = "OLS", XBasis = NULL,
noiseMat = NULL, getnoiseFct = function(n, ...) { rnorm(n) },
argsGetNoiseFct = NULL, nSim = 100, funcOfRes = function(x) {
abs(x) }, useX = TRUE, returnXBasis = FALSE,
nSub = ceiling(NROW(X)/4), ntree = 100, nodesize = 5,
maxnodes = NULL)
|
Y |
An n-dimensional vector. |
E |
An n-dimensional vector or an nxq dimensional matrix or dataframe. |
X |
A matrix or dataframe with n rows and p columns. |
alpha |
Significance level. Defaults to 0.05. |
verbose |
If |
degree |
Degree of polynomial to use if |
basis |
Can be one of |
resid_type |
Can be |
XBasis |
Basis if |
noiseMat |
Matrix with simulated noise. Defaults to NULL in which case the simulation is performed inside the function. |
getnoiseFct |
Function to use to generate the noise matrix. Defaults to |
argsGetNoiseFct |
Arguments for |
nSim |
Number of simulations to use. Defaults to 100. |
funcOfRes |
Function of residuals to use in addition to predicting the
conditional mean. Defaults to |
useX |
Set to |
returnXBasis |
Set to |
nSub |
Number of random features to use if |
ntree |
Random forest parameter: Number of trees to grow. Defaults to 500. |
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. |
A list with the following entries:
pvalue
The p-value for the null hypothesis that Y and E are independent given X.
XBasis
Basis expansion if returnXBasis
was set to TRUE
.
fctBasisExpansion
Function used to create basis expansion if basis is not "provided"
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # Example 1
n <- 100
E <- rbinom(n, size = 1, prob = 0.2)
X <- 4 + 2 * E + rnorm(n)
Y <- 3 * (X)^2 + rnorm(n)
ResidualPredictionTest(Y, as.factor(E), X)
# Example 2
E <- rbinom(n, size = 1, prob = 0.2)
X <- 4 + 2 * E + rnorm(n)
Y <- 3 * E + rnorm(n)
ResidualPredictionTest(Y, as.factor(E), X)
# not run:
# # Example 3
# E <- rnorm(n)
# X <- 4 + 2 * E + rnorm(n)
# Y <- 3 * (X)^2 + rnorm(n)
# ResidualPredictionTest(Y, E, X)
# ResidualPredictionTest(Y, X, E)
|
$pvalue
[1] 0.16
$XBasis
NULL
$fctBasisExpansion
function (x0)
kernelMatrix(rbfdot(s), x0, w)
<environment: 0x6fa2d40>
$pvalue
[1] 0.02
$XBasis
NULL
$fctBasisExpansion
function (x0)
kernelMatrix(rbfdot(s), x0, w)
<bytecode: 0x9315d60>
<environment: 0x448b1b8>
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.