perm.test {exactRankTests}R Documentation

One and Two Sample Permutation Test

Description

Performs the permutation test for the one and two sample problem.

Usage

## Default S3 method:
perm.test(x, y, paired=FALSE, alternative=c("two.sided", "less", "greater"),
          mu=0, exact=NULL, conf.int=FALSE, conf.level=0.95, tol=NULL, ...)
## S3 method for class 'formula'
perm.test(formula, data, subset, na.action, ...)

Arguments

x

numeric vector of integer data values.

y

numeric vector of integer data values.

paired

a logical indicating whether you want a paired test.

alternative

the alternative hypothesis must be one of "two.sided" (default), "greater" or "less". You can specify just the initial letter.

mu

a number specifying an optional location parameter.

exact

a logical indicating whether an exact p-value should be computed.

conf.int

a logical indicating whether a confidence interval should be computed.

conf.level

confidence level of the interval.

tol

real. real valued scores are mapped into integers by multiplication. Make sure that the absolute difference between the "true" quantile and the approximated quantile is less than tol. This might not be possible due to memory/time limitations. See pperm.

formula

a formula of the form lhs ~ rhs where lhs is a numeric variable giving the data values and rhs a factor with two levels giving the corresponding groups.

data

an optional data frame containing the variables in the model formula.

subset

an optional vector specifying a subset of observations to be used.

na.action

a function which indicates what should happen when the data contain NAs. Defaults to getOption("na.action").

...

further arguments to be passed to or from methods.

Details

The permutation test is performed for integer valued observations or scores. If real values x or y are passed to this function the following applies: if exact is true (i.e. the sample size is less than 50 observations) and tol is not given, the scores are mapped into \{1,…,N\}, see pperm for the details. Otherwise the p-values are computed using tol. If the sample size exceeds $50$ observations, the usual normal approximation is used.

P-values are computed according to the StatXact-manual, see pperm.

For (in principle) continuous variables the confidence sets represent the "largest shift in location being consistent with the observations". For discrete variables with only a few categories they are hard to interpret. In the case of binary data (e.g. success / failure) the confidence sets can be interpreted as the differences of two success-rates covered by the data. For a detailed description see R\"ohmel (1996).

Confidence intervals are only available for independent samples. When the sample sizes are unbalanced, length(x) needs to be smaller than length(y).

Value

A list with class "htest" containing the following components:

statistic

the value of the test statistic with a name describing it.

p.value

the p-value for the test.

pointprob

this gives the probability of observing the test statistic itself.

null.value

the location parameter mu.

alternative

a character string describing the alternative hypothesis.

method

the type of test applied.

data.name

a character string giving the names of the data.

conf.int

a confidence interval for the location parameter. (Only present if argument conf.int = TRUE.)

Note

Confidence intervals may need some cpu-time ...

Author(s)

Torsten Hothorn <Torsten.Hothorn@rzmail.uni-erlangen.de>

References

Joachim R\"ohmel (1996), Precision intervals for estimates of the difference in success rates for binary random variables based on the permutation principle. Biometrical Journal, 38(8), 977–993.

Cyrus R. Mehta & Nitin R. Patel (2001), StatXact-5 for Windows. Manual, Cytel Software Cooperation, Cambridge, USA

Examples


# Example from Gardner & Altman (1989), p. 30
# two treatments A and B, 1 means improvement, 0 means no improvement
# confidence sets cf. R\"ohmel (1996)

A <- c(rep(1, 61), rep(0, 19))
B <- c(rep(1, 45), rep(0, 35))
perm.test(A, B, conf.int=TRUE, exact=TRUE)

# one-sample AIDS data (differences only), Methta and Patel (2001),
# Table 8.1 page 181

data(sal)
attach(sal)
ppdiff <- pre - post
detach(sal)

# p-values in StatXact == 0.0011 one-sided, 0.0021 two.sided, page 183

perm.test(ppdiff)
perm.test(ppdiff, alternative="less")
perm.test(ppdiff, exact=FALSE)


[Package exactRankTests version 0.8-30 Index]