Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Paired & Randomization Tests

When observations are matched, the comparison must preserve the pairs. This page explains paired tests, design-based randomization, and planning sample size and power.

At a Glance

Paired analysis
Randomization analysis

Reduce each independent pair to one difference. The sample size is the number of independent pairs.

Paired Comparisons

Use pairing when the same unit receives two conditions, or when two units are meaningfully matched. Examples include two measurements on the same participant or matched specimens from the same batch.

Define a consistent subtraction order:

Dj=Y1j−Y2j,j=1,…,n.D_j=Y_{1j}-Y_{2j},\qquad j=1,\ldots,n.

Here nn counts pairs, not the 2n2n individual measurements. The comparison becomes a one-sample problem for the differences:

Dˉ=1n∑jDj,sD2=∑j(Dj−Dˉ)2n−1.\bar D=\frac1n\sum_jD_j,\qquad s_D^2=\frac{\sum_j(D_j-\bar D)^2}{n-1}.

To test H0:μD=Δ0H_0:\mu_D=\Delta_0,

T=Dˉ−Δ0sD/n∼tn−1under H0.T=\frac{\bar D-\Delta_0}{s_D/\sqrt n}\sim t_{n-1}\quad\text{under }H_0.

The exact result assumes independent, normally distributed differences. The two sets of raw measurements need not individually satisfy an independent-sample model. A two-sided confidence interval is

Dˉ±t1−α/2,n−1sDn.\bar D\pm t_{1-\alpha/2,n-1}\frac{s_D}{\sqrt n}.

Why Pairing Can Improve Precision

Var⁡(Y1−Y2)=σ12+σ22−2Cov⁡(Y1,Y2).\operatorname{Var}(Y_1-Y_2)=\sigma_1^2+\sigma_2^2-2\operatorname{Cov}(Y_1,Y_2).

When responses within pairs are positively correlated, subtracting removes shared unit-to-unit variation. With equal marginal variance σ2\sigma^2 and correlation ρ\rho,

Var⁡(Dˉ)=2σ2(1−ρ)n.\operatorname{Var}(\bar D)=\frac{2\sigma^2(1-\rho)}{n}.
  • Strong positive correlation can give much better precision than an independent comparison of the same size.

  • Arbitrary matching does not guarantee a gain. Negative within-pair correlation can increase variance.

  • For crossover experiments, randomize or counterbalance treatment order. Time trends, learning, fatigue, and carryover can otherwise mimic treatment effects.

  • If a treatment permanently changes the unit, applying both conditions may not be appropriate.

Randomization & Permutation Tests

A randomization test asks: How unusual is the observed statistic among assignments allowed by the design, if treatment has no effect?

  1. Choose a statistic, such as Yˉ1−Yˉ2\bar Y_1-\bar Y_2.

  2. Compute its observed value TobsT_{\mathrm{obs}}.

  3. Generate treatment assignments consistent with the original randomization.

  4. Recompute the statistic for each assignment.

  5. Count results at least as extreme as observed.

For a complete enumeration of equally likely assignments A\mathcal A, a two-sided absolute-statistic test has

p=#{a∈A:∣Ta∣≥∣Tobs∣}∣A∣.p=\frac{\#\{a\in\mathcal A:|T_a|\geq|T_{\mathrm{obs}}|\}}{|\mathcal A|}.

For BB independently sampled random assignments, a standard Monte Carlo estimate is

p^=1+∑b=1BI(∣Tb∣≥∣Tobs∣)B+1.\widehat p=\frac{1+\sum_{b=1}^B I(|T_b|\geq|T_{\mathrm{obs}}|)}{B+1}.

The added 1 includes the observed arrangement and avoids reporting a zero estimated pp-value.

DesignValid rearrangement
Completely randomized independent groupsReassign labels while retaining the original group sizes.
Randomized matched pairsSwap treatment labels within each pair, equivalent to sign-flipping each difference.
Randomized blocksReassign labels within blocks, preserving allocation counts.
Cluster-randomized experimentReassign whole clusters, not individual measurements.

A bootstrap resamples observations to approximate sampling uncertainty. A permutation test rearranges labels to construct a null distribution. These are different procedures.

Planning Sample Size & Power

Choose the smallest effect worth detecting, δ\delta, before data collection. Specify a significance level α\alpha, desired power 1−β1-\beta, and a plausible variance from earlier work or a pilot study.

For a balanced, two-sided independent comparison with common variance σ2\sigma^2, a normal approximation gives

n≈2σ2(z1−α/2+z1−β)2δ2units per group.n\approx\frac{2\sigma^2(z_{1-\alpha/2}+z_{1-\beta})^2}{\delta^2} \quad\text{units per group}.

For paired differences with variance σD2\sigma_D^2,

n≈σD2(z1−α/2+z1−β)2δ2pairs.n\approx\frac{\sigma_D^2(z_{1-\alpha/2}+z_{1-\beta})^2}{\delta^2} \quad\text{pairs}.

Here zqz_q is the qq quantile of the standard normal distribution. Round up. These are planning approximations; small-sample tt procedures, attrition, clustering, and a different design may require different calculations.

Change, holding other inputs fixedRequired sample size
Higher desired powerIncreases.
Larger response varianceIncreases.
Smaller significance levelIncreases.
Smaller target effectIncreases; halving δ\delta roughly quadruples nn.
More effective pairingDecreases when it reduces σD2\sigma_D^2.

Increasing the number of correlated measurements is not the same as increasing the number of independent experimental units. Large samples do not fix confounding.

These calculations compare the paired normal-model test with exact within-pair sign randomization for the same illustrative differences.