Why Constraints Are Needed
For a two-way table, a loglinear model describes each cell through its expected count. If every cell has a positive mean, its logarithm can be expressed as a grand mean plus row, column, and interaction contributions. This decomposition is useful because it separates overall level, row differences, column differences, and departures from an additive pattern.
The decomposition alone does not identify the individual parameters. A constant can be moved from one component to another while leaving every cell log mean unchanged. Constraints remove that ambiguity. Reference-category constraints and sum-to-zero constraints are two common choices. They give different parameter values, but, when used to represent the same cell log means, they give the same fitted means.
Here \(\lambda\) is the grand-mean parameter, \(\alpha_i\) is a row effect, \(\beta_j\) is a column effect, and \(\gamma_{ij}\) is an interaction parameter. Without constraints, these names do not give the parameters unique values. There are \(1+I+J+IJ\) parameters in the expression but only \(IJ\) cell log means, so the representation necessarily has redundancy.
Reference-Category Constraints
Choose row 1 and column 1 as reference categories. Set their row and column effects to zero and set interaction terms involving either reference category to zero. The remaining parameters are then determined by differences from the reference cell and reference categories.
These formulas apply at reference levels too: they give \(\alpha_1=0\), \(\beta_1=0\), and \(\gamma_{i1}=\gamma_{1j}=0\). To verify the decomposition, substitute the formulas: \(\lambda+\alpha_i+\beta_j+\gamma_{ij}=\eta_{11}+(\eta_{i1}-\eta_{11})+(\eta_{1j}-\eta_{11})+(\eta_{ij}-\eta_{i1}-\eta_{1j}+\eta_{11})=\eta_{ij}\).
Worked Example: Calculating Reference Parameters
Suppose a two-by-two table has cell log means \(\eta_{11}=1\), \(\eta_{12}=2\), \(\eta_{21}=3\), and \(\eta_{22}=5\). The corresponding means are \(e,e^2,e^3,e^5\). Use row 1 and column 1 as references.
The grand-mean parameter is \(\lambda=\eta_{11}=1\). The row effects are \(\alpha_1=0\) and \(\alpha_2=\eta_{21}-\eta_{11}=3-1=2\). The column effects are \(\beta_1=0\) and \(\beta_2=\eta_{12}-\eta_{11}=2-1=1\).
The interaction parameters involving the reference row or column are zero. The remaining interaction is \(\gamma_{22}=\eta_{22}-\eta_{21}-\eta_{12}+\eta_{11}=5-3-2+1=1\).
Reconstruction gives \(\eta_{11}=1\), \(\eta_{12}=1+0+1+0=2\), \(\eta_{21}=1+2+0+0=3\), and \(\eta_{22}=1+2+1+1=5\). Exponentiating recovers the four original means, so the parameterization has not changed any cell mean.
Sum-to-Zero Constraints
A second convention makes each set of effects average to zero. This is sometimes called effect coding. The grand-mean parameter is the unweighted average of the cell log means; row and column effects are deviations of their corresponding averages from that grand average. The interaction then accounts for what remains after those averages are removed.
The constraints are \(\sum_i\alpha_i=0\), \(\sum_j\beta_j=0\), \(\sum_j\gamma_{ij}=0\) for every row \(i\), and \(\sum_i\gamma_{ij}=0\) for every column \(j\). For example, \(\sum_i\alpha_i=\sum_i\eta_{i\cdot}-I\eta_{\cdot\cdot}=0\), because the average of the row averages is \(\eta_{\cdot\cdot}\). The column-effect constraint follows in the same way. For each row, \(\sum_j\gamma_{ij}=\sum_j\eta_{ij}-J\eta_{i\cdot}-\sum_j\eta_{\cdot j}+J\eta_{\cdot\cdot}=0\); the column calculation is analogous.
Proof. First, adding the four formula components gives \(\eta_{\cdot\cdot}+(\eta_{i\cdot}-\eta_{\cdot\cdot})+(\eta_{\cdot j}-\eta_{\cdot\cdot})+(\eta_{ij}-\eta_{i\cdot}-\eta_{\cdot j}+\eta_{\cdot\cdot})=\eta_{ij}\). The constraints follow from the average identities just established.
For uniqueness, suppose a constrained decomposition represents the same \(\eta_{ij}\). Averaging it over columns gives \(\eta_{i\cdot}=\lambda+\alpha_i\), since the column effects sum to zero and the interaction terms in row \(i\) sum to zero. Averaging this identity over rows gives \(\eta_{\cdot\cdot}=\lambda\), because the row effects sum to zero. Thus \(\lambda\) and every \(\alpha_i=\eta_{i\cdot}-\eta_{\cdot\cdot}\) are determined. Averaging over rows instead gives \(\eta_{\cdot j}=\lambda+\beta_j\), determining every \(\beta_j\). Finally, \(\gamma_{ij}=\eta_{ij}-\lambda-\alpha_i-\beta_j\) is determined as well. No second constrained decomposition is possible. \(\square\)
Worked Example: Converting the Same Log Means to Sum-to-Zero Parameters
Use the log means from the two-by-two example: \(\begin{pmatrix}1&2\\3&5\end{pmatrix}\). Their overall average is \(\eta_{\cdot\cdot}=(1+2+3+5)/4=11/4\), so \(\lambda=11/4\). The row averages are \(3/2\) and \(4\), giving \(\alpha_1=3/2-11/4=-5/4\) and \(\alpha_2=4-11/4=5/4\).
The column averages are \(2\) and \(7/2\), so \(\beta_1=2-11/4=-3/4\) and \(\beta_2=7/2-11/4=3/4\). The interactions are \(\gamma_{11}=1-3/2-2+11/4=1/4\), \(\gamma_{12}=2-3/2-7/2+11/4=-1/4\), \(\gamma_{21}=3-4-2+11/4=-1/4\), and \(\gamma_{22}=5-4-7/2+11/4=1/4\).
The row effects sum to zero, as do the column effects. Each row and column of the interaction array also sums to zero. For instance, the reconstructed value in cell \((2,2)\) is \(11/4+5/4+3/4+1/4=5\); in cell \((1,2)\) it is \(11/4-5/4+3/4-1/4=2\). The formulas reconstruct each of the four log means, although the parameters differ from the reference-category values.
What Is Identifiable and What Is Invariant?
A parameter is identifiable when distinct allowed parameter values cannot give the same probability model. Without constraints, the separate components \(\lambda,\alpha_i,\beta_j,\gamma_{ij}\) are not identifiable: they are coordinates with redundant freedom. For example, adding a constant to the grand mean and compensating in the interaction array leaves all \(\eta_{ij}\) unchanged. The reference and sum-to-zero constraints each select one unique coordinate representation for a given complete array of cell log means.
In either constrained representation, the cell log means \(\eta_{ij}\), and therefore the fitted means \(\mu_{ij}=\exp(\eta_{ij})\), are invariant. The numerical values called row effects, column effects, or cell interactions are not generally invariant across the two conventions. Their interpretations depend on the constraint: reference effects compare to a chosen baseline, whereas sum-to-zero effects are deviations from averages.
A useful exception is the two-factor difference-in-differences. For any two rows \(i,k\) and columns \(j,\ell\), the contrast \(\eta_{ij}-\eta_{i\ell}-\eta_{kj}+\eta_{k\ell}\) is unchanged by adding any row-only or column-only contributions. Under the reference constraints, the cell interaction is a difference-in-differences relative to row 1 and column 1. Under sum-to-zero constraints, \(\gamma_{ij}\) is a double-centered component; its individual value need not equal the reference interaction. The underlying difference-in-differences, however, is determined by the cell log means.
Worked Example: An Invariant Interaction Contrast
For the two-by-two log-mean array \(\begin{pmatrix}1&2\\3&5\end{pmatrix}\), the row-2 versus row-1 change is \(3-1=2\) in column 1 and \(5-2=3\) in column 2. Their difference is \(3-2=1\). Equivalently, the contrast is \(5-3-2+1=1\).
In the reference parameterization, this contrast is \(\gamma_{22}=1\), since row 1 and column 1 are the references. In the sum-to-zero parameterization, the individual cell interaction \(\gamma_{22}\) is \(1/4\), not \(1\). But the full difference-in-differences is still \(1\): the interaction array has entries \(1/4,-1/4,-1/4,1/4\), so \(\gamma_{22}-\gamma_{21}-\gamma_{12}+\gamma_{11}=1\). The contrast is a feature of the cell log means, not a consequence of choosing one set of coordinates.
Common Mistake
A frequent error is to interpret a parameter as though its numerical value were independent of the constraint. For example, one might see a reference interaction equal to \(1\) and conclude that the corresponding sum-to-zero interaction must also equal \(1\). That is incorrect: these parameters are defined by different formulas. What must agree is the reconstructed cell log mean, or an explicitly defined invariant contrast. When reporting a row effect or interaction, state the constraint convention so its meaning is clear.
Constraints are not additional assumptions about the observed counts. For a full two-way decomposition they choose a unique representation of the same cell log means. Confusing a coordinate convention with a restriction on fitted means can lead to incorrect comparisons across analyses or software outputs.
Check Your Understanding
Answer using the definitions and formulas in this tutorial.
- For reference-category constraints, express \(\gamma_{ij}\) using the four cell log means involving rows \(i,1\) and columns \(j,1\).
- Why are unconstrained grand-mean, row, column, and interaction parameters not uniquely identified?
- Under sum-to-zero constraints, what is the formula for \(\lambda\), and why is it the average of all cell log means?
- Which quantities remain unchanged when the same cell log means are expressed with reference-category rather than sum-to-zero constraints?
- For a two-by-two table, explain why the difference-in-differences of the four cell log means is invariant to the choice of constraint convention.