# t test question

Given a sample of 6 workers, three were randomly selected for working environment A and three were selected for working environment B. The observed response (the number of widgets produced) was for workers under treatment A: 50, 120, 250 and for workers under treatment B: 250, 140, 150.

(a) Tell the null hypothesis where the average number of widgets produced under each treatment is equal versus a two-sided alternate hypothesis.
(b) Test the same hypothesis as in (a) but use a randomization test (using permutations).

So for (a), I have $H_o:\mu =0$ and $H_a:\mu\neq 0$ so I've let $d=A-B$, yielding -200, -20 and 100 respectively. Then $\bar{d}=-40$. I have $5$ d.f. and so my t-statistics is $t_5=(-40-0)/(\sigma/\sqrt{6})$. My estimate of $\sigma$ is $95.5$ using the regular formula, so we have $t_5=-1.026$. Then, p = P{|t_5|\geq 1.026}= 1.65 using R, which seems ridiculous.

My issue here is that this is not a matched-pairs design -- did I do something wrong with the setup?

For (b), I am not sure of the right way to randomize between the 6 samples.

-
(Quick note: the larger-or-equal sign $\leq$ is written \leq. I've made quite a few 'greater or equal ... \geq?' thinkos, myself.) –  Esteis Apr 5 '12 at 8:39
You seem to be using R in a wrong way. The probability that a $t_5$ is greater than 1.026 in absolute value is computed by 2*(1-pt(1.026,5)). You seem to have calculated 2*pt(1.026,5) instead. Of course a probability cannot be greater than 1. –  Xabier Domínguez Apr 5 '12 at 9:16
What the hell was I thinking when I wrote my leq/geq comment? leq is less than or equal. D'oh! >_< –  Esteis Apr 5 '12 at 9:18

Regarding (a):
Firstly, it's a small problem in your R code. pt gives the area under the lower tail by default, and you were expecting the area in the upper tail.

2 * pt(1.026, df=5)
## 1.648

2* pt(1.026, df=5, lower.tail=FALSE)
## 0.352


Secondly, your analysis uses the t-test for paired samples. However, because the observation units (workers) in group B are independent from the observation units in group A, you should be using the t-test for independent samples. The Wikipedia links go straight to the appropriate sections; they should contain all the info you need.

Regarding (b):
It's not called the randomization test because you'll be doing any randomizations; it's called the randomization test because the idea is thus:

$\mathrm H_0$: If group membership is independent of widget production, then we could just as easily expect the same numbers, but with different group memberships. The probability of the observations under this null hypothesis: If these were the 6 values available, and they were distributed over the groups by randomization without regard for group membership, what is the probability that the difference of the group means would be this much or more?

To get the probability of this-difference-or-greater ($\mathrm P(d < -40) + \mathrm P(40 < d)$), you'll need to get the distribution under the null of the differences. You obtain this null distribution by listing the difference for every permutation of the group memberships, or (once you get a lot of observations) by sampling from this list of permutations.

-
Given that all six subjects are different, so we have not naturally paired data, wouldn't it be more natural to test equality of means from two different populations instead? –  Xabier Domínguez Apr 5 '12 at 9:24
Good point, @Xabier, thanks for catching that. I've changed my answer accordingly. –  Esteis Apr 5 '12 at 11:27
Just as a check, should I get 6 different total permutations for (b)? –  Emir Apr 5 '12 at 14:10
Nope, there are 20 ways to choose 3 from 6. Good luck! –  Esteis Apr 5 '12 at 19:54