Part 6 · Module 4
Paired t-Test
Learn how to analyse numerical differences from paired or repeated observations using a paired t-test, confidence interval and reproducible R output.
Learning outcomes
After completing this lecture, you should be able to:
- Recognise paired, matched and repeated numerical observations.
- Define the paired difference and state hypotheses for its population mean.
- Calculate and interpret the paired t-statistic, confidence interval and p-value.
- Explain why the distributional assumption concerns the paired differences.
- Use reproducible R code to perform and verify a paired t-test.
- Report paired summaries and the mean paired difference in the correct direction.
Overview
The paired t-test compares two numerical measurements that are linked in meaningful pairs. In R, it is implemented by t.test(..., paired = TRUE) [3].
Common examples include:
- before-and-after measurements from the same participant;
- matched case–control pairs;
- measurements from two eyes or limbs when one pair is retained per person;
- two laboratory methods applied to the same specimen;
- and crossover-period measurements from the same participant under a simple design.
The analysis reduces each pair to one difference and tests whether the population mean difference equals a prespecified value, usually zero.
The independent unit is the pair, not the individual measurement.
Why this matters
A paired design can be more precise than an independent design because each participant acts as their own comparison. Stable between-person differences are removed from the paired contrast.
However, pairing helps only when:
- the pairs are correctly linked;
- the paired measurements are meaningfully comparable;
- and the within-pair correlation is represented.
Analysing paired observations as independent discards information and usually gives an incorrect standard error.
The normality assumption applies to the distribution of paired differences, not separately to the before and after measurements. General medical-statistics principles for paired analysis and reporting are discussed by Altman [4].
When to use this method
Use a paired t-test when:
- there are exactly two linked numerical measurements per independent pair;
- pairing is known and correct;
- the mean paired difference is the estimand;
- pairs are independent of other pairs;
- and the difference distribution is sufficiently compatible with the procedure.
Do not use it for:
- two groups containing different participants;
- three or more repeated time points;
- incomplete pairs analysed without a missing-data plan;
- clustered pairs;
- or a randomised trial when the treatment effect requires a between-group comparison.
Research question and variables
The estimand is:
where is follow-up minus baseline systolic blood pressure.
The hypotheses are:
The direction must be stated. Reversing the order changes the sign but not the two-sided p-value.
Data structure
Wide paired-data structure
simulated data| participant_id | sbp_baseline | sbp_followup | difference |
|---|---|---|---|
| P001 | 134 | 132 | −2 |
| P002 | 152 | 152 | 0 |
| P003 | 152 | 139 | −13 |
| P004 | 178 | 168 | −10 |
| P005 | 153 | 139 | −14 |
Note: Difference = follow-up minus baseline. The complete dataset contains 30 pairs.
The two variables must be aligned by participant identifier. Sorting one column independently destroys the pairing.
Statistical assumptions
The baseline and follow-up distributions do not each need to be normal. The important distribution is the set of within-pair differences.
How the method works
Let be the sample mean of the paired differences and their sample SD.
The 95% CI is:
Worked example
Reproducible R analysis
paired_bp <- data.frame(
participant_id = sprintf("P%03d", 1:30),
sbp_baseline = c(
134, 152, 152, 178, 153, 143, 169, 139, 135, 159,
162, 151, 131, 140, 158, 156, 152, 140, 142, 150,
155, 163, 165, 146, 151, 129, 138, 142, 150, 152
),
sbp_followup = c(
132, 152, 139, 168, 139, 137, 176, 131, 125, 142,
151, 138, 126, 125, 144, 157, 155, 143, 131, 137,
151, 164, 164, 135, 154, 124, 124, 128, 143, 138
)
)
paired_bp$difference <- paired_bp$sbp_followup - paired_bp$sbp_baseline
fit <- t.test(
paired_bp$sbp_followup,
paired_bp$sbp_baseline,
paired = TRUE,
alternative = "two.sided",
conf.level = 0.95
)
fit
R console output
Paired t-test
data: paired_bp$sbp_followup and paired_bp$sbp_baseline
t = -5.7575, df = 29, p-value = 3.104e-06
alternative hypothesis: true mean difference is not equal to 0
95 percent confidence interval:
-9.667289 -4.599378
sample estimates:
mean difference
-7.133333
Cleaned output code
result <- data.frame(
pairs = nrow(paired_bp),
baseline_mean = mean(paired_bp$sbp_baseline),
baseline_sd = sd(paired_bp$sbp_baseline),
followup_mean = mean(paired_bp$sbp_followup),
followup_sd = sd(paired_bp$sbp_followup),
mean_difference = mean(paired_bp$difference),
difference_sd = sd(paired_bp$difference),
ci_lower = fit$conf.int[1],
ci_upper = fit$conf.int[2],
t = unname(fit$statistic),
df = unname(fit$parameter),
p_value = fit$p.value,
dz = mean(paired_bp$difference) / sd(paired_bp$difference)
)
round(result, 3)
Cleaned R output
pairs baseline_mean baseline_sd followup_mean followup_sd mean_difference difference_sd ci_lower ci_upper t df p_value dz
30 149.567 11.524 142.433 14.105 -7.133 6.786 -9.667 -4.599 -5.758 29 3.10e-06 -1.051
For reporting, write $p<0.001$, not p=0.000.
Interpreting the output
Presenting the results
| Time | Mean (SD), mmHg |
|---|---|
| Baseline | 149.6 (11.5) |
| Follow-up | 142.4 (14.1) |
Follow-up minus baseline mean difference −7.1 mmHg (95% CI −9.7 to −4.6); paired , .
Suggested reporting
Paired analysis is not automatically a causal before-and-after analysis MMed extension
Pairing addresses statistical dependence. It does not create a valid counterfactual.
In an uncontrolled before-and-after study, observed change can reflect:
- natural history;
- regression to the mean;
- maturation;
- seasonal change;
- concurrent treatment;
- or measurement drift.
Causal interpretation requires an appropriate comparison design and assumptions.
Common mistakes
Knowledge check
What is the independent analytical unit in a paired t-test?
Answer and reasoning
The pair. Each pair produces one difference, and differences from separate pairs are assumed independent.
Which distribution should be examined for the normality-related assumption?
Answer and reasoning
The distribution of the paired differences, not the baseline and follow-up distributions separately.
Why does reversing baseline and follow-up not change the two-sided p-value?
Answer and reasoning
It changes every difference’s sign and reverses the test statistic and confidence interval, but the absolute statistic remains the same.
Does the significant decrease prove the medication review caused the improvement?
Answer and reasoning
No. Pairing controls person-level stability but does not control secular change, regression to the mean or co-interventions.
What method is needed for baseline, month 3 and month 6 measurements?
Answer and reasoning
A repeated-measurement method such as repeated-measures ANOVA, a mixed-effects model or GEE, depending on the estimand and assumptions.
Key take-home messages
References
- Student. The probable error of a mean. Biometrika. 1908;6(1):1–25. https://doi.org/10.1093/biomet/6.1.1
- Bland JM, Altman DG. Comparisons against baseline within randomised groups are often used and can be highly misleading. Trials. 2011;12:264. https://doi.org/10.1186/1745-6215-12-264
- R Core Team. Student’s t-test. R documentation, package stats version 4.6.1. Vienna: R Foundation for Statistical Computing; 2026. https://search.r-project.org/R/refmans/stats/html/t.test.html
- Altman DG. Practical statistics for medical research. London: Chapman and Hall; 1991.
- Lakens D. Calculating and reporting effect sizes to facilitate cumulative science: a practical primer for t-tests and ANOVAs. Front Psychol. 2013;4:863. https://doi.org/10.3389/fpsyg.2013.00863
These notes support learning and research planning and do not replace statistical consultation for a specific study.