jmuOutlier (version 2.2)

perm.test: Permutation Test

Description

Performs one-sample and two-sample permutation tests on vectors of data.

Usage

perm.test(x, y = NULL, alternative = c("two.sided", "less", "greater"), mu = 0, 
      paired = FALSE, all.perms = TRUE, num.sim = 20000, plot = FALSE, stat = mean, ...)

Arguments

x

A (non-empty) numeric vector of data values.

y

An optional numeric vector data values.

alternative

A character string specifying the alternative hypothesis, and must be one of "two.sided" (default), "greater" or "less". Only the initial letter needs to be specified.

mu

A number indicating the null value of the location parameter (or the difference in location parameters if performing a two-sample test).

paired

Logical, indicating whether or not a two-sample test should be paired, and is ignored for a one-sample test.

all.perms

Logical. The exact p-value is attempted when all.perms (i.e., all permutations) is TRUE (default), and is simulated when all.perms is FALSE or when computing an exact p-value requires more than num.sim calculations.

num.sim

The upper limit on the number of permutations generated.

plot

Logical. If TRUE, then plot the histogram of the permutation distribution; otherwise, list the p-value.

stat

Function, naming the test statistic, such as mean and median.

Optional arguments to stat; and is the second argument to stat when unspecified. For example, if stat equals mean, then the second argument trim denotes the fraction (0 to 0.5) of observations to be trimmed from each end of x and y before the mean is computed.

Value

alternative

Same as the input.

mu

Same as the input.

p.value

The p-value of the permutation test.

Details

A paired test using data x and nonNULL y is equivalent to a one-sample test using data x-y. The output states more details about the permutation test, such as one-sample or two-sample, and whether or not the p.value calculated was based on all permutations.

References

Higgins, J. J. (2004) Introduction to Modern Nonparametric Statistics.

Examples

Run this code
# NOT RUN {
# One-sample test

print( x <- rnorm(10,0.5) ) 

perm.test( x, stat=median )

# Two-sample unpaired test

print( y <- rnorm(13,1) )

perm.test( x, y )
# }

Run the code above in your browser using DataLab