Learn R Programming

emon (version 1.3)

permute.groups: Does randomisation test for the difference in means of two vectors v1 and v2.

Description

Does randomisation test for the difference in means mu1, mu2 of two vectors v1 and v2. Can do one or two sided tests.

Usage

permute.groups(v1, v2, alternative, nreps)

Arguments

v1
Data vector for variable 1
v2
Data vector for variable 2
alternative
A character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" (mu1>mu2) or "less". You can specify just the initial letter.
nreps
Number of replications used in the randomisation and generation of the p-value. Default is nreps=999

Value

$p.value

Details

Under the null hypothesis that mu1=mu2, the labelling of the n1+n2 observations is unimportant. Therefore, we can generate the null distribution for the test statistic m1-m2 or |m1-m2| depending on whether a one or two sided test is required) by randomly permuting the treatment labels nreps times and calculating the test statistic each time. The p-value is calculated as suggested by Manly (2006).

References

Manly BFJ (2006) Randomization, Bootstrap And Monte Carlo Methods in Biology: 3rd edition. Chapman and Hall.

See Also

power.groups, permute.BACI

Examples

Run this code
set.seed(5)
v1 = rnorm(27,10,2); v2=rnorm(25,11,2)
permute.groups(v1, v2, alternative="two")
permute.groups(v1, v2, alt="l")

Run the code above in your browser using DataLab