Statistics · Topic 11 of 13
T Tests
Theory
A t-test compares the means of numerical data from two groups, and asks whether the difference between them is big enough to be a real effect rather than chance. It is the test to reach for whenever the research question is about an average.
1. Paired or Independent?
This is the only decision you have to make, and everything else follows from it. Ask: did the same subjects produce both sets of numbers?
- Paired — the same people, animals or objects measured twice. Before and after a treatment, morning versus afternoon, summer versus winter. Each value in one list has a partner in the other.
- Independent — two separate groups. Manufacturer A versus Manufacturer B, one school versus another, one age band versus another. Nothing links a particular value in one list to a particular value in the other.
A useful check: if the two lists must be the same length for the data to make sense, the test is paired. Independent groups can be — and usually are — different sizes, and that is not a problem.
2. Performing the Test in R Studio
Independent groups:
t.test(X, Y)
The same subjects measured twice:
t.test(X, Y, paired=TRUE)
The output to read is the p-value and the confidence interval, interpreted exactly as for any other hypothesis test.
3. Check the Data First
A t-test assumes the data is roughly normally distributed. Before running one, look at a histogram or boxplot of each group and comment on the shape. With small samples this is often not clear-cut, and saying so is a perfectly good answer — what loses marks is not looking at all.
If the data is clearly skewed, the mean is not a good summary of it, and a t-test is the wrong tool.
4. Writing the Hypotheses
Common Trap:
A t-test hypothesis must contain the word mean or average. Writing "there is no difference between the two groups" is too vague to gain the mark — a difference in what?
- Null Hypothesis (H0): There is no difference in the mean [variable] between [Group A] and [Group B].
- Alternative Hypothesis (H1): There is a difference in the mean [variable] between [Group A] and [Group B].
Name the actual groups and the actual quantity. Generic letters will not do.
Worked examples
Example 1
For each study, state whether a paired or an independent t-test is appropriate, and say why.
- The resting pulse of 40 volunteers is recorded, then recorded again after eight weeks of a running programme.
- The battery life of 25 phones from Brand A is compared with 31 phones from Brand B.
- Learners sit a spelling test in silence, and the same learners sit an equivalent test with music playing.
- The delivery times of two rival courier firms are compared over the same month.
(a) Paired. The same 40 volunteers are measured twice, so each “after” value belongs to a particular “before” value.
(b) Independent. Two separate sets of phones, with nothing linking a particular Brand A phone to a particular Brand B phone. The unequal sample sizes, 25 and 31, are not a problem.
(c) Paired. The same learners under two conditions.
(d) Independent. Two separate firms, with no link between an individual delivery by one and an individual delivery by the other.
The quick test: in (a) and (c) the two lists must be the same length, because every value has a partner. In (b) and (d) they need not be.
Example 2
A gym records the time, in minutes, that the same 60 members spend training in January and again in June. A paired t-test gives the following output:
Paired t-test data: Train.Jan and Train.Jun t = 2.9143, df = 59, p-value = 0.005022 95 percent confidence interval: 1.842 9.671
State the conclusion in context, at the 5% significance level.
Step 1: Compare the p-value with the significance level.
p = 0.005022, which is less than 0.05.
Step 2: Decide on the null hypothesis.
Since p < 0.05, we reject the null hypothesis.
Step 3: Say what that means in context.
There is sufficient evidence to conclude that there is a difference in the mean training time of gym members between January and June.
Step 4: Use the confidence interval.
The interval (1.842, 9.671) does not contain zero, which agrees with rejecting the null hypothesis. We can be 95% confident that the mean training time fell by between about 1.8 and 9.7 minutes.
Example 3
A supplier claims that two of its greenhouses produce tomato plants of the same average height. A researcher measures a sample of plants from each greenhouse.
- Write suitable hypotheses.
- State the R Studio command needed.
- The test returns a p-value of 0.214. State the conclusion at the 5% level.
(a)
H0: There is no difference in the mean height of tomato plants grown in Greenhouse A and Greenhouse B.
H1: There is a difference in the mean height of tomato plants grown in Greenhouse A and Greenhouse B.
(b) The two samples are separate groups of plants, so this is an independent t-test:
t.test(Height.A, Height.B)
(c) p = 0.214, which is greater than 0.05, so we fail to reject the null hypothesis. There is insufficient evidence of a difference in the mean height of tomato plants between the two greenhouses.
Note the wording: we have not proved the heights are the same. Failing to find evidence of a difference is not the same as showing there is none.