GARETH GRANTTECHNOLOGY · DATA · INNOVATION
Explore

20 / Inference

Paired t-test and before–after change

A paired t-test analyses the difference within each matched unit. By comparing like with like, it can remove stable differences between units and estimate an average change more precisely than treating the before and after values as unrelated samples.

IntermediateLive exploration + Python

The business question

Did the same machines, people or jobs improve after a change?

  • Assess service-time changes when the same technicians perform comparable tasks before and after training.
  • Compare measurements from two instruments on the same specimens.
  • Evaluate matched store or machine performance while preserving the matching design.

How the method works

Pairing is a feature of how the data are collected, not a statistical setting selected after the results appear. Each unit needs an identifiable before value and after value, or two genuinely matched measurements. Subtracting one from the other creates a new dataset of changes. Stable differences between fast and slow technicians can cancel within these differences.

The paired t-test is then a one-sample t-test on those differences. It compares their average with zero, using the standard deviation of the differences and the number of complete pairs. The correlation between before and after is already reflected in this standard deviation. Separate before and after standard deviations cannot substitute for the variation of paired changes.

The confidence interval describes a population mean change under the assumptions. It does not establish that every unit improved or that the intervention caused the change. A before–after study may also capture learning, seasonality, altered demand or a different job mix. Randomised order, concurrent controls and clear timing strengthen the design when they are feasible.

The calculation

d_i = before_i − after_i; mean reduction = mean(d); SE = s_d/√n; t = mean(d)/SE; df = n−1
Read the symbols
SymbolMeaning
d_iThe reduction within matched unit i.
s_dSample standard deviation of the paired reductions.
nNumber of complete independent pairs.
dfDegrees of freedom for the t distribution.

A worked business example

ILLUSTRATIVE SCENARIO

Illustrative timed task completed by eight technicians before and after a revised work instruction.

Inputs

  • Before minutes: 30, 28, 35, 32, 31, 29, 34, 33.
  • After minutes, in the same technician order: 27, 27, 31, 30, 28, 27, 30, 31.
  • Positive differences mean faster completion after the change.

Work through the numbers

  1. Within-person reductions are 3, 1, 4, 2, 3, 2, 4 and 2 minutes.
  2. Their average is 21/8 = 2.625 minutes; their sample SD is approximately 1.06066.
  3. SE = 1.06066/√8 = 0.375; t = 2.625/0.375 = 7 with 7 degrees of freedom.
  4. The two-sided p-value is about 0.000212 and the 95% interval is 1.738–3.512 minutes.
The observed sample supports a positive average time reduction for the matched task.

A shorter average time is valuable only if first-pass quality, safety and workload remain acceptable. The small illustrative sample and uncontrolled timing cannot isolate the work instruction from practice or other changes.

Explore the decision

Compare matched before-and-after values. The live explorer has its own example inputs; it is separate from the worked calculation above.

Enable JavaScript to use this calculator. The worked example and executable Python remain available.

Apply it at work

  1. Identify the matching unit and preserve a reliable pair identifier before collecting measurements.
  2. Use consistent task definitions, timing rules and order; record missing or unmatched pairs.
  3. Calculate and plot the differences, investigate extreme changes, and run the paired analysis.
  4. Review the mean change and interval alongside quality outcomes and a concurrent comparison where possible.

Check these assumptions

  • The matching is meaningful and correctly aligned; row order alone is not evidence of a pair.
  • Differences from separate pairs are independent; repeated observations from one technician require additional modelling.
  • For small samples, differences should be reasonably compatible with a normal distribution without extreme influential values.
  • The measurement method and comparison conditions are sufficiently consistent for the change to be interpretable.

Common mistakes and how to avoid them

  • Comparing only the two group averages hides the pairing and gives an incomplete uncertainty calculation.
  • Removing pairs because their reductions look inconvenient changes the result and may bias the estimate.
  • A statistically convincing change is not automatically causal when the study lacks a suitable control or randomisation.

How this can help the business

  • A manager can quantify the amount of capacity a revised procedure might release while checking quality guardrails.
  • A measurement team can assess a systematic instrument difference before deciding whether calibration or replacement is needed.
A decision rule to adapt

Predefine the minimum useful reduction and acceptable quality outcomes. Confirm that the interval and the study design support the decision, then validate in ordinary work.

When to use another approach

Use Welch’s test for unrelated groups, Wilcoxon signed-rank for appropriate paired ordinal or distributional questions, or mixed models for repeated measurements.

Reproduce the worked example in Python

The code is self-contained for this example. Dependencies and run instructions are included with the downloadable notebook.

Show executable code and recorded output
import numpy as np
from scipy import stats
before = np.array([30,28,35,32,31,29,34,33])
after = np.array([27,27,31,30,28,27,30,31])
difference = before - after
test = stats.ttest_rel(before, after)
mean = difference.mean()
se = difference.std(ddof=1) / np.sqrt(len(difference))
margin = stats.t.ppf(0.975, len(difference)-1) * se
print("Mean reduction (minutes):", round(mean, 3))
print("t and p:", round(test.statistic, 3), round(test.pvalue, 6))
print("95% CI:", round(mean-margin, 3), round(mean+margin, 3))

Recorded output

Mean reduction (minutes): 2.625
t and p: 7.0 0.000212
95% CI: 1.738 3.512
Download all worked examples

Sources and further reading

Concepts are linked to primary teaching or technical sources. The business examples are illustrative applications, not reported client results.