The test for a difference of two means asks the same kind of question as the interval: is there convincing evidence that two true means differ, or that one is larger? Before the arithmetic comes the setup, and with two groups there is one new decision to make first: are the data paired, or are they two independent groups?
Paired or two independent groups?
The design decides, not the numbers. Look at how the data were produced.
| Paired | Two independent groups | |
|---|---|---|
| How the data arise | each unit measured twice, or units matched in pairs | two separate random samples, or random assignment to two groups |
| Examples | before and after; both shoes on the same runner; twins | brand X phones and brand Y phones; runners split into two shoe groups |
| Parameter | , the true mean difference | , the difference of true means |
| Test | paired t test (one-sample t on the differences) | two-sample t test |
| df | , where is the number of pairs | technology, or the smaller of and |
A coach with 40 runners and two shoe designs can do either. In plan 1, every runner runs once in each shoe, in random order: paired. In plan 2, the runners are randomly split 20 and 20: two groups. Plan 1 is usually better at detecting a small effect. Runners differ from each other by minutes; a shoe might change a time by seconds. Pairing compares each runner with themselves, so the large runner-to-runner variation drops out of the differences.
Hypotheses for two means
For two independent groups, the null hypothesis says the true means are equal, and the alternative comes from the question:
You may also write and . Either way, define both parameters in context, and keep the order of subtraction consistent from the hypotheses to the conclusion.
Worked example 1. A consumer group buys a random sample of 15 brand X phones and an independent random sample of 15 brand Y phones and runs each until the battery dies while streaming (invented data). Does brand X last longer on average? Set up the test.
Procedure: a two-sample t test for .
Hypotheses: , , where is the true mean battery life while streaming of all new brand X phones and the same for brand Y.
Conditions. Random: independent random samples of each brand. 10%: 15 is less than 10% of all phones sold, for each brand. Normal/large sample: both samples have , but boxplots of both show no strong skew and no outliers.
Worked example 2. For plan 2 of the shoe study (runners randomly assigned 20 to shoe A, 20 to shoe B), the coach asks whether the mean 5 km time differs between the shoes.
Hypotheses: , , where and are the true mean 5 km times in shoes A and B for runners like these. "Differs" means two-sided.
Conditions. Random: random assignment of runners to shoes. 10%: not needed, since this is an experiment, not a sample from a population. Normal/large sample: 20 per group, so check that a graph of each group's times shows no strong skew or outliers.
Conditions, group by group
Every condition is checked for each group. A sample of 40 delivery times from company P passes the normal/large sample condition by size, but if the sample of 12 from company Q is strongly skewed with an outlier, the test is not appropriate: P passing does not rescue Q. Different sample sizes are fine, and the two standard deviations do not need to match; the test uses each one separately.
When it is a one-sample test after all
If one of the two means is a known standard rather than a second sample (an old bulb's long-established mean life of 1,200 hours, say), there is only one sample: test with a one-sample t test. A two-sample test is for two groups that both carry sampling variability.
Errors in context
For the battery test, a Type I error would occur if the two brands have the same true mean battery life but we find convincing evidence that brand X's is greater. A Type II error would occur if the true mean battery life of brand X phones is greater than that of brand Y phones, but we do not find convincing evidence that it is greater. The next topic computes the test statistic and the p-value.