Tutorials › Bioavailability and Bioequivalence › Choosing the Treatment-Test Error Term and Degrees of Freedom

Log-Scale Analysis and ANOVA · Tutorial 184 of 399

Choosing the Treatment-Test Error Term and Degrees of Freedom

Identify the correct error term and denominator degrees of freedom for a treatment contrast in a balanced two-period crossover ANOVA.

Intermediate 12 min read

What You'll Learn

  • Specify the balanced two-period crossover model and its key assumptions.
  • Derive the treatment contrast from the two sequence-specific subject differences.
  • Identify the residual mean square used to test treatment and explain why it is the right error term.
  • Calculate the treatment test’s denominator degrees of freedom and standard error.
  • Distinguish the crossover analysis from an independent-observations analysis.
  • Recognize design and data features that make the standard test inappropriate.

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.

Definition: In a balanced two-period crossover, each of two sequences has \(n\) subjects; each subject completes both periods and receives each treatment once. The treatment-test error term is the residual mean square that estimates the within-subject residual variance used to test the treatment contrast.

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

$$ Y_{ijk}=\mu+S_i+U_{j(i)}+P_k+T_{l(i,k)}+\varepsilon_{ijk}. $$

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

$$ E(\bar D_{\mathrm{TR}})=\tau-(P_2-P_1), \qquad E(\bar D_{\mathrm{RT}})=\tau+(P_2-P_1). $$

Averaging these means removes the period effect and estimates treatment:

$$ \hat{\tau}=\frac{\bar D_{\mathrm{TR}}+\bar D_{\mathrm{RT}}}{2}. $$

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,

$$ \operatorname{Var}(\hat{\tau}) =\frac{1}{4}\left(\frac{2\sigma^2}{n}+\frac{2\sigma^2}{n}\right) =\frac{\sigma^2}{n}. $$

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

$$ F=\frac{MS_{\mathrm{Treatment}}}{MS_{\mathrm{Residual}}} =\frac{n\hat{\tau}^{\,2}}{MS_{\mathrm{Residual}}} \sim F_{1,\,2n-2} \quad\text{under }H_0:\tau=0. $$

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

$$ \hat{\tau}=(0.10+0.18)/2=0.14\text{ log units}. $$

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:

$$ SS_{\mathrm{Residual}}=\frac{0.0032+0.0032}{2}=0.0032, \qquad df_{\mathrm{Residual}}=2(4)-2=6. $$

Thus \(MS_{\mathrm{Residual}}=0.0032/6=0.0005333\). The standard error is \(\sqrt{0.0005333/4}=0.01155\), and

$$ F=\frac{4(0.14)^2}{0.0005333}=147.0,\qquad df=(1,6). $$

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

$$ df_{\mathrm{Residual}}=2n-2=2(8)-2=14. $$

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.

ApproachWhat it accounts forRelevance to this test
Balanced crossover ANOVASequence, period, treatment, and subjects nested within sequenceUses residual mean square with \(2n-2\) denominator degrees of freedom for treatment
Subject-level differencesWithin-subject T-versus-R contrasts and the two sequence patternsGives the same treatment test under the balanced model
Independent two-sample comparisonCompares treatment-labelled measurements as if each came from a different subjectDoes 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

Common mistake: “There are 32 measurements, so I can use an independent-samples test with about 30 error degrees of freedom.” This treats two observations from the same subject as independent and ignores the crossover’s period and sequence structure. Use the residual mean square for the treatment contrast and \(2n-2\) denominator degrees of freedom in the complete balanced design. Ignoring the pairing does not always make the standard error smaller; the direction of the error depends on the covariance and variance structure. The analysis is invalid because its assumed sampling structure is wrong, not because its result must err in one particular direction.

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,

$$ SS_{\mathrm{Residual}}=\frac{0.0008+0.0008}{2}=0.0008, \qquad df_{\mathrm{Residual}}=2(3)-2=4, \qquad MS_{\mathrm{Residual}}=0.0008/4=0.0002. $$

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.

  1. If there are six subjects per sequence, what are the treatment test’s numerator and denominator degrees of freedom?
  2. Which ANOVA mean square tests the treatment contrast: subjects within sequence or residual?
  3. Why does the subject random effect not contribute to the variance of a within-subject treatment difference?
  4. 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.