Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Contrasts & Multiple Comparisons

A global ANOVA asks whether all means are equal. Contrasts answer focused questions, and multiple-comparison procedures control error across a family of claims.

The worked examples continue the one-way ANOVA example: A, B, and C have means 6, 8, and 11, with four observations each, MSE=2/3MSE=2/3, and 9 residual degrees of freedom.

Contrasts: Focused Questions About Means

A contrast is a linear combination

C=∑i=1mciμi,∑ici=0.C=\sum_{i=1}^m c_i\mu_i,\qquad\sum_i c_i=0.

The zero-sum condition removes the overall level, leaving a comparison.

Question for A, B, CCoefficients (cA,cB,cC)(c_A,c_B,c_C)
A minus B(1,−1,0)(1,-1,0)
C minus the average of A and B(−1/2,−1/2,1)(-1/2,-1/2,1)
Linear trend across three equally spaced levels(−1,0,1)(-1,0,1)
Curvature across three equally spaced levels(1,−2,1)(1,-2,1)

Under the independent common-variance one-way model,

C^=∑iciYˉi⋅,SE⁡(C^)=MSE∑ici2ni.\widehat C=\sum_i c_i\bar Y_{i\cdot},\qquad \operatorname{SE}(\widehat C)=\sqrt{MSE\sum_i\frac{c_i^2}{n_i}}.
TC=C^−C0SE⁡(C^)∼tN−munder H0:C=C0.T_C=\frac{\widehat C-C_0}{\operatorname{SE}(\widehat C)}\sim t_{N-m} \quad\text{under }H_0:C=C_0.

An individual two-sided confidence interval is

C^±t1−α/2,N−mSE⁡(C^).\widehat C\pm t_{1-\alpha/2,N-m}\operatorname{SE}(\widehat C).

For testing C=0C=0, define

SSC=C^2∑ici2/ni,FC=SSCMSE=TC2∼F1,N−m.SS_C=\frac{\widehat C^2}{\sum_i c_i^2/n_i},\qquad F_C=\frac{SS_C}{MSE}=T_C^2\sim F_{1,N-m}.

Here SSCSS_C denotes a contrast sum of squares, not the total condition sum of squares.

Orthogonal & Polynomial Contrasts

Two contrast estimates have covariance

Cov⁡(C^,D^)=σ2∑icidini.\operatorname{Cov}(\widehat C,\widehat D)=\sigma^2\sum_i\frac{c_i d_i}{n_i}.

They are orthogonal when ∑icidi/ni=0\sum_i c_i d_i/n_i=0. With equal group sizes this reduces to ∑icidi=0\sum_i c_i d_i=0. There are at most m−1m-1 mutually orthogonal nonzero contrasts. A full orthogonal set partitions treatment SS.

For equally spaced numeric levels and equal replication:

Number of levelsLinearQuadraticCubic
3(−1,0,1)(-1,0,1)(1,−2,1)(1,-2,1)
4(−3,−1,1,3)(-3,-1,1,3)(1,−1,−1,1)(1,-1,-1,1)(−1,3,−3,1)(-1,3,-3,1)

Polynomial contrasts describe trends for quantitative levels. They do not imply a meaningful trend among arbitrary category names. Unequal spacing or replication requires coefficients and orthogonality checks appropriate to that design.

A prespecified contrast can be tested directly without first rejecting the global ANOVA. Several planned contrasts still form a testing family when joint error control is intended; planning alone does not eliminate multiplicity.

Multiple Comparisons

With mm means, all pairwise comparisons form a family of

K=(m2)=m(m−1)2K=\binom m2=\frac{m(m-1)}2

tests. The family-wise error rate (FWER) is the probability of at least one false rejection in that family.

If KK null tests were independent and each used level α\alpha,

FWER⁡=1−(1−α)K.\operatorname{FWER}=1-(1-\alpha)^K.

With five means, K=10K=10 and 1−0.9510=0.40131-0.95^{10}=0.4013. This is an illustration under independence, not the exact FWER for overlapping pairwise tests, which are dependent.

The one-way pooled pairwise statistic is

tij=Yˉi⋅−Yˉj⋅MSE(1/ni+1/nj),df=N−m.t_{ij}=\frac{\bar Y_{i\cdot}-\bar Y_{j\cdot}} {\sqrt{MSE(1/n_i+1/n_j)}},\qquad df=N-m.
ProcedureRuleMain qualification
Fisher’s protected LSDAfter global rejection, use ordinary pairwise tt tests.Generally lacks strong FWER control across many groups.
BonferroniTest each of KK hypotheses at α/K\alpha/K; adjusted p=min⁡(1,Kp)p=\min(1,Kp).Controls FWER without requiring independence; can be conservative.
HolmSort pp-values; compare p(j)p_{(j)} to α/(K−j+1)\alpha/(K-j+1), stopping at the first failure.Strong FWER control without independence; at least as powerful as Bonferroni.
ŠidákUse α∗=1−(1−α)1/K\alpha^*=1-(1-\alpha)^{1/K}.Exact family calibration for independent tests; not a universal rule for dependence.
Tukey HSD / Tukey-KramerUse the studentized range distribution for all pairs.Suited to all pairwise mean comparisons under the normal common-variance model.

For Bonferroni two-sided simultaneous intervals,

C^ℓ±t1−α/(2K),νSE⁡(C^ℓ).\widehat C_\ell\pm t_{1-\alpha/(2K),\nu}\operatorname{SE}(\widehat C_\ell).

For Tukey-Kramer pairwise intervals,

Yˉi⋅−Yˉj⋅ ± q1−α;m,νMSE2(1ni+1nj),ν=N−m.\bar Y_{i\cdot}-\bar Y_{j\cdot}\ \pm\ q_{1-\alpha;m,\nu}\sqrt{\frac{MSE}{2}\left(\frac1{n_i}+\frac1{n_j}\right)},\qquad \nu=N-m.

With equal group size nn, the margin simplifies to qMSE/nq\sqrt{MSE/n}. Tukey HSD has exact simultaneous coverage under its balanced normal model; Tukey-Kramer extends the procedure to unequal sizes, generally conservatively.

The cell includes the required ANOVA summaries so it runs independently of the previous page.