STAT5002 Chap.11 Two-Sample and Paired T-tests
Two-Sample and Paired T-tests
Comparing two means is where most real studies end up: a new method against an old one, one group against another, before against after. This chapter extends the one-sample T-test to two samples and shows that the right test depends on how the data were collected.
For two independent groups, each sample is modelled as draws from its own box, and the difference of sample means has expected value equal to the difference of box means and an SE built by adding the two squared SEs. Because the box SDs are unknown, you have three choices.
The classical two-sample T-test assumes the two boxes share one SD, pools the sample SDs into a single estimate, and uses Student's t with m + n - 2 degrees of freedom; in R that is t.test(x, y, var.equal = T). The Welch test drops the equal-spread assumption, plugs each sample SD into its own term, and lets R work out a fractional degrees of freedom; it is what t.test(x, y) runs by default.
When normality of the boxes is doubtful, a bootstrap simulation centres each sample, resamples, and builds the null distribution of the Welch statistic directly. Paired data are different: each unit is measured twice, so the two columns are linked and the two-sample methods overstate the SE.
The fix is to subtract within each unit and run a one-sample T-test on the differences, with n - 1 degrees of freedom, via t.test(x, y, paired = T). By the end you should be able to choose among the three tests from the design, read the R printout, and write each test in the HATPC format.
What this chapter covers
- 01
Two-box model for two independent samples
- 02
Expected value and SE of a difference of sample means
- 03
Z-statistic when both box SDs are known
- 04
Equal variances assumption and the pooled SD estimate
- 05
Classical two-sample T-test on m + n - 2 degrees of freedom
- 06
Confidence interval for a difference of means with qt()
- 07
Welch test and R's default t.test()
- 08
Bootstrap simulation of the Welch statistic
- 09
Paired designs and why the columns are not independent
- 10
Paired T-test as a one-sample test on differences
- 11
One-sided alternatives and argument order in t.test()
Worked example · free
Paired T-test on two espresso machines
- +1Each barista used both machines, so the data are paired. Differences old minus new are 3, 3, 1, 5, 1, 5, 1, 3, 4, 1.
- +1H: H0: mean difference = 0 against H1: mean difference is not 0. A: the differences come from a roughly normal box; a dot plot of the 10 values shows no extreme outlier.
- +1The mean difference is 2.70 seconds and the sample SD of the differences is 1.636, so SE = 1.636/sqrt(10) = 0.517.
- +1T = 2.70/0.517 = 5.218, compared with Student's t on 10 - 1 = 9 degrees of freedom.
- +1P: 2 * pt(5.218, df = 9, lower.tail = F) = 0.0006. C: 0.0006 is below 0.05, so reject H0.
- +195% CI: 2.70 plus or minus 2.262 x 0.517, giving (1.53, 3.87) seconds, which excludes 0.
Key terms
- Two-box model
- A model in which two independent samples are drawn with replacement from two separate boxes, each with its own mean and SD.
- Pooled SD estimate
- A single estimate of a common box SD, formed by combining the two sample variances weighted by their degrees of freedom, m - 1 and n - 1.
- Classical two-sample T-test
- A test of equal box means that assumes normal boxes with equal SDs and refers the statistic to Student's t with m + n - 2 degrees of freedom.
- Welch test
- A two-sample T-test that does not assume equal SDs; each sample SD enters its own SE term and the degrees of freedom are computed from the data.
- Paired design
- A study layout in which each unit gives one reading under each condition, so the two columns of data are linked rather than independent.
- Mean difference
- The average of the within-unit differences in a paired design, the quantity a paired T-test compares with zero.
Two-Sample and Paired T-tests FAQ
When should I use var.equal = T in t.test()?
Only when you are willing to assume the two boxes have the same SD, for example when the sample SDs are similar and the boxplots show comparable spread. Otherwise leave it out and R runs the Welch test, which is the safer default.
Why is the degrees of freedom in a Welch test not a whole number?
Welch's approximation makes the degrees of freedom a function of the two sample sizes and sample SDs, so it is usually not a whole number. You are not expected to compute it by hand; read it from the R printout.
What goes wrong if I analyse paired data with a two-sample test?
The two-sample SE treats differences between units as noise, so it is much larger than the SE of the within-unit differences. The test loses power and can miss a clear, consistent effect that the paired test detects.
How do I do a one-sided paired T-test in R?
Use t.test(x, y, paired = T, alternative = "greater") or "less". The differences are taken as x minus y, so swapping the argument order reverses which alternative matches your claim.
Exam move
Make a three-column card: classical, Welch, paired. For each, write the design it fits, its assumptions, its SE formula, its degrees of freedom and the exact t.test() call. Then practise the decision that comes before any arithmetic: take five short study descriptions, ask whether each value in one column belongs to the same unit as a value in the other, and choose the test.
Compute one pooled-SD example fully by hand, including the confidence interval with qt(), and check it against t.test(var.equal = T). For Welch, practise reading printouts rather than computing df. For paired data, always write out the differences first and run a one-sample test on them; then run the unpaired version on the same numbers and compare the SEs, so you can explain in one sentence why pairing changes the answer.
Finish each answer in HATPC order.
Working through Two-Sample and Paired T-tests in STAT5002? Sia is AskSia’s AI Statistics tutor — ask any STAT5002 Two-Sample and Paired T-tests question and get a clear, step-by-step explanation grounded in how STAT5002 is taught and assessed. Read this chapter free, then take your hardest questions to Sia.
STAT5003 Computational Statistical Methods · DATA2002 Data Analytics: Learning from Data · QBUS5001 Foundation in Data Analytics for Business