expect_mc_test: Test if p-values are coming from the null using a sequential...

Description Usage Arguments Value Examples

View source: R/expect_mc.R

Description

Requires as input a generic test that for a given sample size provides a vector of p-values. Aims to reject if these are not from the null. Guarantees a bound on the type I error rate.

Usage

1
expect_mc_test(object, control = NULL, npval = 1)

Arguments

object

A function taking one argument n - that generates p-values based on a sample size n.

control

a list controlling the algorithm

  • n number of samples to be taken in the first step. Default: 1e3

  • maxseqsteps: Number of sequential attempts to use. Default: 7.

  • incn: Factor by which to multiply n from the second sequential attempt onward. Default: 4.

  • level: bound on the type I error, ie the probability of wrongly rejecting a sampler with the correct distribution. Default: 1e-5.

  • debug: If positive then debug information will be printed via 'message()'. Default: 0.

npval

number of p-values returned by the test. A Bonferroni correction is applied if >1. Default: 1.

Value

The first argument, invisibly, to allow chaining of expectations.

Examples

1
2
3
4
5
6
pvalsampler <- function(n){
      x <- sample.int(11,size=n,replace=TRUE)-1;
     chisq.test(tabulate(x+1,nbins=11),
                p=rep(1/11,11))$p.value
}
expect_mc_test(pvalsampler)

mcunit documentation built on April 2, 2021, 5:06 p.m.