Paired t-test: when to use it, formula and worked example

Updated

The paired t-test compares two measurements taken on the same units: the same parts before and after a treatment, or the same samples measured by two methods. It works on the differences within each pair, so the large variation between units cancels out. It is a 1-sample t-test on the differences, with a target difference of zero.

When to use it

  • Method comparison: two gauges, two analyzers or two labs measure the same set of parts or samples.
  • Before and after: the same parts are measured before and after heat treatment, aging or a process change.
  • Matched units: two treatments applied to the two halves of the same panel, or to the left and right cavity of the same shot.
  • Whenever each value in one column belongs to a specific value in the other. If the groups are made of different units, use the 2-sample t-test.

How it works

For each pair i, compute the difference dᵢ = xᵢ(second) − xᵢ(first). Then:

  • H₀: μ_d = 0 (no systematic difference between the two measurements).
  • H₁: μ_d ≠ 0, or > 0, or < 0.

The test statistic, with d̄ and s_d the mean and standard deviation of the n differences:

t = d̄ / (s_d / √n), df = n − 1

The confidence interval for the mean difference is:

d̄ ± t(1 − α/2, n − 1) · s_d / √n

Assumptions: the pairs are independent of each other, and the differences (not the raw values) are roughly normal. The raw values can spread over a wide range; that is exactly the situation where pairing helps.

Example

A hospital laboratory is bringing in a new chemistry analyzer. Before it goes live, 10 patient samples covering the reporting range are run on both the current analyzer (A) and the new one (B). Glucose results, in mg/dL:

Sample12345678910
Analyzer A7275179199235243226237204227
Analyzer B7378180203232245230242210231
B − A1314−324564
Glucose on two analyzers, same 10 samples100150200250Glucose (mg/dL)Analyzer AAnalyzer B12345678910Sample
Glucose on two analyzers, same 10 samples

The lab tests H₀: μ_d = 0 against a two-sided alternative.

  • Mean difference: d̄ = 2.70 mg/dL.
  • Standard deviation of the differences: s_d = 2.584.
  • Standard error: 2.584/√10 = 0.817.
  • t = 2.70/0.817 = 3.30, with 9 degrees of freedom.
  • p-value = 0.0092.
  • t(0.975, 9) = 2.262, so the 95% CI is 2.70 ± 2.262 × 0.817 = 0.85 to 4.55 mg/dL.

An Anderson–Darling test on the 10 differences gives p = 0.29, so normality of the differences is reasonable.

What happens if you ignore the pairing? A 2-sample t-test on the same two columns gives p = 0.93. The samples range from 72 to 245 mg/dL, and that spread between patients (standard deviation about 64 mg/dL) swamps a 2.7 mg/dL offset. Pairing removes it.

How to read the results

  • The p-value of 0.0092 says the new analyzer reads systematically higher than the current one. The offset is real, not noise.
  • The interval says the offset is between about 0.9 and 4.5 mg/dL. That is the number the lab needs.
  • Compare it with what matters clinically. Suppose the lab's acceptance limit for a systematic difference between analyzers is ±6 mg/dL. The whole interval sits inside that limit, so the difference is real but acceptable. Statistical significance and practical importance are separate questions; the interval answers both.
  • Check for a trend. A constant offset and a proportional one (larger at high values) call for different fixes. Plot the differences against the average of each pair; if they grow with the level, study linearity and bias across the range.

Common mistakes

  • Analyzing paired data as two independent samples. As the example shows, that can hide a clear difference completely.
  • Pairing data that are not really paired. Sorting two columns separately and lining them up creates false pairs. Pairs must come from the same unit.
  • Checking normality on the raw values. Only the differences need to be roughly normal.
  • Using a significant p-value to reject a method. A tiny but consistent offset can be highly significant and still acceptable. To show two methods agree within a margin, use an equivalence test for paired data.

Frequently asked questions

What is the difference between a paired t-test and a 2-sample t-test?

The paired test uses the differences within each unit, so variation between units drops out. The 2-sample test compares two separate groups and must carry all of that variation in its standard error. Use paired whenever each value has a natural partner.

What are the degrees of freedom for a paired t-test?

The number of pairs minus one. Ten pairs give 9 degrees of freedom.

What if the differences are not normal?

With 20 or more pairs the test is robust to moderate skewness. For fewer pairs with outliers or skewed differences, use the 1-sample Wilcoxon test on the differences.

How many pairs do I need?

It depends on the smallest difference you need to detect and the spread of the differences. See sample size for the paired t.

Try it with your own data

StatLab SPC is free, open-source statistics for engineers. It runs in your browser, works offline, and never uploads your data.

Open StatLab