Tutorials › Exam PA - Predictive Analytics › Interpreting Interaction Terms in GLMs

Exam PA · Coefficient Interpretation and Diagnostics · Tutorial 340 of 966

Interpreting Interaction Terms in GLMs

Interpret each main-effect coefficient at the other predictor’s zero value, then use the product coefficient to calculate conditional effects at specified predictor values.

Intermediate 13 min read

What You'll Learn

  • Write a two-predictor GLM linear predictor with a product term
  • Interpret main effects at the value zero of the other predictor
  • Calculate a predictor’s conditional slope on the link scale
  • Translate conditional changes into odds or rate ratios when appropriate
  • Identify when an interaction coefficient is being misinterpreted

Why an Interaction Changes the Interpretation

In a GLM without an interaction, the coefficient of a predictor describes the same change on the link scale at every value of the other predictors. A product term changes that: the link-scale effect of one predictor depends on the value of the other. This matters when describing fitted relationships, comparing scenarios, or explaining what a coefficient means in context.

The focus here is a model with two quantitative predictors and their product. Interpretations are conditional associations in the specified model; an interaction by itself does not establish a causal effect. The predictor values and their units matter, especially the value zero, because each main-effect coefficient is interpreted at zero of the other predictor.

Definition: A two-predictor GLM with an interaction product term has linear predictor \(\eta=\beta_0+\beta_1x_1+\beta_2x_2+\beta_{12}x_1x_2\), and conditional mean \(\mu=E[Y\mid x_1,x_2]\) related to it by \(\eta=g(\mu)\), where \(g\) is the model’s link function. The product \(x_1x_2\) allows the link-scale effect of either predictor to vary with the other predictor.

Holding \(x_2\) fixed, the coefficient \(\beta_1\) alone is not generally the effect of \(x_1\). For continuous \(x_1\), the conditional slope on the link scale is \(\beta_1+\beta_{12}x_2\). Similarly, the conditional slope for \(x_2\) is \(\beta_2+\beta_{12}x_1\). These are link-scale statements. If the link is not the identity, the corresponding change in the response mean generally also depends on the fitted mean.

Deriving the Conditional Effect

The result follows directly by collecting the terms involving \(x_1\). With \(x_2\) held fixed, the linear predictor can be rewritten as \(\eta=(\beta_0+\beta_2x_2)+(\beta_1+\beta_{12}x_2)x_1\). Thus, the coefficient multiplying \(x_1\) at that fixed value of \(x_2\) is \(\beta_1+\beta_{12}x_2\). Equivalently, differentiating the linear predictor with respect to \(x_1\) gives the same slope.

$$ \frac{\partial \eta}{\partial x_1} =\beta_1+\beta_{12}x_2, \qquad \frac{\partial \eta}{\partial x_2} =\beta_2+\beta_{12}x_1. $$

For a finite increase \(\Delta\) in \(x_1\), rather than an infinitesimal change, the exact link-scale change is \(\Delta(\beta_1+\beta_{12}x_2)\), provided \(x_2\) stays fixed. This follows by subtracting the linear predictors at \(x_1+\Delta\) and \(x_1\); the terms not involving \(x_1\) cancel. For a one-unit increase, set \(\Delta=1\).

$$ \eta(x_1+\Delta,x_2)-\eta(x_1,x_2) =\Delta(\beta_1+\beta_{12}x_2). $$

The interaction coefficient \(\beta_{12}\) therefore describes how the conditional slope for \(x_1\) changes for a one-unit increase in \(x_2\), on the link scale. It does not, by itself, give the effect of either predictor at every possible value of the other.

Worked Examples

Worked Example: Conditional Slope in an Identity-Link Model

Hypothetical scenario. A facilities team models annual equipment downtime \(Y\), in hours, using the number of technician training sessions \(x_1\) and equipment age \(x_2\), in years. Assume a Gaussian GLM with identity link and fitted model \(\eta=E[Y\mid x_1,x_2]=12-1.5x_1+2x_2-0.25x_1x_2\). Interpret the effect of another training session for equipment that is four years old, and find the fitted mean for three sessions and four years of age.

Method. Because the link is identity, \(\eta\) is the fitted conditional mean in hours. At \(x_2=4\), the conditional slope for training is \(\beta_1+\beta_{12}x_2=-1.5+(-0.25)(4)=-1.5-1.0=-2.5\) hours per session.

Fitted mean. Substitute \(x_1=3\) and \(x_2=4\): \(\eta=12-1.5(3)+2(4)-0.25(3)(4)\). The terms are \(12\), \(-4.5\), \(8\), and \(-3\), so \(\eta=12-4.5+8-3=12.5\) hours.

Check. At four years of age, the model predicts 12.5 hours for three sessions. One additional session changes the fitted mean by \(-2.5\) hours, giving \(12.5-2.5=10.0\) hours for four sessions. Direct substitution confirms \(12-1.5(4)+2(4)-0.25(4)(4)=12-6+8-4=10.0\). The calculation avoids treating \(-1.5\) as the slope at every equipment age.

Worked Example: Conditional Odds Ratio in a Logistic GLM

Hypothetical scenario. A model predicts whether a commercial site has a specified claim indicator \(Y\), where \(Y=1\) means the indicator is present. Let \(x_1\) be the number of inspections per year and \(x_2\) be a numerical site-complexity score. Assume a Bernoulli GLM with logit link and fitted linear predictor \(\eta=\log\{p/(1-p)\}=-2+0.4x_1+0.3x_2-0.1x_1x_2\), where \(p=P(Y=1\mid x_1,x_2)\). Find the effect of one more inspection when \(x_2=2\), and evaluate the fitted log odds at \(x_1=3,x_2=2\).

Conditional effect. At complexity score 2, the change in log odds for one additional inspection is \(0.4+(-0.1)(2)=0.4-0.2=0.2\). Exponentiating a change in log odds gives the corresponding odds multiplier, so the conditional odds ratio for one more inspection is \(e^{0.2}=1.2214\), to four decimal places. At this complexity score, the fitted odds are multiplied by about 1.2214 for each one-unit increase in inspections, according to the model.

Fitted log odds. At \(x_1=3,x_2=2\), \(\eta=-2+0.4(3)+0.3(2)-0.1(3)(2)=-2+1.2+0.6-0.6=-0.8\). For one more inspection, the new linear predictor is \(-0.8+0.2=-0.6\), verifying the conditional change of 0.2.

Check. The odds ratio calculated from the two linear predictors is \(e^{-0.6}/e^{-0.8}=e^{0.2}=1.2214\). This is an odds comparison, not a probability increase of 0.2214. The correction is important because the logistic link is not the identity link.

Worked Example: Conditional Rate Ratio in a Poisson GLM

Hypothetical scenario. A fleet analyst models the number \(Y\) of service events per vehicle over a fixed observation period. Let \(x_1\) be scheduled maintenance visits during that period and \(x_2\) be vehicle age in years. Assume a Poisson GLM with log link, so \(Y\mid x_1,x_2\) has mean \(\mu\) and \(\log(\mu)=1+0.05x_1+0.08x_2+0.02x_1x_2\). Find the rate ratio for one additional maintenance visit when the vehicle is five years old, and calculate the fitted mean at \(x_1=2,x_2=5\).

Conditional rate ratio. At \(x_2=5\), the change in log mean for one additional visit is \(0.05+0.02(5)=0.05+0.10=0.15\). Because the link is logarithmic, exponentiating the change gives the ratio of the two fitted means: \(e^{0.15}=1.1618\), to four decimal places. Thus, at age five, the fitted mean is multiplied by 1.1618 for each additional visit, with other model inputs fixed.

Fitted mean. At \(x_1=2,x_2=5\), the linear predictor is \(1+0.05(2)+0.08(5)+0.02(2)(5)=1+0.10+0.40+0.20=1.70\). Therefore, \(\mu=e^{1.70}=5.4739\) events, to four decimal places.

Check. At \(x_1=3,x_2=5\), the linear predictor is \(1+0.15+0.40+0.30=1.85\), giving fitted mean \(e^{1.85}=6.3598\). The ratio is \(e^{1.85}/e^{1.70}=e^{0.15}=1.1618\). The calculation avoids interpreting 0.05 as the log-rate effect at all vehicle ages.

Reading Coefficients and Avoiding Traps

At \(x_2=0\), the conditional slope for \(x_1\) is \(\beta_1\); at \(x_1=0\), the conditional slope for \(x_2\) is \(\beta_2\). Those are the conditions under which the corresponding main-effect coefficients have their direct slope interpretations. If zero is outside the useful range or has no practical meaning, centering a predictor can make the main effects refer to a more relevant value. Centering changes the reference point for these main effects, but does not remove the interaction from the model.

When the link is logarithmic, exponentiating the conditional link-scale change gives a ratio of fitted means. For a logit link, exponentiating it gives a conditional odds ratio. With an identity link, the conditional link-scale change is a change in the fitted mean itself. In other GLMs, do not assume that a link-scale change is also a response-scale change of the same size.

A frequent error is to report \(\beta_1\) as the effect of \(x_1\) without stating the value of \(x_2\). In the logistic example, using \(e^{0.4}=1.4918\) as the odds ratio at \(x_2=2\) is wrong: that value applies at \(x_2=0\). At \(x_2=2\), the correct log-odds change is \(0.4-0.1(2)=0.2\), and the correct odds ratio is \(e^{0.2}=1.2214\). Always substitute the stated value of the other predictor before interpreting an effect.

A second useful check is the direction of change in the conditional slope. In the logistic example, each one-unit increase in complexity changes the inspection slope by \(-0.1\) on the log-odds scale. The slope is 0.4 at complexity zero, 0.2 at complexity two, and \(-0.1\) at complexity five. The sign change is possible in the fitted model; it reinforces why a single unconditional description of the inspection coefficient would be incomplete.

Key takeaway: In a two-predictor GLM with a product term, calculate a predictor’s conditional effect by adding its main-effect coefficient to the interaction coefficient multiplied by the other predictor’s value. State the link scale, condition, and predictor units when interpreting the result.

Check Your Understanding

For each problem, identify the appropriate conditional link-scale effect before translating it to a response-scale ratio or change.

  1. A Gaussian identity-link model for hypothetical repair hours is \(\eta=7+1.2x-0.4z+0.3xz\), where \(x\) is the number of checks and \(z\) is an equipment index. Find the slope for \(x\) at \(z=2\), then calculate the fitted mean at \(x=3,z=2\). (Answer: slope \(1.8\) hours per check; fitted mean \(11.6\) hours.)
  2. A Poisson log-link model has \(\log(\mu)=-0.5+0.2x+0.1z-0.05xz\). At \(z=4\), calculate the one-unit conditional rate ratio for \(x\), and find the linear predictor at \(x=2,z=4\). (Answer: rate ratio \(e^0=1.0000\); linear predictor \(-0.1\).)
  3. A logistic model for a hypothetical binary outcome has \(\eta=-1+0.5a-0.2b+0.1ab\). At \(b=3\), calculate the one-unit conditional odds ratio for \(a\), then find the log odds at \(a=1,b=3\). (Answer: odds ratio \(e^{0.8}=2.2255\); log odds \(-0.8\).)
  4. A Poisson log-link model has \(\log(\mu)=0.4+0.03x+0.06z+0.01xz\), where both predictors are measured in stated units. At \(x=4\), calculate the change in log mean for a one-unit increase in \(z\), the corresponding rate ratio, and the linear predictor at \(x=4,z=2\). (Answer: log-mean change \(0.10\); rate ratio \(e^{0.10}=1.1052\); linear predictor \(0.4+0.12+0.12+0.08=0.72\).)
  5. A fitted linear predictor is \(\eta=2+0.6x+0.5z-0.2xz\). State the conditional slope for \(x\) at \(z=1\) and at \(z=4\), and explain what the interaction coefficient says about those slopes. (Answer: slopes \(0.4\) and \(-0.2\), respectively; each one-unit increase in \(z\) reduces the link-scale slope for \(x\) by \(0.2\).)
Clinical Biostats