# 2.5: Contrast Analysis

$$\newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} }$$

$$\newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}}$$

$$\newcommand{\id}{\mathrm{id}}$$ $$\newcommand{\Span}{\mathrm{span}}$$

( \newcommand{\kernel}{\mathrm{null}\,}\) $$\newcommand{\range}{\mathrm{range}\,}$$

$$\newcommand{\RealPart}{\mathrm{Re}}$$ $$\newcommand{\ImaginaryPart}{\mathrm{Im}}$$

$$\newcommand{\Argument}{\mathrm{Arg}}$$ $$\newcommand{\norm}[1]{\| #1 \|}$$

$$\newcommand{\inner}[2]{\langle #1, #2 \rangle}$$

$$\newcommand{\Span}{\mathrm{span}}$$

$$\newcommand{\id}{\mathrm{id}}$$

$$\newcommand{\Span}{\mathrm{span}}$$

$$\newcommand{\kernel}{\mathrm{null}\,}$$

$$\newcommand{\range}{\mathrm{range}\,}$$

$$\newcommand{\RealPart}{\mathrm{Re}}$$

$$\newcommand{\ImaginaryPart}{\mathrm{Im}}$$

$$\newcommand{\Argument}{\mathrm{Arg}}$$

$$\newcommand{\norm}[1]{\| #1 \|}$$

$$\newcommand{\inner}[2]{\langle #1, #2 \rangle}$$

$$\newcommand{\Span}{\mathrm{span}}$$ $$\newcommand{\AA}{\unicode[.8,0]{x212B}}$$

$$\newcommand{\vectorA}[1]{\vec{#1}} % arrow$$

$$\newcommand{\vectorAt}[1]{\vec{\text{#1}}} % arrow$$

$$\newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} }$$

$$\newcommand{\vectorC}[1]{\textbf{#1}}$$

$$\newcommand{\vectorD}[1]{\overrightarrow{#1}}$$

$$\newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}}$$

$$\newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}}$$

$$\newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} }$$

$$\newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}}$$

$$\newcommand{\avec}{\mathbf a}$$ $$\newcommand{\bvec}{\mathbf b}$$ $$\newcommand{\cvec}{\mathbf c}$$ $$\newcommand{\dvec}{\mathbf d}$$ $$\newcommand{\dtil}{\widetilde{\mathbf d}}$$ $$\newcommand{\evec}{\mathbf e}$$ $$\newcommand{\fvec}{\mathbf f}$$ $$\newcommand{\nvec}{\mathbf n}$$ $$\newcommand{\pvec}{\mathbf p}$$ $$\newcommand{\qvec}{\mathbf q}$$ $$\newcommand{\svec}{\mathbf s}$$ $$\newcommand{\tvec}{\mathbf t}$$ $$\newcommand{\uvec}{\mathbf u}$$ $$\newcommand{\vvec}{\mathbf v}$$ $$\newcommand{\wvec}{\mathbf w}$$ $$\newcommand{\xvec}{\mathbf x}$$ $$\newcommand{\yvec}{\mathbf y}$$ $$\newcommand{\zvec}{\mathbf z}$$ $$\newcommand{\rvec}{\mathbf r}$$ $$\newcommand{\mvec}{\mathbf m}$$ $$\newcommand{\zerovec}{\mathbf 0}$$ $$\newcommand{\onevec}{\mathbf 1}$$ $$\newcommand{\real}{\mathbb R}$$ $$\newcommand{\twovec}[2]{\left[\begin{array}{r}#1 \\ #2 \end{array}\right]}$$ $$\newcommand{\ctwovec}[2]{\left[\begin{array}{c}#1 \\ #2 \end{array}\right]}$$ $$\newcommand{\threevec}[3]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \end{array}\right]}$$ $$\newcommand{\cthreevec}[3]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \end{array}\right]}$$ $$\newcommand{\fourvec}[4]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}$$ $$\newcommand{\cfourvec}[4]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}$$ $$\newcommand{\fivevec}[5]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}$$ $$\newcommand{\cfivevec}[5]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}$$ $$\newcommand{\mattwo}[4]{\left[\begin{array}{rr}#1 \amp #2 \\ #3 \amp #4 \\ \end{array}\right]}$$ $$\newcommand{\laspan}[1]{\text{Span}\{#1\}}$$ $$\newcommand{\bcal}{\cal B}$$ $$\newcommand{\ccal}{\cal C}$$ $$\newcommand{\scal}{\cal S}$$ $$\newcommand{\wcal}{\cal W}$$ $$\newcommand{\ecal}{\cal E}$$ $$\newcommand{\coords}[2]{\left\{#1\right\}_{#2}}$$ $$\newcommand{\gray}[1]{\color{gray}{#1}}$$ $$\newcommand{\lgray}[1]{\color{lightgray}{#1}}$$ $$\newcommand{\rank}{\operatorname{rank}}$$ $$\newcommand{\row}{\text{Row}}$$ $$\newcommand{\col}{\text{Col}}$$ $$\renewcommand{\row}{\text{Row}}$$ $$\newcommand{\nul}{\text{Nul}}$$ $$\newcommand{\var}{\text{Var}}$$ $$\newcommand{\corr}{\text{corr}}$$ $$\newcommand{\len}[1]{\left|#1\right|}$$ $$\newcommand{\bbar}{\overline{\bvec}}$$ $$\newcommand{\bhat}{\widehat{\bvec}}$$ $$\newcommand{\bperp}{\bvec^\perp}$$ $$\newcommand{\xhat}{\widehat{\xvec}}$$ $$\newcommand{\vhat}{\widehat{\vvec}}$$ $$\newcommand{\uhat}{\widehat{\uvec}}$$ $$\newcommand{\what}{\widehat{\wvec}}$$ $$\newcommand{\Sighat}{\widehat{\Sigma}}$$ $$\newcommand{\lt}{<}$$ $$\newcommand{\gt}{>}$$ $$\newcommand{\amp}{&}$$ $$\definecolor{fillinmathshade}{gray}{0.9}$$

The paired comparisons discussed in sections 2.2 and 2.3 have the limitation that the comparisons are made only between treatment mean pairs. The contrast analysis procedure can be used to carry out comparisons of a much wider context such as comparisons of treatment level groups or even testing of trends prompting regression modeling to express the response vs. treatment relationship with treatment as a numerical predictor. In the context of a single factor ANOVA model, a linear contrast can be defined as a linear combination of the treatment means such that their numerical coefficients add to zero. Mathematically, a contrast can be represented by... $A = \sum_{i=1}^{T} a_{i} \bar{y}_{i}$ where $$\bar{y}_{1}, \bar{y}_{2}, \ldots, \bar{y}_{T}$$ represent the sample treatment means and $$\sum_{i=1}^{T} a_{i} = 0$$. The quantity $$A$$ is a sample statistic and serves as an estimate for the population contrast $$\sum_{i=1}^{T} a_{i} \mu_{i}$$. By choosing the numerical coefficients appropriately, linear contrasts can be used to make different comparisons among groups of treatment means but not limited to only mean pairs. The table below gives 4 linear contrasts defined in terms of the 3 fertilizer levels F1, F2, F3, and the Control in the greenhouse example.

Table: Greenhouse example contrasts
Ex $$a_1$$ $$a_2$$ $$a_3$$ $$a_4$$ Contrast
1 1 -1 0 0 F1-F2
2 1 1 1 -3 F1+F2+F3-3C
3 1 1 -2 0 F1+F2-2F3
4 0 1 -1 0 F2-F3

Notice that values of each list of $$a_{i}$$ ($$i = 1,2,3,4$$) add to zero. The first contrast compares the first two fertilizer types in terms of their means, and the second compares the means of the 3 fertilizer types with the Control mean. The third is a comparison between the combined effect of fertilizer types 1 and 2 with fertilizer type 3, while the last contrast compares the second and third fertilizer types.

A pair of contrasts $$A = \sum_{i=1}^{T} a_{i} \bar{y}_{i}$$ and $$B = \sum_{i=1}^{T} b_{i} \bar{y}_{i}$$ is orthogonal if the products of their numerical coefficients add to zero. This can be expressed mathematically as $\sum_{i=1}^{T} a_{i} b_{i} = 0$

A set of contrasts is said to be orthogonal if every pair of contrasts in the set is orthogonal. Two orthogonal contrasts are not correlated which means that if $$A$$ and $$B$$ are orthogonal, then $$\text{Covariance} (A, B) = 0$$. Furthermore, the sum of squares of the treatment usually displayed in the ANOVA table can be partitioned into a set of ($$T-1)$$ orthogonal contrasts each with 1 degree of freedom. Note that the maximal number of orthogonal contrasts associated with a treatment of $$T$$ levels is $$(T-1)$$ and each of them would be associated with one specific comparison independent of each other. In the table above, contrasts 1, 2, and 3 form an orthogonal set of contrasts and contrast 4 cannot be admitted into this set.

The statistical significance of a linear contrast, which can be equated to testing for the zero contrast value can be formulated using the null and alternative hypotheses: $H_{0}: \ \sum_{i=1}^{T} a_{i} \mu_{i} = 0 \text{ vs. } H_{A}: \ \sum_{i=1}^{T} a_{i} \mu_{i} \neq 0$ and can be tested using either,

$t = \dfrac{\sum_{i=1}^{T} a_{i} \bar{y}_{i}}{\sqrt{\text{MSE} \sum_{i=1}^{T} \frac{a_{i}^{2}}{n_{i}}}} \text{ with } (N-T) \text{ degrees of freedom}$ $\text{or} \nonumber$ $F = \frac{\left(\sum_{i=1}^{T} a_{i} \bar{y}_{i} \right)^{2}}{\text{MSE} \sum_{i=1}^{T} \frac{a_{i}^{2}}{n_{i}}}$

with numerator and denominator degrees of freedom equal to $$1$$ and $$(N-T)$$ respectively.

Note that MSE can be obtained from the ANOVA table. Applying the above formula, the $$t$$-statistic for testing contrast 2 above is... $t = \frac{\sum_{i=1}^{T} a_{i} \bar{y}_{i}}{\sqrt{\text{MSE} \sum_{i=1}^{T} \frac{a_{i}^{2}}{n_{i}}}} = \frac{28.6 + 25.867 + 29.2 + (3 * 21)}{3.052 \times \sqrt{\frac{(1+1+1+9)}{6}}} = 8.365$

with $$df=20$$ and has a $$p$$-value of .0028, indicating that the average plant height due to the combined treatment of the 3 fertilizer types differs significantly from the average plant height yielded by the control.

The above testing procedure is applicable to non-orthogonal contrasts as well. But, as non-orthogonal contrasts are not guaranteed to be uncorrelated, the conclusions arrived at may be "overlapping" and lead to redundancies. In Chapter 3, examples are provided to illustrate how software can be used to conduct contrast testing. The hypothesis testing for trends using contrasts will be discussed in Chapter 10: ANCOVA II.

This page titled 2.5: Contrast Analysis is shared under a CC BY-NC 4.0 license and was authored, remixed, and/or curated by Penn State's Department of Statistics via source content that was edited to the style and standards of the LibreTexts platform.