Learn R Programming

lavaSearch2 (version 1.0.0)

calcType1postSelection: Compute the Type 1 Error After Selection

Description

Compute the type 1 error after selection.

Usage

calcType1postSelection(level, mu, Sigma, quantile.previous, distribution, df,
  n = 10, correct = TRUE, ...)

Arguments

level

expected coverage.

mu

vector of means for the joint distribution of the test statistics

Sigma

variance-covariance matrix for the joint distribution of the test statistics.

quantile.previous

significance quantile used at the previous step.

distribution

distribution of the test statistics. Can be "pmvnorm" (normal distribution) or "pvmt" (student's t distribution)

df

degree of freedoms (only used for the student distribution).

n

number of points for the numerical integration

correct

logical. If true, returns the corrected level that should be used to obtain the expected coverage.

...

arguments passed to lower level functions

Value

type 1 error (numeric)

Details

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 after and before selection.

Examples

Run this code
# NOT RUN {
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)
# }
# 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)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab