Learn R Programming

BHH2 (version 2016.05.31)

permtest: Permutation test: randomization test for small size samples

Description

Permutation test for means and variance comparisons.

Usage

permtest(x, y = NULL)

Arguments

x
numeric vector. Sample group X.
y
numeric vector. Sample group Y.

Value

The function returns the number $N$ of different samples generated for the permutation distribution, the observed t-statistic, its p-value, based on both, the parametric and permutation distributions as well as the observed F-ratio and its corresponding p-values. The test may take a long time to generate all the possible combinations. It has been tested for $n + m = 22$ and $n < 12$.

WARNING

The test may take a long time to generate all the possible combinations.

Details

In the one--sample problem, the function builds all $2^n$ possible $+/- x_i$ combinations. For the two--sample problem, all possible $B(n+m,n)$ samples size $n$ (=length(x)) and $m$ (=length(y)) are generated and the permutation distributions for the t-statistics and F-ratios. p-values are computed based on these distributions.

References

Box G. E. P, Hunter, J. S. and Hunter, W. C. (2005). Statistics for Experimenters II. New York: Wiley.

See Also

onet.permutation and towt.permutation of DAAG package, and perm.test of the exactRankTests.

Examples

Run this code
library(BHH2)

# Permutation test for Tomato Data
data(tomato.data)
cat("Tomato Data (not paired):\n")
attach(tomato.data)
a <- pounds[fertilizer=="A"]
b <- pounds[fertilizer=="B"]
print(round(test <- permtest(b,a),3))
detach()

# Permutation test for Boy's Shoes Example
data(shoes.data)
cat("Shoes Data (paired):\n")
attach(shoes.data)
x <- matB-matA
print(round(test <- permtest(x),3))
detach()

Run the code above in your browser using DataLab