mcp: Function mcp in package 'simctest'

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/mcp.R

Description

An algorithm for the computation of the power of Monte Carlo tests with guaranteed precision

Usage

1
2
mcp(genstream,alpha=0.05,delta="adaptive",
cp=0.99,maxeffort=Inf,options = list())

Arguments

genstream

a function that returns a function that returns a random Bernoulli variable (each stream corresponds to a dataset. 0 = (T<t), 1= (T>=t) where t is computed from the dataset and T is a resampled test-statistic from that dataset.)

alpha

the level of the test.

delta

the desired length of confidence interval, or "adaptive" if using adaptive delta. See details.

maxeffort

maximum effort. Effort is total number of samples taken. Set to finite value if needed (the resulting confidence interval still has the guaranteed coverage probability, but may not be as ‘short’ as desired). Can also interrupt the algorithm during main loop and get a result of class "mcpres".

cp

the desired coverage probability.

options

Additional options. See details

Details

options$maxeffort: set to maximum allowable effort.

options$reports: set to FALSE if onscreen reports are not wanted.

options$file: optional file-name to save results to.

options$pilotn: number of streams in pilot (1000 by default).

options$pilotmaxsteps: maxsteps in pilot (1000 by default).

options$gammapilotprop: proportion of error spent on pilot CI (0.1 by default)

options$gammatestprop: proportion of error spent on testing remaining paths (default is 0.1)

options$spendgammatest: spending sequence for the testing procedure on the remaining streams. Must be a non-negative function of integers with positive limit 1 (t/(20+t) by default).

options$eta: internal parameter to the testing procedure on the remaining streams (0.05 by default).

options$maxstepsbase: initial maximum number of steps (500 by default)

options$maxstepsinc: multiplier for the maximum number of steps thereafter (1.5 by default).

options$maxbatch: multiplier for the maximum number of steps thereafter (200000 by default).

options$deltamid: adaptive delta function. Describes the length of the confidence interval desired depending on the midpoint of the interval. By default the function requires 0.02 for intervals containing 0.05 or lower or 0.95 or higher, and 0.1 otherwise. If using non-default adaptive delta must also specify epsilon (below).

options$epsilon: error probability for each stream. Only set if using non-standard adaptive delta.

Value

An object of class "mcpres" with slots:

int

confidence interval for power.

cp

coverage probability.

beta

Estimate of power.

N

the number of streams started in main loop (or in pilot if stopped after pilot).

effort

total number of samples generated.

rescount

number of positive and negative outcomes.

truncated

boolean indicating whether procedure was truncated by user-specified maxeffort.

taccepted

boolean indicating whether the procedure stopped as a result of a hypothesis test or brute force (the confidence interval coverage probability is guaranteed in either case.)

Author(s)

Axel Gandy and Patrick Rubin-Delanchy

References

Gandy, A. and Rubin-Delanchy, P. An algorithm to compute the power of Monte Carlo tests with guaranteed precision. arXiv:1110.1248v1

See Also

mkdeltamid

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
#The following example takes a bit of computing time
## Not run: 
#Example where we know the power should be the level of the test
genstream <- function(){p <- runif(1); function(N){runif(N) <= p}}

res <- mcp(genstream, alpha=0.05, delta="adaptive", cp=0.99)

#should find confidence interval of length 0.02 centered around 0.05
res

## End(Not run)

simctest documentation built on May 30, 2017, 2:53 a.m.