View source: R/calcType1postSelection.R
calcType1postSelection | R Documentation |
Compute the type 1 error after selection [EXPERIMENTAL].
calcType1postSelection(
level,
mu,
Sigma,
quantile.previous,
distribution,
df,
n = 10,
correct = TRUE,
...
)
level |
[numeric 0-1] expected coverage. |
mu |
[numeric vector] the expectation of the joint distribution of the test statistics |
Sigma |
[matrix] the variance-covariance of the joint distribution of the test statistics. |
quantile.previous |
[numeric] significance quantile used at the previous step. |
distribution |
[character] distribution of the test statistics.
Can be |
df |
[integer > 0] the degree of freedom of the joint Student's t distribution.
Only used when |
n |
[integer > 0] number of points for the numerical integration |
correct |
[logical] if true, correct the level to account for previous testings. |
... |
arguments passed to |
The number of tests at the current step (i.e. after selection) is assumed to be one less than the number of tests at the previous step (i.e. before selection).
Arguments mu
and Sigma
must contain the moments for the vector of test statistics
before and after selection (in that order).
[numeric] the type 1 error.
Brice Ozenne
library(mvtnorm)
n <- 350
#### only 2 tests
Sigma <- rbind(c(1,0,0),c(0,1,1),c(0,1,1))
z2 <- qmvnorm(0.95, mean = rep(0,2), sigma = Sigma[1:2,1:2], tail = "both.tails")$quantile
## no selection since strong effect
mu <- c(10,0,0)
calcType1postSelection(0.95, quantile.previous = z2, distribution = "gaussian",
mu = mu, Sigma = Sigma, correct = TRUE)
## strong selection
## Not run:
mu <- c(0,0,0)
levelC <- calcType1postSelection(0.95, quantile.previous = z2, distribution = "gaussian",
mu = mu, Sigma = Sigma)
print(levelC) # more liberal than without selection
calcType1postSelection(levelC, quantile.previous = z2, distribution = "gaussian",
mu = mu, Sigma = Sigma, correct = FALSE)
## End(Not run)
#### 3 tests
Sigma <- diag(1,5,5)
Sigma[4,2] <- 1
Sigma[2,4] <- 1
Sigma[5,3] <- 1
Sigma[3,5] <- 1
z2 <- qmvnorm(0.95, mean = mu[1:3], sigma = Sigma[1:3,1:3], tails = "both.tails")$quantile
## no selection since strong effect
## Not run:
mu <- c(10,0,0,0,0)
calcType1postSelection(0.95, quantile.previous = z2, distribution = "gaussian",
mu = mu, Sigma = Sigma, correct = TRUE)
## strong selection
mu <- c(0,0,0,0,0)
levelC <- calcType1postSelection(0.95, quantile.previous = z2,
mu = mu, Sigma = Sigma, distribution = "gaussian")
calcType1postSelection(levelC, quantile.previous = z2, distribution = "gaussian",
mu = mu, Sigma = Sigma, correct = FALSE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.