Sample size

Sample size calculator for paired means

Calculate how many pairs you need to detect a minimum mean change.

Calculate how many pairs you need to detect a minimum mean change in a repeated-measures or before/after design, at the target power. It works on the standard deviation of the differences.

Calculator

Enter σd, Δ, alpha and power to get the number of pairs needed.

Result pending…

Explanation

In a paired design the same experimental unit is measured under two conditions (before/after, crossover treatment/control, right eye/left eye). The comparison of interest is not the difference of means between two independent groups, but the mean of the individual differences \(\bar{d} = \bar{X}_1 - \bar{X}_2\).

The key advantage of the paired design is that it removes between-subject variability, which is usually the largest source of noise. That's why the relevant parameter is \(\sigma_d\) (the standard deviation of the within-subject differences), which is generally much smaller than the \(\sigma\) of each group taken separately. This translates into significantly smaller samples compared with an independent two-group design.

The relationship between \(\sigma_d\) and the standard deviations of each measurement is: \(\sigma_d^2 = \sigma_1^2 + \sigma_2^2 - 2\rho\sigma_1\sigma_2\), where \(\rho\) is the correlation between the two measurements. The larger \(\rho\) is, the smaller \(\sigma_d\) is, and the more efficient the paired design becomes.

Sample size formula

\( n = \left\lceil\left(\frac{(Z_{\alpha/2}+Z_\beta)\,\sigma_d}{\Delta}\right)^2\right\rceil \)

  • n: number of pairs (individuals or units, not total observations).
  • \(\sigma_d\): standard deviation of the within-subject differences (not of each group).
  • \(\Delta\): the smallest mean difference you want to detect.
  • \(Z_{\alpha/2}\) and \(Z_\beta\): normal quantiles for two-sided alpha and power.

Quick setup

  • σd: estimate it from a paired pilot study (measure differences within each pair) or from the literature. Do not use the individual σ of each group separately.
  • If you only have the individual σ and an estimated ρ: compute σd = σ·√(2(1−ρ)) assuming equal variances.
  • Δ: the smallest practically relevant difference (minimum clinically important change, minimum operational improvement).
  • Alpha and power: 0.05 and 0.80 as a baseline; 0.90 if false negatives are costly.

Simple example

A training intervention: σd = 8, minimum change to detect Δ = 3, α = 0.05, power 0.80. Result: ≈ 56 pairs. For the same situation with two independent groups (σ = 8) you would need ~113 per group if ρ = 0, but only ~56 pairs if ρ = 0.5 thanks to the paired design.

Worked example

A physiotherapy clinic wants to evaluate the effectiveness of a new treatment protocol by measuring pain level (0–10 scale) before and after the intervention in each patient. A previous pilot study estimates the standard deviation of the individual differences as \(\sigma_d = 2.1\) points. The clinical team considers it relevant to detect a minimum mean improvement of \(\delta = 1.0\) point. A two-sided significance level \(\alpha = 0.05\) and 80% power are set.

The corresponding critical values are \(z_{\alpha/2} = 1.960\) (97.5th percentile of the standard normal) and \(z_{\beta} = 0.842\) (80th percentile). Substituting into the formula:

\( n = \frac{(z_{\alpha/2} + z_{\beta})^2 \cdot \sigma_d^2}{\delta^2} = \frac{(1.960 + 0.842)^2 \times 2.1^2}{1.0^2} = \frac{(2.802)^2 \times 4.41}{1} = \frac{7.851 \times 4.41}{1} \approx 34.6 \)

Rounding up to the next integer, 35 pairs are needed (that is, 35 patients measured before and after) to reach 80% power.

If the team wants to increase power to 90% (\(z_{\beta} = 1.282\)), the calculation becomes:

\( n = \frac{(1.960 + 1.282)^2 \times 4.41}{1.0^2} = \frac{(3.242)^2 \times 4.41}{1} = \frac{10.511 \times 4.41}{1} \approx 46.4 \)

That would require 47 pairs. This increase of 12 pairs illustrates how raising power from 80% to 90% requires roughly 34% more sample.

If the true variability were larger — say \(\sigma_d = 3.0\) — with 80% power the sample size would rise to \(n = 7.851 \times 9.0 / 1.0 \approx 71\) pairs, which highlights the importance of a reliable pilot study to estimate \(\sigma_d\) accurately.

Model assumptions

  • The differences \(d_i = X_{1i} - X_{2i}\) are independent across pairs.
  • The differences are approximately normally distributed (or n is large).
  • \(\sigma_d\) is constant across all pairs (homoscedasticity of the differences).
  • Order effects do not contaminate the measurements (in crossover designs, use adequate washout periods).

Common uses

  • Pre-post intervention studies (before and after treatment).
  • Crossover designs in clinical trials.
  • Comparison of two measurement methods applied to the same subject.
  • Evaluations of change in skill, weight, blood pressure, etc.

How to interpret the result

The value \(n\) is the minimum number of subjects, each of whom contributes two measurements (before/after, or condition A/condition B). The total number of observations is \(2n\), but the number of independent statistical units remains \(n\). Always round up, and apply a dropout adjustment: if you expect 15% attrition between the first and second measurement, recruit \(\lceil n / 0.85 \rceil\) subjects in the first phase.

The key and most delicate parameter is \(\sigma_d\), the standard deviation of the within-subject differences, which should not be confused with the standard deviations of each measurement separately. If \(\sigma\) from a single measurement is used instead of \(\sigma_d\), the calculated \(n\) may be over- or underestimated depending on the correlation between the two measurements: when the within-subject correlation \(\rho\) is high, \(\sigma_d \approx \sigma\sqrt{2(1-\rho)}\) is considerably smaller than \(\sigma\), and the paired design requires far fewer subjects than the independent design. Run a sensitivity analysis with \(\sigma_d \pm 25\%\) and use the larger resulting \(n\).

If the calculated \(n\) turns out very small (< 15 pairs), check that the distribution of the differences is approximately normal, since the paired t-test relies on that assumption. With very few pairs, consider the Wilcoxon signed-rank test for related samples. When \(n\) turns out unmanageably large, review whether the minimum detectable difference \(\delta\) is practically relevant or could be relaxed. Once the data has been collected, use the paired-means hypothesis test calculator for the main analysis.

References and further reading

  • Wikipedia: Paired difference test — statistical foundation of the paired t-test.
  • Wikipedia: Crossover study — crossover designs and order considerations.
  • Cohen, J. (1988). Statistical Power Analysis for the Behavioral Sciences (2nd ed.). Lawrence Erlbaum. — chapter on the t-test for correlated differences.

Frequently asked questions

  • Why σd and not the σ of each group? Because the analysis operates on the within-subject differences, not on the group means. Using the individual σ would overestimate σd if individuals are heterogeneous.
  • How do I get σd without a pilot study? If you know the individual σ and the expected correlation ρ between measurements: σd ≈ σ·√(2(1−ρ)). For ρ = 0.7 and σ = 10 → σd ≈ 7.7.
  • When is a paired design better than two groups? Whenever the correlation between measurements is positive (ρ > 0) and you can apply both conditions to the same individual without carryover effects.
  • Is the result exact? It's the normal approximation; for small n consider using t quantiles with n−1 degrees of freedom iteratively.