Why the Error Term Matters
In a crossover study, each subject receives both treatments. The two measurements from one subject therefore share a subject-specific component; they are not independent observations. A treatment comparison should use the variation in within-subject contrasts, rather than treating the subject-to-subject differences in baseline level as treatment-test error.
For the classical balanced two-period, two-sequence crossover, the treatment test has 1 numerator degree of freedom and \(2n-2\) denominator degrees of freedom, where \(n\) is the number of subjects in each sequence. Its denominator is the residual mean square from the crossover ANOVA—not the mean square for subjects nested within sequence. The distinction follows from which effects vary within subjects and which vary between subjects.
Model and Assumptions
Let \(Y_{ijk}\) be the log-scale endpoint for subject \(j\) in sequence \(i\) during period \(k\). A classical additive model is
Here \(\mu\) is an overall mean; \(S_i\) is the fixed sequence effect; \(U_{j(i)}\) is the random effect for subject \(j\) nested in sequence \(i\); \(P_k\) is the fixed period effect; and \(T_{l(i,k)}\) is the fixed effect of the treatment received. The treatment contrast \(\tau\) is the mean for treatment T minus the mean for treatment R. The subject effects are assumed independent with mean zero and variance \(\sigma_U^2\). The residuals \(\varepsilon_{ijk}\) are assumed independent of the subject effects and of one another, with mean zero and common variance \(\sigma^2\). For the usual exact small-sample \(F\) test, residuals are also assumed normally distributed.
This test also relies on the design and model being appropriate: subjects complete both periods, each treatment occurs once per subject, and the treatment effect is additive across periods. In particular, the model assumes no carryover effect that would make a period’s response depend on treatment received earlier. These conditions support interpreting the within-subject contrast as a treatment comparison while allowing for a period effect. The introductory material on the classical two-period crossover ANOVA gives the broader model context; here the focus is the treatment test’s denominator.
How the Error Term and Degrees of Freedom Arise
For each subject, form the observed log-scale difference \(D=\text{T response}-\text{R response}\), regardless of the order in which the treatments were received. Write the period effect as \(P_2-P_1\). In the T-then-R sequence, the subject’s expected difference is \(\tau-(P_2-P_1)\); in the R-then-T sequence, it is \(\tau+(P_2-P_1)\). Thus the sequence-specific mean differences are
Averaging these means removes the period effect and estimates treatment:
The subject effect \(U_{j(i)}\) also cancels in each within-subject difference. What remains is the difference between that subject’s two residuals. Under the model, its variance is \(2\sigma^2\). The two sequence means each average \(n\) such differences, and the sequences contain different subjects. Therefore,
This calculation explains why the treatment test needs an estimate of \(\sigma^2\), the within-subject residual variance. Subjects within sequence instead describe between-subject variation and supply the error term for a between-subject sequence test. They are not the treatment-test denominator.
After fitting the two sequence-specific means of \(D\), there are \(2n\) subject differences and two fitted means. The remaining contrast variation has \(2n-2\) degrees of freedom. Equivalently, in the crossover ANOVA, the residual degrees of freedom are \(2n-2\). With one treatment contrast, the ANOVA test is
The standard error of \(\hat{\tau}\) is \(\sqrt{MS_{\mathrm{Residual}}/n}\). The equivalent \(t\) statistic is \(\hat{\tau}/\sqrt{MS_{\mathrm{Residual}}/n}\), with \(2n-2\) degrees of freedom; its square equals \(F\). The stated \(F\) reference distribution applies under the model assumptions and the null hypothesis.
Worked Example: Computing the Treatment Test
Suppose a hypothetical balanced study has four subjects per sequence. The subject-level log differences \(D=\text{T}-\text{R}\) are \(0.10, 0.14, 0.06, 0.10\) in the T-then-R sequence and \(0.18, 0.22, 0.14, 0.18\) in the R-then-T sequence. Assume complete observations and the model conditions described above.
The sequence means are \(\bar D_{\mathrm{TR}}=0.10\) and \(\bar D_{\mathrm{RT}}=0.18\), so the estimated treatment contrast is
The within-sequence sums of squared deviations are \(0.0032\) and \(0.0032\). Each subject difference combines two period residuals, so the corresponding raw ANOVA residual sum of squares is half their total:
Thus \(MS_{\mathrm{Residual}}=0.0032/6=0.0005333\). The standard error is \(\sqrt{0.0005333/4}=0.01155\), and
The result is statistically inconsistent with \(H_0:\tau=0\) at the 0.05 level (indeed, \(p<0.001\)). The estimate is a log difference; exponentiating gives an estimated T-to-R ratio of \(e^{0.14}=1.150\). This example illustrates the calculation, not evidence from an actual study.
Degrees of Freedom Are Not the Number of Measurements
A tempting but incorrect calculation counts all the period measurements as independent observations. For \(n\) subjects in each of two sequences, there are \(4n\) measurements, but each subject contributes a pair. The treatment contrast is informed by variation across the \(2n\) subject-level differences, after accounting for the two sequence-specific means. That is why the residual degrees of freedom are \(2n-2\), not a count based on \(4n\) independent observations.
Worked Example: Checking the Denominator Degrees of Freedom
A hypothetical balanced study has eight subjects in each sequence. Each subject completes two periods, giving 16 subjects and 32 measurements. For the treatment test, the correct residual degrees of freedom are
A two-sample analysis that treated the 16 T measurements and 16 R measurements as independent might use \(16+16-2=30\) degrees of freedom. That number does not account for the within-subject pairing, period, or sequence structure, so it is not the denominator degrees of freedom for this crossover ANOVA. The problem is not repaired by having 32 measurements: the design still contains 16 subjects, each measured twice.
Practical Calculation and Alternatives
For a complete balanced study, the treatment test can be understood either through the ANOVA table or through the subject-level differences. In the difference view, estimate the treatment contrast by averaging the two sequence means, estimate the residual variation from within-sequence scatter, and use \(2n-2\) denominator degrees of freedom. This is equivalent to the treatment test from the classical balanced crossover ANOVA when the same model and assumptions are used.
| Approach | What it accounts for | Relevance to this test |
|---|---|---|
| Balanced crossover ANOVA | Sequence, period, treatment, and subjects nested within sequence | Uses residual mean square with \(2n-2\) denominator degrees of freedom for treatment |
| Subject-level differences | Within-subject T-versus-R contrasts and the two sequence patterns | Gives the same treatment test under the balanced model |
| Independent two-sample comparison | Compares treatment-labelled measurements as if each came from a different subject | Does not represent the crossover dependence or its ANOVA error term |
The assumptions should be checked against the design and data before relying on this test. Confirm that both periods are observed for each included subject, that the sequence allocation is balanced as specified, and that the treatment and period effects can reasonably be represented additively. Residual summaries can help reveal unusual observations or markedly different scatter, but no diagnostic can establish the absence of carryover or repair a design that does not support the model.
The result is specific to a complete, balanced, two-period crossover with the stated model. Missing periods, unequal sequence sizes, or a different covariance structure can change the estimation and degrees of freedom; the formula \(2n-2\) should not be transferred automatically to those settings. In particular, do not substitute the subject-within-sequence mean square simply because it appears in the ANOVA table: that term concerns between-subject variation, whereas treatment is compared within subjects.
Common Mistake
Worked Example: A Small Balanced Study
In another hypothetical study, three subjects per sequence have log differences \( -0.02, 0.02, 0.00\) for T-then-R and \(0.08, 0.12, 0.10\) for R-then-T. Assume the same complete balanced design and model.
The two sequence means are \(0.00\) and \(0.10\), giving \(\hat{\tau}=(0.00+0.10)/2=0.05\) log units. Each sequence has a squared-deviation sum of \(0.0008\). Therefore,
The standard error is \(\sqrt{0.0002/3}=0.008165\), and the treatment statistic is \(F=3(0.05)^2/0.0002=37.5\), with \(df=(1,4)\). The result is significant at the 0.05 level (\(p<0.01\)). The small denominator degrees of freedom reflect the small number of subjects, even though every subject supplies two measurements.
Check Your Understanding
Answer each question using the balanced two-period model described above.
- If there are six subjects per sequence, what are the treatment test’s numerator and denominator degrees of freedom?
- Which ANOVA mean square tests the treatment contrast: subjects within sequence or residual?
- Why does the subject random effect not contribute to the variance of a within-subject treatment difference?
- What is the treatment contrast estimate if the two sequence mean differences are 0.12 and 0.04 log units?
Solutions. (1) The numerator has 1 degree of freedom and the denominator has \(2(6)-2=10\). (2) Use the residual mean square, because treatment varies within subjects. (3) The same subject effect appears in both period measurements and cancels on subtraction. (4) The estimate is \((0.12+0.04)/2=0.08\) log units; averaging the sequence means removes the additive period effect.