University of Sydney · FACULTY OF STATISTICS

STAT5002 Chap.11 Two-Sample and Paired T-tests

- one subject, every graph, every model, every mark
11 Chapters4-page Bible
Our own words - no uploaded lecturer files
Updated for this semester
Chapter 11 of 12 · STAT5002

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.

In this chapter

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

Q [6 marks]. A cafe times 10 baristas making the same coffee on its old machine and on a new machine. Old times (seconds): 48, 55, 51, 62, 45, 58, 50, 53, 60, 47. New times, same baristas in the same order: 45, 52, 50, 57, 44, 53, 49, 50, 56, 46. Test at the 5% level whether mean preparation time differs between the machines, and give a 95% confidence interval for the mean difference. (6 marks. The mark allocation is ours, not the University's.)
The left panel shows why two-sample methods mislead here: the typists differ from one another by far more than the layouts do, and that spread swamps the comparThe left panel shows why two-sample methods mislead here: the typists differ from one another by far more than the layouts do, and that spread swamps the comparison. Yet 8 of 8 lines rise, and the right panel keeps only those within-typist changes. Their SD is 1.75, against column SDs of 8.83 and 7.36.EIGHT TYPISTS, TWO LAYOUTSwords per minute, one line per typist40506070Layout ALayout BDIFFERENCESB minus A, per typist0123456mean 3.25
The left panel shows why two-sample methods mislead here: the typists differ from one another by far more than the layouts do, and that spread swamps the comparison. Yet 8 of 8 lines rise, and the right panel keeps only those within-typist changes. Their SD is 1.75, against column SDs of 8.83 and 7.36.
  • +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.
T = 5.218 on 9 df with p = 0.0006, so we reject H0: the new machine is faster by about 2.7 seconds on average, with a 95% CI of (1.53, 3.87).
Sia tip — Before typing t.test(), ask whether each value in one column belongs to the same unit as a value in the other. If yes, add paired = T and state your differences as first argument minus second, so the sign of T and any one-sided alternative point the way you intend.
Glossary

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.
FAQ

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.

Study strategy

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.

A+Everything unlocked
Unlocks this Bible + all 165 of your University of Sydney subjects - and 1,000+ Bibles across every Australian university.
Sia - your STAT5002 tutor, unlimited, worked the way the exam marks it
The full 4-page Bible + practice bank with worked solutions
Chrome extension - sync your LMS so Sia knows your deadlines
Bilingual EN / Chinese on every Bible and every Sia answer
$0.99 Trial
30-day money-back · cancel in one tap · how it works