Re: [R] Permutation Distribution

From: Charles C. Berry <cberry_at_tajo.ucsd.edu>
Date: Fri 21 Jul 2006 - 03:45:38 EST


On Thu, 20 Jul 2006, Jacob van Wyk wrote:

> Hallo
>
> Is there an elegant way to do the following:
>
> Dataset consists of 2 variables: var1: some measurements, and var2: a grouping variable with two values, 1 and 2.
> There are (say) 10 measurements from group 1 and 15 measurements from group 2.
> The idea is to study the permutation distribution of mean(group 1) * mean(group2).
> One way would be to permute 1s and 2s and select the corresponding measurements; calculate the difference in means.
> Redo this 1000 times, say. Etc.

There are only choose(25,10) == 3268760 values.

You can enumerate all the sums of the values in one group following:

         http://finzi.psych.upenn.edu/R/Rhelp02a/archive/76450.html

from which the products of the means are easily obtained.

Takes about 5 seconds on my 2GHz AMD running Windows XP.

HTH, Chuck

Charles C. Berry                        (858) 534-2098
                                          Dept of Family/Preventive Medicine
E mailto:cberry@tajo.ucsd.edu	         UC San Diego
http://biostat.ucsd.edu/~cberry/         La Jolla, San Diego 92093-0717

______________________________________________
R-help@stat.math.ethz.ch 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. Received on Fri Jul 21 04:58:08 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 21 Jul 2006 - 06:19:37 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.