core27 min studyLesson 255 in Mathematics

Contrasts, ANOVA, and nested models

Compare nested mean spaces using extra sums of squares and interpret group contrasts without treating significance as an effect size.

On this page

What you’ll understand

  • Express a group comparison as an estimable contrast.
  • Derive the extra-sum-of-squares F statistic for nested designs.
  • Distinguish joint tests, effect sizes, and multiplicity.

Analysis of variance and regression are two descriptions of the same projection geometry. A group model permits a separate mean for each group; a restricted model may require some or all means to coincide. Comparing those nested spaces asks whether the extra directions explain more response variation than the fitted noise scale would reasonably allow. Contrasts specify the scientific comparisons, while an F test can assess several restrictions together. Neither replaces reporting the size and uncertainty of the effects being compared.

A contrast names a scientific comparison

For group means collected in a vector μ, a contrast is a linear combination whose coefficients sum to zero. The difference between two group means is the simplest example. The zero-sum condition makes the comparison unchanged if every group mean shifts by the same amount. More general regression hypotheses use Cβ=dC\beta=d, where the rows of C specify coefficient combinations and d contains their hypothesized values. In a redundant parameterization those combinations must be estimable before an ordinary test has a meaningful target.

The model's parameterization affects coefficient labels but not the fitted group means or valid contrasts. An intercept-plus-indicators coding and a direct group-means coding can describe the same column space. For independent errors with common variance, the variance of a difference of two sample means is σ² times the sum of their reciprocal group sizes. Unequal sample sizes therefore affect precision even though the scientific meaning of the mean difference is unchanged.

ψ=∑j=1gcjμj,∑j=1gcj=0,Var⁡(Y‾a−Y‾b)=σ2(1na+1nb)\psi=\sum_{j=1}^{g}c_j\mu_j,\qquad \sum_{j=1}^{g}c_j=0,\qquad \operatorname{Var}(\overline Y_a-\overline Y_b)=\sigma^2\left(\frac1{n_a}+\frac1{n_b}\right)
The variance formula assumes independent observations with common variance and distinct groups; estimability also requires observations in the groups being compared.↔ Scroll wide equations horizontally.

Extra sums of squares measure an added subspace

Let the reduced design's column space be contained in the full design's column space. Denote their ranks by r and p, with q=p−r positive and n>p. The full residual sum of squares cannot exceed the reduced one, because the full fit can always choose the reduced fit. Their difference is the squared length of the response projected onto the q added orthogonal directions. It is not generally the same as fitting each predictor alone and adding its separate contribution.

Under the null that the true mean belongs to the reduced space, spherical Gaussian errors make that extra sum of squares divided by σ² chi-squared with q degrees of freedom. It is independent of the full-model residual sum of squares, which has n−p degrees of freedom. Dividing the two sums by their respective dimensions removes σ² and gives an exact F statistic. The full model supplies the denominator noise estimate; using the reduced residual there would mix the tested departure into the scale estimate.

F=(SSE⁡R−SSE⁡F)/(p−r)SSE⁡F/(n−p)∼Fp−r,n−punder the reduced Gaussian modelF=\frac{(\operatorname{SSE}_R-\operatorname{SSE}_F)/(p-r)}{\operatorname{SSE}_F/(n-p)}\sim F_{p-r,n-p}\quad\text{under the reduced Gaussian model}
The exact F reference requires nested fixed mean spaces, positive added rank, n>p, and independent equal-variance Gaussian errors. Ranks, not raw column counts, determine dimensions.↔ Scroll wide equations horizontally.

Interpret the comparison at the scale of the question

For one estimable restriction, the corresponding two-sided t statistic squared equals the nested-model F statistic. With several restrictions, the joint F test asks whether at least one tested component departs from the null; it does not identify which component or how large a practically relevant effect is. A small p value can accompany a tiny effect in a very precise experiment, while a wide interval can leave an important effect unresolved in a small experiment.

In unbalanced or nonorthogonal designs, sequential sums of squares can depend on the order in which terms enter. State the actual reduced and full spaces rather than relying on a table label. Testing many response-chosen contrasts introduces multiplicity and selection issues, and observational group differences do not by themselves establish a causal effect. Random assignment, a prespecified comparison, and a model for dependence address different parts of the argument; none follows merely from the ANOVA decomposition.

Two means versus one common mean

Group A has responses (1,3,2)(1,3,2) and group B has (4,6,5)(4,6,5). Compare a common-mean model with a two-group-means model under independent equal-variance Gaussian errors.

  1. The group means are 2 and 5. The full model has rank 2, and its residual sum of squares is (1+1+0)+(1+1+0)=4(1+1+0)+(1+1+0)=4. Its residual degrees of freedom are 6−2=46-2=4.

  2. The pooled mean is 3.5. The between-group contribution is 3(2−3.5)2+3(5−3.5)2=13.53(2-3.5)^2+3(5-3.5)^2=13.5, so the reduced SSE is 4+13.5=17.54+13.5=17.5.

  3. There is one added mean direction. Thus F=(17.5−4)/(4/4)=13.5F=(17.5-4)/(4/4)=13.5, with null reference F1,4F_{1,4}. The estimated difference B−A is 3 with standard error (4/4)(1/3+1/3)=2/3\sqrt{(4/4)(1/3+1/3)}=\sqrt{2/3}.

The result

The squared t statistic for the mean difference is 32/(2/3)=13.53^2/(2/3)=13.5, matching the F statistic. The numerical effect is 3 response units; the reference distribution and its assumptions are separate from that effect size.

Explore the model

Interactive lab

Interactive lab · vectors

Resolve variation into perpendicular pieces

Pause and Reset; set Angle to 45 degrees and Magnitude to 2. Predict equal squared component lengths of 2, then inspect the readouts. Repeat from Reset with Angle=0 and Magnitude=2 to put all squared length in one direction. This two-axis geometry illustrates orthogonal sums of squares; it does not compute ANOVA p values, group means, or residual degrees of freedom.

Resolve variation into perpendicular piecesPlayback traces a fixed vector and its projections. Angle and magnitude set the geometry; the moving marker does not change them. Current readings: x component: 1.393; y component: 0.975; Magnitude: 1.7. All parameters are adjustable with the labeled controls below.−7.46−3.7303.737.46−3.5−1.7501.753.5xyvvₓ = 1.39
Vectorx / y projectionsTrace marker
x component
1.393
y component
0.975
Magnitude
1.7
t = 0 s

Playback traces a fixed vector and its projections. Angle and magnitude set the geometry; the moving marker does not change them. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forA nested-model comparison isolates response length in added mean directions and compares it with a separately estimated noise scale.

Check your understanding

A full model has rank 5 and a nested reduced model has rank 3 with n=20. Which degrees of freedom belong to the exact nested F test?

Try it yourself

A fixed full model of rank 4 has SSE=24 from n=12 observations. A nested rank-2 model has SSE=42. Calculate the F statistic and its null reference degrees of freedom. What does rejecting the reduced model establish?

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

First compute the added rank and the full residual degrees of freedom, then divide each sum of squares by its own dimension.

Compare with the solution

There are 4−2=24-2=2 added directions and 12−4=812-4=8 full-model residual degrees of freedom. The statistic is F=((42−24)/2)/(24/8)=9/3=3F=((42-24)/2)/(24/8)=9/3=3, with F2,8F_{2,8} reference under spherical Gaussian errors and the reduced null. Rejection would indicate that the restrictions collectively conflict with that model; it would not identify a causal mechanism or establish that every added coefficient is nonzero.

Take it with you

  • Contrasts specify comparisons that survive a common mean shift.
  • Nested F tests compare added rank with full-model residual rank.
  • Joint significance, practical size, and causal interpretation answer different questions.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.