simctest {simctest}R Documentation

Sequential implementation of Monte Carlo tests

Description

Wrapper function for convenient use of the sequential implementation of the Monte Carlo test.

Usage

simctest(gensample, level=0.05, epsilon=1e-3, maxsteps=1e4)

Arguments

gensample function that performs one sampling step. Returns 0 (sampled test statistic does not exceed the observation) or 1 (sampled test static exceeds the observation).
level level passed to getalgonthefly
epsilon error bound epsilon passed to getalgonthefly
maxsteps maximal number of steps to take

Value

An object of class sampalgres.

Author(s)

Axel Gandy

References

Gandy, A. (2009) Sequential Implementation of Monte Carlo Tests with Uniformly Bounded Resampling Risk. To appear in JASA.

Examples

  #Example from Davison&Hinkley section 11.4, p. 534
  data(fir,package="boot")
  fir.mle <- c(sum(fir$count), nrow(fir))
  fir.gen <- function(data, mle){
    d<-data
    y <- sample(x=mle[2],size=mle[1],replace=TRUE)
    d$count <- tabulate(y,mle[2])
    d
  }
  fir.fun <- function(data)
    (nrow(data)-1)*var(data$count)/mean(data$count)
  obs<-fir.fun(fir)
  resampl<-function(){obs<fir.fun(fir.gen(data=fir,mle=fir.mle))}
  simctest(resampl)

  #now trying simctest.cont
  res <- simctest(resampl,maxsteps=10)
  res

  res <- cont(res,10)
  cont(res,10)


[Package simctest version 1.0-0 Index]