Next: randt() Up: Design Macros Help File Previous: randsign()   Contents

# randt2()

Usage:
 ```randt2(y1, y2 [,trials:n]), REAL vectors y1 and y2, positive integer n ```

Keywords: permutation test, analysis
```randt2(y1, y2) computes all possible values of xbar_1 - xbar_2 where
xbar_1 is the mean of a subset of size M = length(y1) from vector(y1,y2)
and xbar_2 is the mean of the length(y2) remaining elements.  y1 and y2
must be REAL vectors.  If there are MISSING values in y1 or y2, they are
immediately deleted and a warning message printed.

The returned value is a vector containing all the differences.

Thus randt2() produces the permutation distribution for a test of equality
of means based on the differences of the means of y1 and y2.

randt2(x1, x2, trials:N) does the same except it randomly samples N
values from the permutation distribution of ybar_1 - ybar_2.

You can use the results of randt2 to compute p-values for the
randomization equivalent of the two sample t-test by finding the
fraction of the differences as extreme or more extreme than the observed
difference for the two groups.  You may need to be a little careful in
making the comparison because there may not be an exact match of the
observed difference of means and the values returned by randt2 because
of minor differences in rounding .

Examples:
Cmd> y1 <- vector(6.5,6,7.1,7.1,3.5,6.1) # group 1 data

Cmd> y2 <- vector(3.9,4.9,2.1,7.7,4.9) # group 2 data

Cmd> d <- sum(y1)/6 - sum(y2)/5; d  # difference of means
(1)        1.35

Cmd> out <- randt2(y1,y2)

Cmd> length(out) # how many are there?
(1)         462

Cmd> sum(round(out - d,12) >= 0)/462 #one-sided permutation P-value
(1)     0.20996