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. Cheers, Bert On Fri, Oct 14, 2011 at 12:42 PM, Michael Friendly <[email protected]>wrote: > On 10/14/2011 1:20 PM, Weidong Gu wrote: > >> On Fri, Oct 14, 2011 at 11:38 AM, Michael Friendly<[email protected]> >> wrote: >> >>> Hi all >>> Consider the classic data below from Darwin on the heights of 15 pairs of >>> zea mays (corn) plants >>> either cross-fertilized or self-fertilized, where the goal is to see if >>> it >>> makes a difference. >>> >>> head(ZeaMays) >>>> >>> pair pot cross self diff >>> 1 1 1 23.500 17.375 6.125 >>> 2 2 1 12.000 20.375 -8.375 >>> 3 3 1 21.000 20.000 1.000 >>> 4 4 2 22.000 20.000 2.000 >>> 5 5 2 19.125 18.375 0.750 >>> 6 6 2 21.500 18.625 2.875 >>> ... >>> >>> I'd like to illustrate two types of non-parametric tests of whether the >>> mean(diff) = 0. >>> >>> (a) Permutation test, where the values of, say self are permuted and >>> diff=cross - self >>> is calculated for each permutation. There are 15! permutations, but a >>> reasonably >>> large number of random permutations would suffice. >>> >>> (b) Test based on assigning each abs(diff) a + or - sign, and calculating >>> the mean(diff). >>> There are 2^15 such possible values, but again, a reasonably large number >>> of >>> random >>> samples would do. >>> >>> What do you mean by 'assigning each abs(diff) a + or - sign, and >> calculating the mean(diff)'? >> abs(diff) should be all positive, right? >> >> >> I mean to calculate > mean (sign * abs(diff)) > where sign is a vector of length 15 composed of some combination of (-1, > +1). > > This is actually what Fisher did. It corresponds to assigning one member > of each pair to cross / self > > -- > 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 > > ______________________________**________________ > [email protected] mailing list > https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help> > PLEASE do read the posting guide http://www.R-project.org/** > posting-guide.html <http://www.R-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. > -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm [[alternative HTML version deleted]] ______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.

