Skip to main content

Biostatistics in Practice: Principles and Procedures - A MedCalc companion e-book

Comparison of Two Groups of Paired Observations

Observations are paired when each value in one group is meaningfully linked to exactly one value in the other — most commonly because both measurements are made on the same subject (a before–after design, or a crossover trial), or because subjects have been individually matched on key characteristics. The pairing structure eliminates between-subject variability from the comparison, concentrating the analysis entirely on within-pair differences and typically yielding considerably more power than an unpaired design of the same size. When the differences between paired measurements are approximately normally distributed, the paired t-test is the appropriate method; when that assumption cannot be justified, the Wilcoxon signed-rank test provides a distribution-free alternative. If the observations are not paired — each group is sampled independently — see the Two groups of independent observations chapter.

The Within-Pair Difference

The central move in paired analysis is to replace each pair $(x_{1i},\, x_{2i})$ with a single difference:

$$ d_i = x_{1i} - x_{2i}, \quad i = 1, \ldots, n $$

This transforms the problem entirely: instead of comparing two correlated samples, the analysis becomes a one-sample problem — testing whether the mean of the $n$ differences is zero. The null hypothesis is $H_0: \mu_d = 0$, where $\mu_d$ is the population mean difference. The original measurements need not be normally distributed; what matters for the parametric test is the distribution of the differences.

Before proceeding, normality of the differences should be assessed — by a histogram, a Normal Q-Q plot, or a formal test such as the Shapiro–Wilk test. These methods are described in the Visualizing univariate data and Are the data normally distributed? chapters. When $n \geq 30$ the central limit theorem makes the paired t-test robust to moderate departures from normality. For smaller samples, non-normality of the differences is a genuine concern and the Wilcoxon signed-rank test should be considered.

The Paired t-Test

Let $\bar{d}$ and $s_d$ be the sample mean and standard deviation of the $n$ differences. The test statistic is:

$$ t = \frac{\bar{d}}{s_d / \sqrt{n}} $$

Under $H_0$, this follows a t-distribution with $n - 1$ degrees of freedom. The two-tailed $P$ value is standard; a one-tailed test is appropriate only when the direction of the difference was pre-specified and a result in the opposite direction would be interpreted as no effect.

The 95% confidence interval for the mean difference is:

$$ \bar{d} \;\pm\; t_{\alpha/2,\; n-1} \;\times\; \frac{s_d}{\sqrt{n}} $$

where $t_{\alpha/2,\; n-1}$ is the critical value from the t-distribution with $n - 1$ degrees of freedom. The confidence interval is usually more informative than the $P$ value alone: it shows the direction and magnitude of the difference, and whether the effect is clinically as well as statistically meaningful (see the Clinical versus statistical significance chapter).

The Wilcoxon Signed-Rank Test

The Wilcoxon signed-rank test is the non-parametric alternative to the paired t-test. It does not assume that differences are normally distributed; it requires only that they come from a continuous, symmetric distribution. The null hypothesis is that the distribution of differences is symmetric about zero — equivalently, that the median difference is zero.

The procedure is:

  1. Compute the $n$ differences $d_i = x_{1i} - x_{2i}$. Discard any pairs where $d_i = 0$; let $n'$ be the remaining count.
  2. Rank the absolute values $|d_i|$ from 1 (smallest) to $n'$ (largest). Tied values receive the average of the ranks they would otherwise occupy.
  3. Compute $W^+$, the sum of ranks for pairs where $d_i > 0$, and $W^-$, the sum of ranks for pairs where $d_i < 0$. By definition $W^+ + W^- = n'(n'+1)/2$.
  4. The test statistic is $W = \min(W^+, W^-)$. Under $H_0$, large values of both $W^+$ and $W^-$ are expected; a very small value of the minimum indicates asymmetry in the signed ranks.

For small $n'$, exact critical values are used. For $n' \geq 25$, the normal approximation

$$ z = \frac{W^+ - n'(n'+1)/4}{\sqrt{n'(n'+1)(2n'+1)/24}} $$

is adequate. When tied differences are present, a continuity correction and a ties adjustment to the variance are applied.

When the normality assumption holds, the paired t-test is slightly more powerful than the Wilcoxon signed-rank test. When it does not, the Wilcoxon test is considerably more reliable. For small samples with uncertain distributional shape, the Wilcoxon test is a safe default.

Worked Example

Twelve patients with newly diagnosed hypertension have systolic blood pressure (SBP) measured at baseline and after eight weeks of antihypertensive treatment:

Patient Before (mmHg) After (mmHg) Difference $d_i$
115814216
21451387
316214814
417115417
51491454
615514114
716815513
81521466
916314815
101481399
1117515817
121561479

All 12 differences are positive, indicating that every patient had a lower SBP after treatment. The sample mean and standard deviation of the differences are:

$$ \bar{d} = \frac{141}{12} = 11.75 \text{ mmHg}, \qquad s_d = 4.54 \text{ mmHg} $$

The standard error of the mean difference is $4.54 / \sqrt{12} = 1.31$ mmHg. The test statistic is:

$$ t = \frac{11.75}{1.31} = 8.97 $$

With $\text{df} = 11$, the two-tailed $P < 0.001$. The 95% confidence interval for the mean reduction in SBP is:

$$ 11.75 \pm 2.201 \times 1.31 = (8.87,\; 14.63) \text{ mmHg} $$

Treatment reduced mean systolic blood pressure by 11.75 mmHg (95% CI 8.87 to 14.63 mmHg). The confidence interval lies entirely above zero and well above any plausible threshold for clinical irrelevance, so the result is both statistically and clinically significant.

MedCalc computes the paired t-test and its confidence interval in its Paired t-test procedure, and the Wilcoxon signed-rank test in its Wilcoxon signed-rank test procedure.