MChtest-package: Monte Carlo hypothesis tests allowing sequential stopping

Description Details Author(s) References See Also Examples

Description

Performs Monte Carlo hypothesis tests. It allows a couple of different sequential stopping boundaries (a truncated sequential probability ratio test boundary and a boundary proposed by Besag and Clifford, 1991). Gives valid p-values and confidence intervals on p-values.

Details

Package: MChtest
Type: Package
Version: 1.0-3
Date: 2019-05-14
License: GPL

Use MCbound to create sequential stopping boundaries. These may take considerable set-up time, but once the stopping boundary is calculated then it can be used in MCtest to save time in computation of Monte Carlo hypothesis tests. The idea of the truncated sequential probability ratio test boundary is that it takes many resamples if the true p-value (i.e., the one from an infinite resample size) is close to the significance level (e.g., 0.05), but takes much fewer if the true p-value is far from the significance level.

Author(s)

Michael P. Fay

Maintainer: Michael P. Fay <mfay@niaid.nih.gov>

References

Besag, J. and Clifford, P. (1991). Sequential Monte Carlo p-values. Biometrika. 78: 301-304.

Fay, M.P., Kim, H-J. and Hachey, M. (2007). Using truncated sequential probability ratio test boundaries for Monte Carlo implementation of hypothesis tests. Journal of Computational and Graphical Statistics. 16(4):946-967.

See Also

Precalculated MCbound: MCbound.precalc1

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Create a stopping boundary
##### May take a long time if Nmax is large
B<-MCbound("tsprt",c(alpha0=.001,beta0=.01,Nmax=99,p0=.04,p1=.06))
## do Monte Carlo  test
x<-data.frame(y=1:100,z=rnorm(100),group=c(rep(1,50),rep(2,50)))
stat<-function(x){ cor(x[,1],x[,2]) }
### nonparametric bootstrap test on correlation between y and z
### low p-value means that such a large correlation unlikely due to chance
resamp<-function(x){ n<-dim(x)[[1]] ; x[sample(1:n,replace=TRUE),] }
MCtest(x,stat,resamp,bound=B) 
## Package comes with a large precalculated MC bound as the default
## the precalculated bound is good for testing at the 0.05 level
MCtest(x,stat,resamp)

Example output

MCtest using MCbound of
    type= tsprt with parms=

alpha0  beta0   Nmax     p0     p1 
 0.001  0.010 99.000  0.040  0.060 

p-value= 0.6666667
99 percent confidence interval (on p-value):
 0.1435687 0.9771157 
MCtest using MCbound of
    type= tsprt with parms=

          p0           p1       alpha0        beta0         Nmax 
6.144961e-02 4.000000e-02 1.000000e-04 1.000000e-04 9.999000e+03 

p-value= 0.5227259
99 percent confidence interval (on p-value):
 0.3241731 0.7086698 

MChtest documentation built on May 16, 2019, 5:06 p.m.