[R] Permutation Distribution
Charles C. Berry
cberry at tajo.ucsd.edu
Thu Jul 20 19:45:38 CEST 2006
On Thu, 20 Jul 2006, Jacob van Wyk wrote:
> 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:
from which the products of the means are easily obtained.
Takes about 5 seconds on my 2GHz AMD running Windows XP.
Charles C. Berry (858) 534-2098
Dept of Family/Preventive Medicine
E mailto:cberry at tajo.ucsd.edu UC San Diego
http://biostat.ucsd.edu/~cberry/ La Jolla, San Diego 92093-0717
More information about the R-help