Linear Contrasts

Canonical reference: Maxwell, Delaney, & Kelley (MDK) ref/mdk

A significant omnibus test says the group means are not all equal, but it does not say where the differences lie. Most research questions are more specific than the omnibus hypothesis: does one treatment differ from another, or does the average of two treatments differ from a control? A contrast expresses any such question as a statement about a weighted combination of group means and provides a single test, interval, and effect size for it. This page develops the machinery for one contrast at a time; testing several contrasts raises the risk of false positives, which is the subject of Multiple Comparisons. For the contrast representation of factorial main effects and interactions, see Factorial ANOVA; for simple effects and marginal-mean follow-ups, see Factorial ANOVA Follow-Up Tests. For within-person contrast scores and comparison-specific error estimates, see Repeated-Measures Comparisons.

Throughout, is observation in group of groups, is the sample size in group , , is the group mean, and is the mean square within groups from the one-way analysis.

Pairwise and complex comparisons

An individual comparison tests one hypothesis about the group means. Two kinds cover most questions:

  • A pairwise comparison involves two means, , or equivalently .
  • A complex comparison involves more than two means, for example , which asks whether the average of groups 1 and 2 equals the mean of group 3.

Both are questions the omnibus test cannot answer: the omnibus null aggregates all differences into one test, so rejecting it does not locate any particular difference. Retaining it does not rule out a specific difference either: the omnibus spends its numerator degrees of freedom across every direction of mean difference, so it can miss a difference concentrated along one comparison that a focused contrast would detect. Planned contrasts therefore need not be contingent on a significant omnibus result; they test the hypotheses the study was designed to ask.

Contrast coefficients

A contrast is a linear combination of population means whose coefficients sum to zero:

The zero-sum condition is what makes a comparison: it guarantees that a constant added to every mean leaves unchanged, so reflects differences among the means rather than their overall level. The null hypothesis for any contrast is .

With four groups, representative questions and their coefficients are:

Question about the meansCoefficients
Group 2 vs. group 4
Average of groups 1 and 3 vs. group 4
Average of groups 1 and 2 vs. average of groups 3 and 4

Choosing a scaling

The coefficients of a contrast are determined by the question only up to a constant multiple: and state the same null hypothesis. The scaling is not arbitrary in practice, because it sets the units of every interpreted quantity. A useful convention normalizes the coefficients so that the positive ones sum to and the negative ones sum to ; is then an average difference of means. Multiplying all coefficients by multiplies the estimate, the standard error, and the confidence-interval endpoints by , while the sum of squares, the test statistic, and the decision are unchanged. The standardized-effect formula below assumes the normalized scaling; other scalings require a corresponding adjustment, so normalization should precede interpretation.

Multiplying by a negative constant also leaves the test unchanged. Reversing every sign negates and the confidence-interval endpoints (so becomes ), while the standard error, , and are untouched: the standard error depends on squared coefficients and the test on the squared estimate. Sign reversal changes only the direction in which the comparison is stated, so coefficients can be oriented to make the reported difference positive without altering the inference.

Estimating a contrast

The contrast is estimated by replacing population means with sample means:

with standard error, under the equal-variance assumption,

A running example uses three groups with : two active treatments with means and , and a control with mean , with and . For the comparison of the average active-treatment mean to the control mean,

so the average of the two active-treatment means is estimated to fall points below the control mean. For the pairwise comparison of the two active treatments, gives .

The restricted-model view

The same test can be derived as a comparison between two models, a perspective developed generally in Model Comparison. The full model allows each group its own population mean, , and its error is the within-group sum of squares, . The restricted model imposes on those means. Its predictions are the fitted values that minimize the total squared error subject to :

  • For a pairwise comparison, the two compared groups share their pooled mean ( for means and with equal ), and every other group keeps its own mean.
  • For a complex comparison, every group with a nonzero coefficient shifts. In the example the constrained predictions are , , and , which satisfy but reproduce none of the raw group means.

The increase in squared error measures how badly the restriction fits: in the example. Counting parameters gives the degrees of freedom: the full model estimates means, so , and one linear restriction removes exactly one parameter, so and the numerator of the test always has

degree of freedom. A single-df restriction is what allows the same comparison to be framed as either an test or a test. The count has a direct intuition: under one linear restriction, means can still vary freely, but the restriction then determines the remaining mean. With and three groups, for instance, and can be anything, but is then forced to equal their average — only two of the three means are free. How this one-numerator-df-per-restriction bookkeeping runs through every test and correction procedure is tabulated in Crosswalk of ANOVA Quantities.

The full model here is the same full model the omnibus test uses. The full model is fixed by the design, not by the hypothesis: whichever comparison is tested, every group keeps its own mean, and the hypothesis enters only through the restriction. When a comparison involves two of three groups, the third group’s mean remains free, yet its within-group variability still contributes to , so the error estimate rests on all residual degrees of freedom rather than only on the groups named in the coefficients. What separates a single comparison from the omnibus test is the restriction alone: the omnibus null ties all means together, while a contrast imposes one linear restriction on them. With only two groups the two restrictions coincide — tying two means together is tying all means together — and the single pairwise comparison is the omnibus test.

Two consequences follow when several comparisons are made on one design. First, is identical for every comparison, because the full model never changes; differs from comparison to comparison, because each restriction fits different predictions — pooling two means for a pairwise test, shifting several means for a complex one. Second, using all groups in rather than only the compared groups is what makes the single-comparison test more powerful than an analysis of just those groups, provided variances are equal: both error estimates target the same population error variance, but the pooled estimate uses more degrees of freedom and is therefore more stable, so the resulting varies less from sample to sample.

Testing a contrast

The error increase has a closed form that avoids fitting the restricted model:

with and degrees of freedom, and equivalently

With only two groups, a pairwise contrast reduces to the pooled independent-samples test (t Tests). With more groups, the same form uses pooled across all groups; the contrast machinery also accommodates any weighting of the means.

In the running example, , so

The of exceeds the critical value : the data provide evidence that the average of the two active-treatment means differs from the control mean. The pairwise contrast between the two active treatments gives and , which does not exceed the critical value.

Confidence intervals

A confidence interval for follows the estimate-plus-minus-margin pattern (Confidence Intervals):

where the two-tailed critical value and the square root of the critical value coincide. For the complex contrast,

an interval of average active-treatment means to points below the control mean. The interval contains zero exactly when the test retains , but the interval adds what the decision alone hides: for the retained pairwise contrast, — a difference as large as points favoring the first treatment, or points favoring the second, remains compatible with the data. The retained null is therefore a statement of imprecision, not evidence that the two treatments are equivalent.

Unequal sample sizes

The formulas already accommodate unequal through the term: the same contrast estimated from differently sized groups has a different standard error and therefore a different test statistic. With and group sizes , , and ,

smaller than the equal- value . Adding observations to any group with a nonzero coefficient can only shrink the standard error, and the shrinkage is largest for groups with large . What can raise it is reallocating a fixed total sample size toward groups with small coefficients and away from groups with large ones. The coefficient pattern should still follow the substantive question — matching group sizes to the comparison of interest is a design decision, not a computational one.

Unequal variances

pools within-group variance across all groups, including groups whose means are not involved in the contrast. This makes individual contrasts more sensitive to unequal variances than the omnibus test, and equal sample sizes give less protection here than they do for the omnibus: a group outside the comparison can distort the standard error in either direction. If an excluded group’s variance is much smaller than those involved, pooling underestimates the standard error and inflates the Type I error rate; if it is much larger, pooling overestimates the standard error and costs power.

When population variances may differ, each group’s variance can be used separately, generalizing Welch’s approach (t Tests):

with approximate (Satterthwaite) denominator degrees of freedom best obtained from software. Only groups with nonzero coefficients contribute, so groups excluded from the comparison no longer contaminate the standard error.

Effect sizes

Standardized difference. With normalized coefficients, the contrast can be expressed in within-group standard deviation units:

For the complex contrast, : the average active-treatment mean falls about two within-group standard deviations below the control mean. The normalization requirement is substantive — under the scaling the same data would give , which no longer measures an average mean difference.

Association strength. Two proportions locate the contrast in the overall variance decomposition:

The alerting proportion measures how much of the between-group variability the contrast captures; the effect-size proportion uses the total variability, adding within-group variability to the denominator. For the example, while : nearly all of the systematic group variation rides on this one contrast, yet it accounts for only about half of the total variation because half of the total is within-group variation. The two numbers answer different questions and can diverge widely, so the denominator, not the numerator, deserves attention when comparing them. See Effect Sizes for the general framework.

Orthogonality

With group means there are at most linearly independent contrasts — the zero-sum condition discards one dimension — so any larger set contains redundancy. Linear independence is not the same as orthogonality: the contrasts and are independent yet share , so both change when changes.

Two contrasts are orthogonal when they carry nonoverlapping information about the mean differences. The check multiplies the two coefficient vectors element by element within each group and sums:

In the running example the pairwise and complex contrasts are orthogonal: . Under equal sample sizes, the sums of squares of a set of mutually orthogonal contrasts partition — here — so orthogonal contrasts decompose the omnibus test into independent single-df pieces, each spending its own degree of freedom on a separate question.

The partition also fixes the relationship among the test statistics. With a complete set of orthogonal contrasts, the omnibus is the average of the contrast statistics:

The running example gives , exactly the omnibus . This averaging is the arithmetic behind the omnibus test’s blindness to localized differences: evidence concentrated in one contrast is diluted by the other contrasts in the average, which is why a focused contrast can reject when the omnibus test does not. This economy is the appeal of orthogonal contrasts.

Nonorthogonal contrasts break the additive bookkeeping. Contrasts that share means count some of the same between-group variability more than once, so their sums of squares need not add to and can exceed it. Comparing each active treatment separately to the control in the running example — and , not orthogonal because — gives and , totaling . Their values likewise sum to : more than of between-group variability appears “explained” because the active-versus-control variation is counted twice. Association strengths can therefore be summed only across a complete orthogonal set, where they total exactly ; across a nonorthogonal set each proportion must be reported on its own. None of this is an argument against nonorthogonal contrasts: substantive questions frequently imply them, and a research question should be tested with the coefficients it implies rather than bent toward orthogonality.

What a single contrast establishes

A rejected contrast supports exactly the comparison its coefficients define — no more. Three limits matter in practice:

  • Rejecting a complex contrast does not localize the difference. Concluding that the average of the two active-treatment means differs from the control does not establish that each active treatment individually differs from the control; the average could conceal one null treatment and one strong one. Testing the individual comparisons requires their own contrasts.
  • A retained null is not evidence of equality. The pairwise contrast was retained with a confidence interval spanning ; imprecision, not equivalence, is the honest reading.
  • Each test carries its own error rate. The formulas on this page describe a single comparison tested once. When several contrasts are tested, the chance of at least one false positive grows, and procedures such as Bonferroni, Tukey, and Scheffé trade power for that control — see Multiple Comparisons.