Learn R Programming

lavaSearch2 (version 2.0.3)

calcType1postSelection: Compute the Type 1 Error After Selection [EXPERIMENTAL]

Description

Compute the type 1 error after selection [EXPERIMENTAL].

Usage

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

Value

[numeric] the type 1 error.

Arguments

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 "pmvnorm" (normal distribution) or "pvmt" (Student's t distribution)

df

[integer > 0] the degree of freedom of the joint Student's t distribution. Only used when distribution="pvmt".

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

Author

Brice Ozenne

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 before and after selection (in that order).

Examples

Run this code
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
if (FALSE) {
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)
}

#### 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
if (FALSE) {
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)
}

Run the code above in your browser using DataLab