boot2pvalue: Compute the p.value from the distribution under H1

Description Usage Arguments Details Examples

Description

Compute the p.value associated with the estimated statistic using a bootstrap sample of its distribution under H1.

Usage

1
2
boot2pvalue(x, null, estimate = NULL, alternative = "two.sided",
  FUN.ci = quantileCI, tol = .Machine$double.eps^0.5)

Arguments

x

[numeric vector] a vector of bootstrap estimates of the statistic.

null

[numeric] value of the statistic under the null hypothesis.

estimate

[numeric] the estimated statistic.

alternative

[character] a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less".

FUN.ci

[function] the function used to compute the confidence interval. Must take x, alternative, conf.level and sign.estimate as arguments and only return the relevant limit (either upper or lower) of the confidence interval.

tol

[numeric] the absolute convergence tolerance.

Details

For test statistic close to 0, this function returns 1.

For positive test statistic, this function search the quantile alpha such that:

If the argument alternative is set to "less", it returns 1.

For negative test statistic, this function search the quantile alpha such that:

If the argument alternative is set to "greater", it returns 1.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
set.seed(10)

#### no effect ####
x <- rnorm(1e3) 
boot2pvalue(x, null = 0, estimate = mean(x), alternative = "two.sided")
## expected value of 1
boot2pvalue(x, null = 0, estimate = mean(x), alternative = "greater")
## expected value of 0.5
boot2pvalue(x, null = 0, estimate = mean(x), alternative = "less")
## expected value of 0.5

#### positive effect ####
x <- rnorm(1e3, mean = 1) 
boot2pvalue(x, null = 0, estimate = 1, alternative = "two.sided")
## expected value of 0.32 = 2*pnorm(q = 0, mean = -1) = 2*mean(x<=0)
boot2pvalue(x, null = 0, estimate = 1, alternative = "greater")  
## expected value of 0.16 = pnorm(q = 0, mean = 1) = mean(x<=0)
boot2pvalue(x, null = 0, estimate = 1, alternative = "less")
## expected value of 0.84 = 1-pnorm(q = 0, mean = 1) = mean(x>=0)

#### negative effect ####
x <- rnorm(1e3, mean = -1) 
boot2pvalue(x, null = 0, estimate = -1, alternative = "two.sided") 
## expected value of 0.32 = 2*(1-pnorm(q = 0, mean = -1)) = 2*mean(x>=0)
boot2pvalue(x, null = 0, estimate = -1, alternative = "greater")
## expected value of 0.84 = pnorm(q = 0, mean = -1) = mean(x<=0)
boot2pvalue(x, null = 0, estimate = -1, alternative = "less") # pnorm(q = 0, mean = -1)
## expected value of 0.16 = 1-pnorm(q = 0, mean = -1) = mean(x>=0)

bozenne/riskRegressionLight documentation built on May 7, 2019, 12:52 a.m.