Learn R Programming

statmod (version 1.4.33)

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)

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?

Value

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

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, and 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. http://www.statsci.org/smyth/pubs/PermPValuesPreprint.pdf

Examples

Run this code
# NOT RUN {
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