Tutorials › Statistical Theory III - Theories of Inference, Multivariate Methods, and Contingency Tables › Interaction Sums of Squares in Balanced Factorials

Cochran's Theorem and Sums-of-Squares Decompositions · Tutorial 214 of 972

Interaction Sums of Squares in Balanced Factorials

Learn to isolate interaction variation in a balanced two-way factorial layout, calculate its sum of squares, and determine its degrees of freedom from the projection space.

Intermediate 11 min read

What You'll Learn

  • Define the interaction subspace for a balanced two-way factorial layout
  • Calculate interaction effects from cell, row, column, and grand means
  • Prove that the interaction projection is orthogonal to the grand mean and both main effects
  • Derive the interaction projection's rank as the interaction degrees of freedom
  • Compute interaction sums of squares in replicated and unreplicated examples
  • Recognize why balance is essential to this simple orthogonal decomposition

Why Isolate Interaction Variation?

In a two-factor experiment, an additive description says that the response can be accounted for by a grand mean, an effect for each level of factor A, and an effect for each level of factor B. An interaction is the part of the cell pattern left over: it records departures from that additive description. In a balanced layout, those parts can be represented by an orthogonal projection, so their sum of squares has a direct geometric meaning.

Assume factor A has \(a\) levels, factor B has \(b\) levels, and each of the \(ab\) cells has \(r\) observations, where \(a,b\geq 2\) and \(r\geq 1\). Write the observations as \(y_{ijk}\), for \(i=1,\ldots,a\), \(j=1,\ldots,b\), and \(k=1,\ldots,r\). The balanced replication is important: each cell mean is based on the same number of observations.

Definition: The interaction effect in cell \((i,j)\) is \( \hat{\gamma}_{ij}=\bar{y}_{ij.}-\bar{y}_{i..}-\bar{y}_{.j.}+\bar{y}_{...} \), where \(\bar{y}_{ij.}\) is the mean in cell \((i,j)\), \(\bar{y}_{i..}\) is the mean for level \(i\) of A, \(\bar{y}_{.j.}\) is the mean for level \(j\) of B, and \(\bar{y}_{...}\) is the grand mean. The interaction sum of squares is \( SS_{AB}=r\sum_{i=1}^{a}\sum_{j=1}^{b}\hat{\gamma}_{ij}^{\,2} \).

The factor \(r\) appears because the estimated interaction effect is repeated for all \(r\) observations in its cell. The interaction effects have zero row sums and zero column sums: summing them across either factor removes the corresponding main-effect and grand-mean terms. Those constraints express precisely what it means for the interaction to contain no grand-mean or main-effect component.

The Interaction Projection

Treat the full data vector \(y=(y_{ijk})\) as an element of \(\mathbb{R}^{abr}\), with the usual inner product given by the sum of products over observations. Let \(\mathcal{U}_{AB}\) be the subspace of vectors that are constant within each cell, with cell values \(\gamma_{ij}\) satisfying \( \sum_j\gamma_{ij}=0 \) for every \(i\), and \( \sum_i\gamma_{ij}=0 \) for every \(j\). Such vectors are orthogonal to the grand-mean space and to each of the two main-effect spaces.

The interaction projection of the data is the vector whose entry for every observation in cell \((i,j)\) is \(\hat{\gamma}_{ij}\). To see why, first note the margin constraints. For a fixed \(i\), \( \sum_j\hat{\gamma}_{ij}=\sum_j\bar{y}_{ij.}-b\bar{y}_{i..}-\sum_j\bar{y}_{.j.}+b\bar{y}_{...}=0 \). Here \(\sum_j\bar{y}_{ij.}=b\bar{y}_{i..}\) and \(\sum_j\bar{y}_{.j.}=b\bar{y}_{...}\). The column sums are zero by the same calculation with \(i\) and \(j\) exchanged. Thus the proposed vector belongs to \(\mathcal{U}_{AB}\).

Theorem: The vector with entries \(\hat{\gamma}_{ij}\), repeated across the \(r\) observations in cell \((i,j)\), is the orthogonal projection of \(y\) onto \(\mathcal{U}_{AB}\). Its squared length is \(SS_{AB}=r\sum_{i,j}\hat{\gamma}_{ij}^{\,2}\), and the rank of this projection is \((a-1)(b-1)\).

To prove the projection claim, let \(z\) be any vector in \(\mathcal{U}_{AB}\), with cell values \(\gamma_{ij}\). The inner product of \(y-\hat{\gamma}\) with \(z\) is \( r\sum_{i,j}(\bar{y}_{ij.}-\hat{\gamma}_{ij})\gamma_{ij} \). By the definition of \(\hat{\gamma}_{ij}\), the difference in parentheses is \(\bar{y}_{i..}+\bar{y}_{.j.}-\bar{y}_{...}\). Therefore the inner product equals \(r\sum_{i,j}(\bar{y}_{i..}+\bar{y}_{.j.}-\bar{y}_{...})\gamma_{ij}\). The first term is zero because \(\sum_j\gamma_{ij}=0\); the second is zero because \(\sum_i\gamma_{ij}=0\); and the grand-mean term is zero because either set of margin constraints implies \(\sum_{i,j}\gamma_{ij}=0\). Thus \(y-\hat{\gamma}\) is orthogonal to every vector in \(\mathcal{U}_{AB}\). Since \(\hat{\gamma}\) itself belongs to that subspace, it is the orthogonal projection. Its squared length is the sum of its \(abr\) entries squared, which is \(r\sum_{i,j}\hat{\gamma}_{ij}^{\,2}\). \(\square\)

Why the Interaction Rank Has This Form

A cell pattern has \(ab\) entries before imposing constraints. The row- and column-sum conditions are not \(a+b\) independent restrictions: the sum of all row sums must equal the sum of all column sums. There is exactly one such redundancy, leaving \(a+b-1\) independent restrictions.

For completeness, these constraints have rank \(a+b-1\). The map taking a cell matrix to its \(a\) row sums and \(b\) column sums has outputs whose two grand totals agree, so its rank is at most \(a+b-1\). It attains that rank: for any proposed row sums \(u_i\) and column sums \(v_j\) with \(\sum_i u_i=\sum_j v_j\), one can set entries \(\gamma_{ij}=0\) for \(i<a,j<b\), set \(\gamma_{i b}=u_i\) for \(i<a\), set \(\gamma_{a j}=v_j\) for \(j<b\), and set \(\gamma_{ab}=u_a-\sum_{j<b}v_j\). The resulting matrix has exactly the proposed margins. Hence the margin map has rank \(a+b-1\), and its kernel—the interaction cell patterns—has dimension \(ab-(a+b-1)=(a-1)(b-1)\).

Repeating each cell value \(r\) times does not change the dimension: it embeds each interaction pattern into the observation space without adding new free choices. Therefore the interaction projection has rank \((a-1)(b-1)\). In a Gaussian sums-of-squares decomposition, this rank is the interaction degrees of freedom. It is determined by the number of independent interaction patterns, not by the number of observations in each cell.

Worked Calculations

Worked Example: A Replicated Two-by-Two Layout

Suppose each cell has two observations, with data arranged as follows:

Cell \((1,1)\): 9, 11; cell \((1,2)\): 13, 15; cell \((2,1)\): 12, 14; cell \((2,2)\): 14, 16. The cell means are \(10,14,13,15\), respectively.

The row means are \(\bar{y}_{1..}=12\) and \(\bar{y}_{2..}=14\). The column means are \(\bar{y}_{.1.}=11.5\) and \(\bar{y}_{.2.}=14.5\), and the grand mean is \(\bar{y}_{...}=13\). Thus the interaction effects are \( \hat{\gamma}_{11}=10-12-11.5+13=-0.5 \), \( \hat{\gamma}_{12}=14-12-14.5+13=0.5 \), \( \hat{\gamma}_{21}=13-14-11.5+13=0.5 \), and \( \hat{\gamma}_{22}=15-14-14.5+13=-0.5 \).

Each row sum and each column sum is zero. Since \(r=2\), the interaction sum of squares is \( SS_{AB}=2[(-0.5)^2+(0.5)^2+(0.5)^2+(-0.5)^2]=2(1)=2 \). The rank is \((2-1)(2-1)=1\), so there is one independent interaction direction.

Worked Example: A Three-by-Two Layout

Consider one observation per cell, with rows \((4,6)\), \((7,5)\), and \((9,8)\). The row means are \(5,6,8.5\); the column means are \(20/3,19/3\); and the grand mean is \(39/6=6.5\).

Applying the interaction formula gives the first-row effects \(-7/6,7/6\), the second-row effects \(5/6,-5/6\), and the third-row effects \(1/3,-1/3\). For example, \( \hat{\gamma}_{11}=4-5-20/3+6.5=-7/6 \), and \( \hat{\gamma}_{31}=9-8.5-20/3+6.5=1/3 \). The other four entries follow by the same substitution.

The row sums and column sums are zero. The sum of squared effects is \( (49+49+25+25+4+4)/36=156/36=13/3 \). Here \(r=1\), so \(SS_{AB}=13/3\). The rank is \((3-1)(2-1)=2\), matching the two independent interaction directions.

Worked Example: Separating an Additive Pattern from Interaction

Take the two-by-three cell pattern with rows \((2,5,4)\) and \((6,5,10)\), with one observation per cell. The row means are \(11/3\) and \(7\); the column means are \(4,5,7\); and the grand mean is \(16/3\).

The first-row interaction effects are \(2-11/3-4+16/3=-1/3\), \(5-11/3-5+16/3=5/3\), and \(4-11/3-7+16/3=-4/3\). The second-row effects are \(1/3,-5/3,4/3\). Each row and column sums to zero, as required.

The interaction sum of squares is \(SS_{AB}=2[(1+25+16)/9]=84/9=28/3\). The rank is \((2-1)(3-1)=2\). By contrast, if the cell values had exactly the form “grand mean plus a row effect plus a column effect,” every \(\hat{\gamma}_{ij}\) would be zero and the interaction sum of squares would vanish.

Interpretation and a Common Pitfall

The interaction sum of squares measures the squared length of the component that is orthogonal to the grand mean and both main-effect spaces. It is not simply the variation among cell means: cell means also contain grand-mean and main-effect variation. The formula subtracts those additive components before measuring the remaining pattern.

Under independent normal errors with common variance, the interaction projection is one of the orthogonal components in the Gaussian sums-of-squares decomposition. Its degrees of freedom are \((a-1)(b-1)\), and its sum of squares divided by the error variance has a chi-square distribution when the mean vector has no interaction component. This conclusion uses both the orthogonal projection structure and the Gaussian, equal-variance assumptions.

  • Wrong reasoning: “There are \(ab\) cell means, so the interaction has \(ab\) degrees of freedom.” This counts cell patterns before removing the grand mean and main effects.
  • Correction: Interaction cell patterns must have every row and column sum equal to zero. Those constraints leave \(ab-(a+b-1)=(a-1)(b-1)\) free directions.
  • Another pitfall: Applying the same unweighted cell-mean formula to an unbalanced layout. With unequal cell replication, the corresponding projection generally uses weights and is not obtained by this simple balanced orthogonal decomposition.
Key takeaway: In a balanced two-way factorial, subtract the row and column effects and add back the grand mean to obtain each interaction effect. The resulting cell pattern is orthogonal to the grand mean and both main effects, and its projection rank is \((a-1)(b-1)\).

Check Your Understanding

Use the definitions and projection argument above to answer the following.

  1. Why does the interaction sum of squares include a factor of \(r\)?
  2. Show directly that the interaction effects sum to zero across each row.
  3. For a balanced layout with four levels of A and three levels of B, what is the interaction rank?
  4. How many independent margin constraints are imposed on the \(ab\) interaction cell values, and why is one constraint redundant?
  5. Why is variation among cell means not, by itself, the interaction sum of squares?
Clinical Biostats