Why Interaction Selection Needs Structure
An interaction allows the association between one predictor and the response to vary with another predictor. It can reveal meaningful effect modification, but adding every possible interaction risks fitting noise and making results difficult to interpret. Selecting interactions therefore involves two decisions: which candidate model performs well by a likelihood or predictive criterion, and whether its terms form a coherent model.
The principle of hierarchy supplies a common structural constraint. It asks that lower-order terms accompany an interaction, so that a model does not attribute a pattern to a product term while omitting the predictors that define that product. Hierarchy does not decide which interaction is scientifically appropriate, nor does it replace model comparison; it restricts the candidate models being compared.
Interaction Terms and Hierarchy
For two predictors \(x\) and \(z\), a GLM with a two-way interaction has linear predictor
where \(\mu=E[Y\mid x,z]\), \(g\) is the link function, and the \(\beta\)'s are coefficients. The interaction term is \(xz\). In a model with factors, the corresponding interaction consists of the product or products of their contrast-coded columns; the same hierarchy principles apply to the factor terms as a whole.
A model containing the interaction and both main effects satisfies both principles. A model containing \(x\) and \(xz\), but not \(z\), satisfies weak hierarchy but violates strong hierarchy. A model containing \(xz\) alone violates both. For higher-order interactions, hierarchy is usually defined in terms of the lower-order component terms; conventions can differ, so the rule should be specified for the candidate set. Here the focus is two-way interactions.
Hierarchy is especially useful because the meaning of a main-effect coefficient depends on the other predictor's value. In the equation above, \(\beta_x\) describes the effect of \(x\) when \(z=0\), not an effect that is necessarily constant across \(z\). Omitting the \(z\) main effect while retaining \(xz\) can impose an awkward restriction: the model forces the effect of \(z\) to be zero at \(x=0\), even if that restriction has no scientific basis.
Comparing Interaction Structures
Begin with a scientifically defensible candidate set, as in other GLM selection problems. To compare likelihood-based criteria, models must use the same response observations and a comparable likelihood. AIC is \( -2\ell(\hat\theta)+2k\), where \(\ell(\hat\theta)\) is the maximized log-likelihood and \(k\) is the number of estimated parameters. Smaller AIC is preferred among the candidates being compared. BIC uses a larger, sample-size-dependent penalty, while predictive criteria assess performance on held-out or cross-validated observations. In every case, apply hierarchy as a constraint on the candidates, not as a substitute for the criterion.
For nested models, adding an interaction cannot reduce the maximized likelihood when the smaller model is obtained by setting its interaction coefficient or coefficients to zero. But improved fit alone is not sufficient: the more complex model uses additional parameters. A likelihood-ratio test can address a specified nested comparison under its regularity conditions, but a screening test and a model-selection criterion answer different questions. In particular, a small p-value is not a general rule for retaining every interaction.
A practical comparison can proceed in stages: define the interaction terms under consideration, retain only models that meet the chosen hierarchy rule, fit those candidates consistently, and compare their likelihood or predictive scores. If a predictive score is estimated by cross-validation, use the same folds for all candidates when feasible; this makes paired score differences easier to interpret.
Worked Example: AIC and a Treatment-by-Age Interaction
Suppose a Poisson GLM models a count \(Y\) using treatment \(T\), coded 0 or 1, and age \(A\), measured in years. The additive model has linear predictor \(\eta=\beta_0+\beta_TT+\beta_AA\); the interaction model adds \(\beta_{TA}TA\). Both models include the two main effects, so the interaction model satisfies strong hierarchy. Assume the fitted log-likelihoods are \(-120.4\) for the additive model and \(-115.8\) for the interaction model. There are three regression coefficients in the additive model and four in the interaction model; the Poisson dispersion is fixed.
For the additive model, \(k=3\), so \( \mathrm{AIC}=-2(-120.4)+2(3)=240.8+6=246.8.\) For the interaction model, \(k=4\), so \( \mathrm{AIC}=-2(-115.8)+2(4)=231.6+8=239.6.\) The interaction model has the smaller AIC by \(246.8-239.6=7.2\), so it is preferred by AIC among these two candidates.
Suppose its estimated coefficients are \(\hat\beta_T=0.40\), \(\hat\beta_A=0.03\), and \(\hat\beta_{TA}=-0.02\). At age \(A\), the treatment contrast on the log-mean scale is \(\hat\beta_T+\hat\beta_{TA}A\). At age 10 this is \(0.40-0.02(10)=0.20\), giving a treatment rate ratio of \(\exp(0.20)\approx1.22\). At age 20 the contrast is \(0.40-0.02(20)=0\), giving a rate ratio of 1. The selected interaction thus represents a treatment contrast that varies with age. This comparison does not by itself establish that the interaction is scientifically important or precisely estimated.
Conditional Effects: What the Interaction Says
In a model with continuous \(x\) and \(z\), the effect of changing \(x\) depends on \(z\). The next result gives the precise interpretation on the link scale and, when the inverse link is differentiable, on the response scale.
To derive the result, differentiate each term of the linear predictor with respect to \(x\), holding \(z\) fixed:
Since \(\mu=g^{-1}(\eta)\), the chain rule gives
Thus \(\beta_{xz}\) is the change in the link-scale slope for \(x\) associated with a one-unit increase in \(z\). It is not generally the change in the response-scale slope: the factor \((g^{-1})'(\eta)\) also depends on the predictors. For a binary \(x\), the corresponding link-scale contrast between \(x=1\) and \(x=0\) is \(\beta_x+\beta_{xz}z\), rather than a derivative.
Hierarchy and Centering
The values \(x=0\) and \(z=0\) may be outside the useful range of the data. Centering can make the main-effect coefficients easier to interpret, but it should not change the fitted model space when both main effects and the interaction are present.
To verify this, write \(x=x'+c_x\) and \(z=z'+c_z\). The original linear predictor becomes
This is an intercept, two main effects, and an interaction in the centered predictors. Conversely, \(x'=x-c_x\) and \(z'=z-c_z\) allow the same expansion in reverse, so every predictor in either parameterization can be written in the other. The two sets of linear predictors, and hence the fitted means under the same link, are identical. If the interaction is included without both main effects, this invariance need not hold: expanding \(xz\) after centering introduces the missing lower-order terms. This is one reason to use hierarchy, rather than treating it as a cosmetic convention. \(\square\)
Centering changes the interpretation of the main-effect coefficients. In the centered model, the coefficient of \(x'\) is the link-scale effect of \(x\) at \(z=c_z\), rather than at \(z=0\). The interaction coefficient is unchanged by this centering transformation.
Worked Example: Interpreting a Logistic Interaction
Consider a logistic GLM for a binary outcome, with continuous \(x\) and binary group indicator \(G\). Let \( \operatorname{logit}(\mu)= -1+0.5x+0.2G+0.3xG.\) The log-odds slope for \(x\) when \(G=0\) is \(0.5\). When \(G=1\), it is \(0.5+0.3=0.8\). Thus the interaction coefficient \(0.3\) is the difference between these two log-odds slopes.
At \(x=1\), the linear predictor for \(G=0\) is \(-1+0.5=-0.5\), so the fitted probability is \(1/(1+\exp(0.5))\approx0.378\). For \(G=1\), it is \(-1+0.5+0.2+0.3=0\), so the fitted probability is \(1/(1+\exp(0))=0.5\). The probability difference at this \(x\) is about \(0.122\).
The value \(0.3\) is not that probability difference. It is a difference in log-odds slopes; the response-scale probability difference depends on \(x\) and on the fitted probabilities. For example, at \(x=0\), the fitted probabilities are \(1/(1+\exp(1))\approx0.269\) for \(G=0\) and \(1/(1+\exp(0.8))\approx0.310\) for \(G=1\), a difference of about \(0.041\).
Predictive Comparison Under Hierarchy
A hierarchy constraint can also be applied when the goal is prediction. Suppose candidate logistic models for a binary outcome use predictors \(X\) and \(Z\), each coded 0 or 1. All models include an intercept. A two-fold validation exercise yields the following average held-out log losses per observation; lower values are better.
| Candidate model | Fold 1 loss | Fold 2 loss | Mean loss |
|---|---|---|---|
| Intercept + \(X+Z\) (no interaction) | 0.44 | 0.42 | 0.43 |
| Intercept + \(X+Z+XZ\) | 0.40 | 0.42 | 0.41 |
Worked Example: Choosing an Interaction by Validation Loss
The two candidate models above both satisfy strong hierarchy: the first is additive, and the second includes both main effects along with the interaction. For the additive model, the mean loss is \((0.44+0.42)/2=0.43\). For the interaction model, it is \((0.40+0.42)/2=0.41\). The interaction model has lower mean held-out loss by \(0.43-0.41=0.02\) per observation, so it is preferred by this validation comparison.
The difference is modest, and the two-fold estimate can be uncertain. A responsible conclusion is that this validation exercise favors the hierarchical interaction model, not that the interaction is certainly useful in a new sample. A different set of folds or a different sample could produce a different ranking.
Common Mistakes and Practical Checks
- Keeping an interaction but dropping both main effects. A lower score for an interaction-only candidate does not make it a strong-hierarchy model. If that principle is part of the analysis, exclude the candidate or refit a hierarchy-respecting alternative before making the selection.
- Reading a main-effect coefficient as an average effect. With an interaction, the coefficient for \(x\) is the effect at the reference value \(z=0\) (or at the centered reference value), not a universal effect across \(z\).
- Calling an interaction important because it improves training fit. A more complex model can fit the observed data better. Compare a complexity-penalized likelihood criterion or a suitable predictive score, and consider uncertainty in that comparison.
- Interpreting the interaction coefficient on the wrong scale. In logistic and log-link models, the coefficient describes interaction on the link scale. Response-scale changes require calculating fitted means or contrasts at specified predictor values.
- Changing the candidate set without checking comparability. Likelihood criteria require comparable likelihoods on the same response observations. Predictive scores should also be calculated on consistent validation splits when candidates are compared.
Hierarchy makes interaction selection more interpretable and can protect against arbitrary dependence on a predictor's zero point. It does not guarantee a correct model, settle the scientific meaning of an interaction, or eliminate uncertainty from selection. Report the hierarchy rule, the criterion used, the compared candidates, and conditional effects at meaningful predictor values.
Check Your Understanding
Try these questions by identifying both the model structure and the scale of the effect.
- A model contains \(X\), \(Z\), and \(XZ\). Does it satisfy strong hierarchy, weak hierarchy, both, or neither?
- For \(\eta=\beta_0+\beta_xx+\beta_zz+\beta_{xz}xz\), write the link-scale effect of a one-unit increase in \(x\) at \(z=4\).
- Why can centering preserve fitted values in a model with both main effects and an interaction, yet change the interpretation of the main-effect coefficients?
- An interaction model has a lower training deviance but a higher cross-validated log loss than its additive counterpart. Which model is preferred by the reported predictive comparison, and what conclusion should be avoided?
- In a logistic GLM, does the interaction coefficient equal the difference in response probabilities between groups? Explain which scale it describes.