Why Expected Mean Squares Matter
An ANOVA table does more than partition variability into named sources. Its expected mean squares show which variance components and fixed effects contribute, on average, to each mean square. Comparing the right pair of mean squares is essential: the treatment statistic must use a denominator that reflects the random variation in the treatment contrast, not simply the largest or most familiar residual term.
In a balanced two-period crossover, each subject receives both treatments, and equal numbers of subjects are assigned to each of the two treatment sequences. A subject’s overall response level can vary substantially between subjects, but that level is shared across the subject’s two periods. It therefore does not contribute to the treatment comparison in the same way as the subject’s period-to-period variation. The expected mean squares make this distinction explicit.
Model and Assumptions
Let \(Y_{jik}\) be the log-scale endpoint for subject \(i\) in sequence \(j\), measured in period \(k\). There are two sequences, TR and RT, and \(n\) subjects in each sequence. Thus there are \(2n\) subjects and \(4n\) observations. Each subject receives treatment T once and treatment R once. Use the additive model
Here \(\mu\) is the overall mean; \(S_j\) is the fixed sequence effect; \(U_{i(j)}\) is the random effect for subject \(i\) within sequence \(j\); \(P_k\) is the fixed period effect; and \(T_{\ell(j,k)}\) is the fixed treatment effect assigned in that sequence and period. The subject effects are independent with mean zero and variance \(\sigma_U^2\). The errors are independent with mean zero and variance \(\sigma^2\), and are independent of the subject effects. The fixed effects use sum-to-zero coding: \(S_1+S_2=0\), \(P_1+P_2=0\), and \(T_T+T_R=0\).
The model assumes equal group sizes, no carryover contribution to the measured response, additive sequence, period, and treatment effects, and a common residual variance. For the exact F tests described here, the random subject effects and residual errors are normally distributed. The balanced design makes sequence, period, and treatment contrasts orthogonal under this model. Serious departures—such as unequal sequence sizes, missing measurements, or treatment-related variance differences—can change the simple mean-square relationships.
ANOVA Sources and Expected Mean Squares
The balanced ANOVA separates the sequence contrast, subject differences within sequence, period contrast, treatment contrast, and the remaining subject-by-period variation. The source “subject(sequence) by period” means variation in a subject’s two-period pattern that remains after accounting for the model’s sequence, period, and treatment terms. It is the treatment-test error term.
| Source | Degrees of freedom | Expected mean square |
|---|---|---|
| Sequence | 1 | \(\sigma^2+2\sigma_U^2+2n\sum_j S_j^2\) |
| Subject within sequence | \(2(n-1)\) | \(\sigma^2+2\sigma_U^2\) |
| Period | 1 | \(\sigma^2+2n\sum_k P_k^2\) |
| Treatment | 1 | \(\sigma^2+2n\sum_{\ell}T_\ell^2\) |
| Subject(sequence) by period | \(2n-2\) | \(\sigma^2\) |
For example, let the treatment contrast be \(\delta=T_T-T_R\). Under sum-to-zero coding, \(T_T=\delta/2\) and \(T_R=-\delta/2\), so \(\sum_\ell T_\ell^2=\delta^2/2\). The treatment EMS is therefore \(\sigma^2+n\delta^2\). Under the null hypothesis \(H_0:\delta=0\), its expectation is \(\sigma^2\), the same as the subject(sequence)-by-period error EMS. This matching of expectations motivates the treatment F ratio.
Why the Treatment Denominator Is Within-Subject Error
A short derivation using subject-level treatment differences shows why the subject effect cancels. Define \(d_{ji}\) as that subject’s log response on T minus the log response on R. The subject’s \(U_{i(j)}\) appears once in each response, so it subtracts out. The period contrast can remain, but its sign is opposite in the two sequences. Write that contrast as \(c\) for TR and \(-c\) for RT. Then
The variance \(2\sigma^2\) follows because \(e_{ji}\) is the difference between two independent residual errors, each with variance \(\sigma^2\). With equal sequence sizes, averaging the two sequence means cancels \(c\) and estimates \(\delta\). The residual sum of squares in the subject-by-period part of the ANOVA can be written
where \(\bar d_j\) is the mean difference in sequence \(j\). Centering within each sequence removes both \(\delta\) and the sequence-specific period contribution. Each centered difference has variance \(2\sigma^2\); multiplying its sum of squares by \(1/2\) gives expected residual sum of squares \((2n-2)\sigma^2\), with \(2n-2\) degrees of freedom. Thus the error mean square has expectation \(\sigma^2\).
By contrast, the mean square for subjects within sequence contains the random subject effect. Its EMS is \(\sigma^2+2\sigma_U^2\). That source describes between-subject differences in overall level, which cancel in the paired treatment difference. It is not the appropriate denominator for testing treatment.
The numerator and denominator have the same expected value under \(H_0\). Under the normality and independence assumptions, the ratio has the stated F distribution. A large value is evidence against equal treatment means on the log scale; it is not evidence that a null hypothesis has a particular probability of being true.
Worked Example: Reading the Treatment EMS
Suppose a hypothetical balanced crossover has \(n=6\) subjects per sequence. For illustration, take \(\sigma_U^2=0.040\), \(\sigma^2=0.010\), and a fixed treatment contrast \(\delta=0.080\) log units. Find the treatment and subject-within-sequence EMS values.
Since \(T_T=\delta/2=0.040\) and \(T_R=-0.040\), the treatment EMS is
The subject-within-sequence EMS is
These different expectations do not make the subject-within-sequence mean square the treatment denominator. The treatment contrast cancels the subject intercept; its relevant error is subject(sequence) by period, whose EMS is \(0.010\ \text{log-unit}^2\). Under \(H_0\), the treatment EMS also reduces to \(0.010\ \text{log-unit}^2\).
Worked Example: Calculating the Treatment and Error Mean Squares
Consider hypothetical subject-level log differences \(d_{ji}=\log(T)-\log(R)\) from \(n=3\) subjects in each sequence. Suppose the TR differences are \(0.10,\ 0.12,\ 0.08\), and the RT differences are \(0.14,\ 0.16,\ 0.12\). Find the treatment estimate, treatment mean square, and subject(sequence)-by-period mean square.
The sequence means are \(0.10\) and \(0.14\). Their average is the balanced treatment estimate, because the period contribution has opposite signs across sequences:
For a one-degree-of-freedom treatment contrast, \(SS_{\mathrm{treatment}}=n\hat{\delta}^{\,2}\). Thus
Within each sequence the differences deviate from their sequence mean by \(0,\ 0.02,\ -0.02\). The within-sequence squared deviations sum to \(0.0008\) for each sequence, or \(0.0016\) in total. The corresponding ANOVA error sum of squares is half this amount:
Its degrees of freedom are \(2n-2=4\), so \(MS_{\mathrm{subject(sequence)\ by\ period}}=0.0008/4=0.000200\ \text{log-unit}^2\). The treatment statistic is \(F=0.0432/0.000200=216\), with 1 and 4 degrees of freedom. The example’s data give a very large statistic; the calculation alone does not establish that real data satisfy the model assumptions.
Using the Denominator Correctly
The next hypothetical ANOVA summary illustrates why the two subject-related mean squares must not be confused. Suppose there are \(n=10\) subjects per sequence, and the fitted table gives \(MS_{\mathrm{treatment}}=0.0120\), \(MS_{\mathrm{subject(sequence)\ by\ period}}=0.00300\), and \(MS_{\mathrm{subject(sequence)}}=0.0280\), all in squared log units. The correct treatment statistic is
At the 5% level, the upper critical value for \(F_{1,18}\) is approximately 4.414. Since \(4.00<4.414\), this statistic does not reject \(H_0\) at \(\alpha=0.05\). Using the subject-within-sequence mean square instead would give \(0.0120/0.0280=0.429\), but that is not the treatment test: the denominator includes between-subject variation that cancels from the within-subject contrast.
Worked Example: Checking Degrees of Freedom and Balance
A hypothetical study has 8 subjects in TR and 8 in RT. Check the residual degrees of freedom and the total degrees of freedom, then consider what happens if one RT subject has no second-period measurement.
With \(n=8\) per sequence, the subject(sequence)-by-period residual degrees of freedom are
The total number of observations is \(4n=32\), so total degrees of freedom are \(32-1=31\). The source degrees of freedom sum to \(1+14+1+1+14=31\), as required.
If one RT subject is missing a period, the data no longer form this complete balanced design: that subject does not provide a two-treatment within-subject contrast. Substituting the reduced observation count into the balanced formulas does not, by itself, produce a valid analysis. The simple EMS table and exact F reference above rely on the stated balanced model; missing-data analysis requires a method that handles the incomplete pattern.
Diagnostics, Comparisons, and Limitations
Before relying on this decomposition, verify that subjects are assigned to both sequences in equal numbers and that each included subject has both period measurements. Check the treatment and period labels against the assigned sequences, since a coding error can reverse or corrupt the paired differences. On the fitted model’s residuals, look for striking non-normality, influential observations, sequence-specific spread, and patterns suggesting that residual variance differs by treatment or period. These checks can reveal model concerns, but a small study has limited ability to diagnose them.
The paired-difference view is a useful way to see the cancellation of the subject intercept and the role of the two sequence means. The ANOVA view makes the full source decomposition and its degrees of freedom explicit. In a complete balanced study, these views agree on the treatment contrast and its within-subject error. The simple ANOVA formulas are less suitable when the data are unbalanced or incomplete; they also depend on the additive model and the absence of carryover. A large sequence mean square is not, on its own, a substitute for checking those assumptions or a reason to change the treatment denominator.
Common Mistakes
- Using subject(sequence) as the treatment denominator. That mean square contains the between-subject variance component \(2\sigma_U^2\). Treatment is a within-subject contrast, so its denominator is subject(sequence) by period.
- Calling the treatment EMS equal to the residual EMS under every condition. They match under \(H_0\); under a nonzero fixed treatment contrast, the treatment EMS also contains \(n\delta^2\).
- Ignoring the sequence balance. Equal sequence sizes allow the period contribution to cancel in the average of the sequence-specific treatment differences. Unequal sizes need not have this simple cancellation.
- Treating an F statistic as the probability that treatments are equal. The F statistic is a ratio of mean squares. Its p-value is calculated under \(H_0\) and the model assumptions; it is not the probability that \(H_0\) is true.
Check Your Understanding
Answer each question, then compare your reasoning with the solutions.
- For \(n=5\) subjects per sequence, what are the degrees of freedom for subject(sequence) by period?
- If \(\sigma^2=0.020\), what is the treatment EMS under \(H_0\)?
- Why does \(\sigma_U^2\) not appear in the treatment-test denominator EMS?
- In a balanced study, the treatment mean square is 0.018 and the subject(sequence)-by-period mean square is 0.006. What is the treatment F statistic?
- Name one condition under which the balanced EMS formulas should not be applied without further analysis.
Solutions. (1) \(2(5-1)=8\). (2) Under \(H_0\), \(E(MS_{\mathrm{treatment}})=\sigma^2=0.020\). (3) The random subject intercept is shared by both of a subject’s observations and cancels when the within-subject treatment difference is formed. (4) \(F=0.018/0.006=3.00\); the degrees of freedom are 1 and \(2(5)-2=8\). (5) Examples include unequal sequence sizes, a missing period measurement, or a model with carryover or nonconstant residual variance.