Tutorials › Exam PA - Predictive Analytics › Model Hierarchy and Complexity in GLM Selection

Exam PA · Model Comparison, Offsets, and Weights · Tutorial 373 of 966

Model Hierarchy and Complexity in GLM Selection

Apply model hierarchy to interactions and polynomial effects, then account for the full complexity of each GLM when comparing candidate specifications.

Advanced 11 min read

What You'll Learn

  • State the strong hierarchy principle for interaction and polynomial terms
  • Explain why lower-order terms preserve interpretable effects under changes of reference point
  • Count regression coefficients and other estimated parameters when comparing GLMs
  • Compare hierarchical candidates using likelihood and AIC calculations
  • Distinguish a better-fitting model from a better-supported model after penalizing complexity

Why Hierarchy Matters in GLM Selection

A GLM can improve its fit by adding interactions or higher powers of predictors. But a term should not be judged only by whether it reduces deviance: the model's structure and the number of parameters added matter too. Hierarchy provides a disciplined way to build interpretable candidate models, while complexity accounting makes comparisons fair.

This tutorial focuses on two common cases: an interaction such as \(xz\), and a polynomial term such as \(x^2\). The same principles apply whether a GLM uses an identity, log, or logit link. They do not dictate which model must be selected; they help ensure that the candidate models and their comparisons are sensible.

Definition: Under the strong hierarchy principle, a model containing an interaction between two predictors also contains the main effects of both predictors. A model containing a polynomial power \(x^r\), for \(r \geq 2\), also contains the lower powers \(x, x^2, \ldots, x^{r-1}\). These are modeling principles, not mathematical requirements for every possible GLM.

For categorical predictors, “main effect” and “interaction” refer to sets of coefficients, not necessarily single coefficients. If factor A has \(a\) levels and factor B has \(b\) levels, their main effects usually require \(a-1\) and \(b-1\) coefficients, and their interaction requires \((a-1)(b-1)\) coefficients under standard reference-level coding. The hierarchy principle retains both main-effect sets when the interaction set is included.

Why Lower-Order Terms Belong with Interactions

Consider the linear predictor

$$ \eta = \beta_0+\beta_1x+\beta_2z+\beta_3xz. $$

The interaction says that the association between \(x\) and the linear predictor can change with \(z\): its slope with respect to \(x\) is \(\beta_1+\beta_3z\). The main effects describe the corresponding lower-order contributions. Omitting them can make the interaction depend unnecessarily on the particular zero points used for the predictors.

The reason can be shown directly. Let \(z'=z-c\), so \(z=z'+c\). Substituting this into the complete model gives

$$ \begin{aligned} \eta &=\beta_0+\beta_1x+\beta_2(z'+c)+\beta_3x(z'+c)\\ &=(\beta_0+\beta_2c)+(\beta_1+\beta_3c)x+\beta_2z'+\beta_3xz'. \end{aligned} $$

After shifting the origin of \(z\), the intercept and the main-effect coefficient of \(x\) change, while the interaction remains. Now consider a model containing only an intercept and \(\beta_3xz\). Replacing \(z\) by \(z'+c\) produces \(\beta_3xz'+\beta_3cx\): a main effect of \(x\) appears solely because the origin changed. The model without lower-order terms is therefore not generally invariant to a harmless change of reference point. This is one reason strong hierarchy is a useful default.

With a complete polynomial, shifting the origin also changes the coefficients of lower powers. For example, \((x+c)^2=x^2+2cx+c^2\), so a quadratic effect expressed around a shifted origin includes a linear term and a changed intercept. Including the lower-order terms allows the same curve to be represented after recentering.

Hierarchy and Parameter Counts

A candidate model's complexity is determined by the number of estimated parameters, not by the number of terms as written in a formula. A term can represent several coefficients. For example, an interaction between two factors with three and four levels adds six coefficients, not one. The intercept and any estimated dispersion parameter also count when calculating an information criterion such as AIC.

For models fit to the same observations with maximized log-likelihood \(\ell\), AIC is

$$ \mathrm{AIC}=-2\ell+2k, $$

where \(k\) is the number of estimated parameters under the convention being used. Lower AIC is preferred among the candidates being compared. The likelihood improvement rewards fit; the \(2k\) term penalizes complexity. AIC does not make an incoherent or non-hierarchical candidate automatically appropriate.

For nested models fit to the same data, the likelihood-ratio statistic is \(2(\ell_{\text{larger}}-\ell_{\text{smaller}})\). When a term adds \(q\) estimable coefficients, the usual large-sample reference comparison uses \(q\) degrees of freedom, subject to the model and regularity conditions for that test. A term that adds six coefficients should not be assessed as if it added only one.

Worked Example: Deciding Whether to Add an Interaction

A hypothetical insurer models annual repair cost using a Gaussian GLM with identity link and constant variance. The predictors are vehicle age \(x\) and annual mileage \(z\). Both candidates use the same 120 policies. The main-effects model has log-likelihood \(-180.2\), three regression coefficients (intercept and two slopes), and one estimated variance parameter. The hierarchical model adds \(xz\), has log-likelihood \(-174.8\), and estimates one additional regression coefficient. Compare the candidates using AIC and state the hierarchy check.

Method. Count every estimated parameter, including the Gaussian variance, and calculate AIC for each model. The reduced model has \(k=3+1=4\); the interaction model has \(k=4+1=5\).

For the main-effects model,

$$ \mathrm{AIC}_{\text{main}}=-2(-180.2)+2(4)=360.4+8=368.4. $$

For the interaction model,

$$ \mathrm{AIC}_{\text{interaction}}=-2(-174.8)+2(5)=349.6+10=359.6. $$

The interaction model has lower AIC by \(368.4-359.6=8.8\). Its log-likelihood improves by \(-174.8-(-180.2)=5.4\), so the likelihood-ratio statistic is \(2(5.4)=10.8\) for one added coefficient. The interaction model includes both vehicle age and mileage main effects, so it satisfies strong hierarchy.

Check. The AIC change is \(-10.8+2(1)=-8.8\), matching the direct subtraction. The common mistake avoided is counting \(xz\) as the whole model or forgetting the estimated variance in \(k\). Either way, the absolute AIC values would be misreported; the relative difference here still reflects the one-parameter penalty.

Polynomial Terms and Hierarchical Comparisons

For a polynomial of degree \(r\), strong hierarchy retains each power below \(r\). Thus a cubic model contains \(x\), \(x^2\), and \(x^3\). This gives the polynomial a coherent interpretation: the curve can express both slope and curvature, and the terms remain available when the predictor is centered at another value.

A common comparison is between a linear model and its quadratic extension. These are nested if they use the same data, response, link, and other terms; the quadratic model adds one coefficient, \(x^2\). In contrast, comparing a model with \(x^2\) alone against one with \(x\) is not the usual hierarchical test of whether curvature improves a linear trend. The two specifications answer different questions and may not be nested.

Worked Example: Checking a Quadratic Extension

A hypothetical analyst models a continuous response, annual energy use, against building age \(x\), using a Gaussian GLM with identity link. Both models use the same 80 buildings. The linear model has log-likelihood \(-96.0\), with an intercept, \(x\), and an estimated variance. The quadratic model has log-likelihood \(-91.9\), with an intercept, \(x\), \(x^2\), and an estimated variance. Calculate the AIC values and verify whether the comparison respects hierarchy.

Method. The linear model has \(k=2+1=3\) estimated parameters. The quadratic model has \(k=3+1=4\). The additional regression parameter is the coefficient of \(x^2\).

For the linear model,

$$ \mathrm{AIC}_{\text{linear}}=-2(-96.0)+2(3)=192.0+6=198.0. $$

For the quadratic model,

$$ \mathrm{AIC}_{\text{quadratic}}=-2(-91.9)+2(4)=183.8+8=191.8. $$

The quadratic model has lower AIC by \(198.0-191.8=6.2\). Its log-likelihood increases by \(4.1\), and the one-parameter AIC penalty is \(2\), so the net AIC change is \(-2(4.1)+2=-6.2\). The model includes \(x\) as well as \(x^2\), so the polynomial hierarchy is respected.

Check. The two AIC calculations differ by \(6.2\), consistent with the log-likelihood change and the single added parameter. The common mistake avoided is interpreting an \(x^2\)-only model as the hierarchical quadratic extension of a linear model.

Factor Interactions: Count the Coefficients, Not the Labels

For a factor interaction, the increase in complexity can be substantial. Suppose factor A has three levels and factor B has four levels. With an intercept, standard reference-level coding gives two coefficients for A, three for B, and six for the interaction. The full model therefore has \(1+2+3+6=12\) regression coefficients. The hierarchical main-effects model has \(1+2+3=6\). In a Gaussian GLM with an estimated variance, the corresponding total parameter counts are 13 and 7.

The interaction represents departures from a model in which the factor effects combine additively on the linear-predictor scale. It is not a single extra parameter merely because it appears as one formula term. Sparse or empty combinations of factor levels can also make some interaction coefficients unestimable; in that case, the nominal count may not equal the number of estimable parameters. Check the fitted model and the data structure before interpreting a comparison.

Worked Example: A Multi-Coefficient Factor Interaction

A hypothetical study compares a continuous outcome across treatment factor A with three levels and region factor B with four levels. Gaussian GLMs with identity link are fitted to the same 400 observations. The main-effects model has log-likelihood \(-515.5\); the model with the A-by-B interaction has log-likelihood \(-510.0\). Assume all cells are represented, all coefficients are estimable, and each model estimates one variance parameter. Use AIC to compare them and explain the complexity penalty.

Method. With an intercept, the main-effects model has \(1+(3-1)+(4-1)=6\) regression coefficients. Including variance gives \(k_{\text{main}}=7\). The interaction adds \((3-1)(4-1)=6\) coefficients, giving 12 regression coefficients and \(k_{\text{full}}=13\) in total.

For the main-effects model,

$$ \mathrm{AIC}_{\text{main}}=-2(-515.5)+2(7)=1031+14=1045. $$

For the interaction model,

$$ \mathrm{AIC}_{\text{full}}=-2(-510.0)+2(13)=1020+26=1046. $$

The interaction model improves the log-likelihood by \(5.5\), so twice that improvement is \(11\). However, it adds six parameters and incurs a \(2(6)=12\) AIC penalty. The net AIC change is \(-11+12=1\), so the simpler main-effects model has the lower AIC by 1.

Check. Direct calculation gives \(1046-1045=1\), agreeing with the improvement-minus-penalty calculation. The common mistake avoided is treating a factor interaction as one parameter and concluding that the fit improvement outweighs only a penalty of 2.

Using Hierarchy in a Selection Decision

Hierarchy is a structural guide, not a substitute for the comparison objective. Earlier material on GLM comparison distinguishes likelihood-based fit, information criteria, and predictive performance. In each case, the candidate set should be built so that the terms have meaningful interpretations and the complexity is counted correctly.

1
Write the full term structure.
Identify whether each proposed term is a main effect, an interaction, or a polynomial power. For a two-way interaction, identify both component predictors.
2
Apply hierarchy.
When using strong hierarchy, retain both main effects for an interaction and all lower powers for a polynomial term. State explicitly if a deliberate exception is being considered.
3
Count added parameters.
Use the factor degrees of freedom or the number of added polynomial coefficients. Include other estimated parameters when calculating AIC or another criterion.
4
Compare on a valid basis.
For a likelihood comparison, ensure the models use the same response observations and likelihood basis. Then interpret improvement in fit alongside the number of added parameters and the chosen objective.

A lower deviance for a larger model is expected when it is a nested extension fit by maximum likelihood to the same data. That fact alone does not establish that every added term is worthwhile. Conversely, a small AIC difference does not prove that one model is substantively correct. Report the candidate structure, the number of added coefficients, the comparison criterion, and any important limitations.

Common Mistakes and Exam Traps

  • Keeping an interaction but dropping both main effects. This violates strong hierarchy and can make the model's meaning depend on arbitrary predictor origins. Retain both main effects by default.
  • Keeping \(x^3\) but omitting \(x\) or \(x^2\). A cubic hierarchical model contains every lower power. Compare the complete polynomial extension with its lower-degree counterpart.
  • Counting formula terms instead of coefficients. A factor-by-factor interaction can add several degrees of freedom. Count the level contrasts and their products.
  • Ignoring parameters outside the linear predictor. For Gaussian likelihood-based criteria, an estimated variance is a parameter too. Use a consistent parameter-count convention for all models.
  • Selecting only by the smallest deviance. Fit usually improves as terms are added. Consider the complexity penalty or the stated predictive objective rather than equating better in-sample fit with better selection.
  • Assuming hierarchy is an absolute law. It is a widely useful modeling principle, not a theorem that forbids every non-hierarchical specification. If an exception is used, justify the scientific meaning and interpretability.
Key takeaway: For interactions and polynomial effects, strong hierarchy supplies a stable and interpretable default: retain the relevant lower-order terms. Then count every added coefficient, not just every written term, before judging whether the improvement in fit justifies the added complexity.

Check Your Understanding

For each situation, identify the hierarchical structure or calculate the requested parameter count or comparison. Assume all stated coefficients are estimable.

  1. A GLM linear predictor contains \(x^2\), \(xz\), and \(w\), but no other terms are specified. Under strong hierarchy, which lower-order predictor terms must also be included? (Answer: Include \(x\) for \(x^2\), and include both \(x\) and \(z\) for \(xz\); \(w\) is already a main effect.)
  2. A Gaussian GLM with identity link includes a four-level factor A, a continuous predictor \(x\), and their interaction. Count the regression coefficients and then the total parameters if one variance is estimated. (Answer: \(1+3+1+3=8\) regression coefficients; 9 total parameters including variance.)
  3. Two models use the same data. Model R has log-likelihood \(-72.0\) and \(k=5\); Model S has log-likelihood \(-69.5\) and \(k=7\). Calculate both AIC values and select the lower-AIC model. (Answer: AIC R \(=144+10=154\); AIC S \(=139+14=153\); select Model S by AIC.)
  4. A model contains \(xz\) and has no \(x\) main effect. If \(z'=z-4\), substitute \(z=z'+4\) into the interaction term and state the additional term created. (Answer: \(xz=x(z'+4)=xz'+4x\); recentering creates the \(x\) main-effect term \(4x\).)
  5. A Gaussian GLM has a five-level factor A and a three-level factor B. Count the regression coefficients in the hierarchical main-effects model and in the model with the interaction; then include one estimated variance parameter in each total. (Answer: Main effects have \(1+4+2=7\) regression coefficients and 8 total parameters; the interaction adds \(4\times2=8\), giving 15 regression coefficients and 16 total parameters.)
Clinical Biostats