non-parametric permutation and signed paired-difference distributions
On 10/14/2011 4:10 PM, Bert Gunter wrote:
If I understand what you want to do, it's simple. 2^15 is small (only about 33000), so you can generate all the possible means (sums, actually) and and find the population quantile for your result. If avals is the vector of 15 absolute values, the complete distribution is: allsums <- as.matrix(expand.grid(as.data.frame(matrix(rep(c(-1,1),15), nr =2)))) %*% avals This was instantaneous on my machine.
That's beautiful, Bert. Thanks! Here is my fleshed-out example
mean(ZeaMays$diff)
# complete permutation distribution of diff, for all 2^15 ways of assigning
# one value to cross and the other to self
allmeans <- as.matrix(expand.grid(as.data.frame(matrix(rep(c(-1,1),15),
nr =2)))) %*% abs(ZeaMays$diff) / 15
# upper-tail p-value
sum(allmeans > mean(ZeaMays$diff)) / 2^15
# two-tailed p-value
sum(abs(allmeans) > mean(ZeaMays$diff)) / 2^15
hist(allmeans, breaks=64, xlab="Mean difference, cross-self",
main="Histogram of all mean differences")
abline(v=mean(ZeaMays$diff), col="red", lwd=2)
abline(v=-mean(ZeaMays$diff), col="red", lwd=2, lty=2)
Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology Dept. York University Voice: 416 736-5115 x66249 Fax: 416 736-5814 4700 Keele Street Web: http://www.datavis.ca Toronto, ONT M3J 1P3 CANADA