I'm not an expert, so forgive me if some of the terminology is a little clumsy. Happy to provide more information where required.
I have two vectors of 50 paired numeric values in R. I want to perform a two-tailed randomisation or permutation test to determine whether their differences are due to chance or not.
A permutation test (also called a randomization test, re-randomization test, or an exact test) is a type of statistical significance test in which the distribution of the test statistic under the null hypothesis is obtained by calculating all possible values of the test statistic under rearrangements of the labels on the observed data points.
I want to do this type of test because I believe the distributions of the values in the vectors violate the assumptions of other tests such as the t-test (for example, many of the numeric values in the vector are 0).
The permtest
function in the BHH2 library, almost does what I want, but it operates on all $2^{50}$ permutations, which will take too long. Instead, I want to estimate the p-value, by sampling a large number of the possible permutations. I had a look in the coin package, but nothing in there seems to do a permutation test with sampling from paired numeric vectors.
Some googling lead me to this email, which suggests that the reason I can't find a package to do it is that it's a one-liner in R. Unfortunately, I'm not experienced enough with R to be able to produce that one-liner.
Is there a package or method that will perform a two-tailed paired permutation test using only a sample of the permutation space?
If not, would somebody be able to share a short bit of R code to do it?
coin
(among several others) does randomization tests. e.g. see the answer to this question (read the whole thing). If I understand right, the examples cover both approximate and exact cases and cover both independent and dependent samples. $\endgroup$oneway_test(y ~ x | pairs, distribution=approximate(B=9999))
withlibrary(coin)
. $\endgroup$