Learn R Programming

statmod (version 1.5.0)

permp: Exact permutation p-values

Description

Calculates exact p-values for permutation tests when permutations are randomly drawn with replacement.

Usage

permp(x, nperm, n1, n2, total.nperm=NULL, method="auto", twosided=TRUE)

Value

vector or array of p-values, of same dimensions as x

Arguments

x

number of permutations that yielded test statistics at least as extreme as the observed data. May be a vector or an array of values.

nperm

total number of permutations performed.

n1

sample size of group 1. Not required if total.nperm is supplied.

n2

sample size of group 2. Not required if total.nperm is supplied.

total.nperm

total number of permutations allowable from the design of the experiment.

method

character string indicating computation method. Possible values are "exact", "approximate" or "auto".

twosided

logical, is the test two-sided and symmetric between the two groups?

Author

Belinda Phipson and Gordon Smyth

Details

This function can be used for calculating exact p-values for permutation tests where permutations are sampled with replacement, using theory and methods developed by Phipson and Smyth (2010). The input values are the total number of permutations done (nperm) and the number of these that were considered at least as extreme as the observed data (x).

total.nperm is the total number of distinct values of the test statistic that are possible. This is generally equal to the number of possible permutations, unless a two-sided test is conducted with equal sample sizes, in which case total.nperm is half the number of permutations, because the test statistic must then be symmetric in the two groups. Usually total.nperm is computed automatically from n1 and n2, but can also be supplied directly by the user.

When method="exact", the p-values are computed to full machine precision by summing a series terms. When method="approximate", an approximation is used that is faster and uses less memory. If method="auto", the exact calculation is used when total.nperm is less than or equal to 10,000 and the approximation is used otherwise.

References

Phipson B, Smyth GK (2010). Permutation P-values should never be zero: calculating exact P-values when permutations are randomly drawn. Statistical Applications in Genetics and Molecular Biology, Volume 9, Issue 1, Article 39. tools:::Rd_expr_doi("10.2202/1544-6115.1585"), tools:::Rd_expr_doi("10.48550/arXiv.1603.05766").

Examples

Run this code
x <- 0:5
# Both calls give same results
permp(x=x, nperm=99, n1=6, n2=6)
permp(x=x, nperm=99, total.nperm=462)

Run the code above in your browser using DataLab