Tutorials › Regression Analysis (Undergraduate) › Why an Interaction Coefficient Is a Slope Difference

Interactions Among Groups · Tutorial 347 of 991

Why an Interaction Coefficient Is a Slope Difference

Use fitted-value changes to show precisely what a group interaction coefficient measures and how its sign and units relate to the reference group’s slope.

Intermediate 9 min read

What You'll Learn

  • Write a group-specific linear model using reference-group indicator variables
  • Derive a group’s fitted slope from the change in its fitted values
  • Show why an interaction coefficient equals a non-reference group’s slope minus the reference group’s slope
  • Interpret the sign and units of an interaction coefficient in context
  • Distinguish a group’s slope from its interaction coefficient
  • Identify why the same reference group is used for each interaction coefficient

Why the Interaction Coefficient Is a Slope Difference

When a quantitative predictor has a different fitted relationship with an outcome across groups, a regression model can represent that variation using interaction terms. The interpretation of the interaction coefficient is easy to misstate: for a non-reference group, it is not that group’s slope. It is the difference between that group’s slope and the reference group’s slope. We can establish this directly by comparing changes in fitted values.

The distinction matters when describing a model. If the reference group’s fitted slope is 2 outcome units per predictor unit and another group’s interaction coefficient is \(-0.5\), the second group’s slope is \(2-0.5=1.5\), not \(-0.5\). The interaction coefficient describes how much the slope changes relative to the reference.

The Model and Its Group-Specific Slopes

Suppose the outcome \(Y\) is related to a quantitative predictor \(x\) and a categorical group variable with \(G\) groups. Label one group as the reference group, and label the others \(2,\ldots,G\). For each non-reference group \(j\), let \(I(G_i=j)\) equal 1 when observation \(i\) belongs to group \(j\), and 0 otherwise. The reference group has all these indicators equal to 0.

Model: A linear model with group-specific intercepts and slopes can be written as
$$ Y_i=\beta_0+\beta_1x_i+\sum_{j=2}^{G}\delta_j I(G_i=j)+\sum_{j=2}^{G}\gamma_j x_i I(G_i=j)+\epsilon_i. $$

Here, \(\beta_0\) is the reference group’s intercept and \(\beta_1\) is its slope. For each non-reference group \(j\), \(\delta_j\) allows its intercept to differ from the reference group’s intercept, and \(\gamma_j\) is its quantitative-predictor-by-group interaction coefficient. The fitted values use the estimated coefficients, written with hats: \(\hat\beta_0,\hat\beta_1,\hat\delta_j,\hat\gamma_j\).

The model describes a straight-line conditional mean within each group. For statistical interpretations of the fitted conditional means, the usual regression conditions include a correctly specified conditional mean, errors with mean zero at each predictor and group combination, and independent errors with constant variance. Normal errors are additionally used for exact small-sample t-based inference. The algebra below concerns the fitted lines themselves: the identity between an interaction coefficient and a slope difference follows from the model form and does not depend on those error assumptions.

To see what the fitted lines are, set the group indicators to their appropriate values. In the reference group, all indicators are zero, so its fitted value at \(x\) is \(\hat\beta_0+\hat\beta_1x\), with slope \(\hat\beta_1\). In non-reference group \(j\), its indicator equals 1 and all the other non-reference indicators equal 0. Its fitted value is \((\hat\beta_0+\hat\delta_j)+(\hat\beta_1+\hat\gamma_j)x\). Therefore its slope is \(\hat\beta_1+\hat\gamma_j\).

Deriving the Slope Difference From Fitted Values

A slope is the change in fitted outcome divided by the change in predictor. Choose any predictor value \(x\) and a nonzero increment \(h\). For the reference group, moving from \(x\) to \(x+h\) changes the fitted value by \(\hat\beta_1h\). For group \(j\), the change is \((\hat\beta_1+\hat\gamma_j)h\). The group-specific intercept terms cancel within each change because they do not depend on \(x\).

Now subtract the reference group’s fitted change from group \(j\)’s fitted change. The result, divided by the same predictor increment, is the difference between the two slopes:

$$ \begin{aligned} \hat y_j(x+h)-\hat y_j(x) &=(\hat\beta_1+\hat\gamma_j)h,\\ \hat y_{\mathrm{ref}}(x+h)-\hat y_{\mathrm{ref}}(x) &=\hat\beta_1h,\\ \frac{[\hat y_j(x+h)-\hat y_j(x)]-[\hat y_{\mathrm{ref}}(x+h)-\hat y_{\mathrm{ref}}(x)]}{h} &=\frac{(\hat\beta_1+\hat\gamma_j)h-\hat\beta_1h}{h}\\ &=\hat\gamma_j. \end{aligned} $$
Theorem: In this reference-group model, the interaction coefficient for non-reference group \(j\) equals that group’s fitted slope minus the reference group’s fitted slope: $$ \hat\gamma_j=(\hat\beta_1+\hat\gamma_j)-\hat\beta_1. $$ It measures the difference in fitted outcome change per one-unit increase in \(x\), not the group’s slope by itself.

The increment \(h\) can be any nonzero value because the fitted relationships are straight lines. A larger increment changes the fitted outcomes by a proportionally larger amount, and division by \(h\) returns the same slope difference. The group-specific intercept difference \(\hat\delta_j\) does not appear: changing an intercept shifts a line up or down but does not change its slope.

Worked Example: A Two-Group Slope Difference

Suppose a hypothetical fitted model predicts a health score from weekly exercise hours for two groups, A and B. The outcome is measured in score points, and group A is the reference group. The fitted equation is

$$ \hat y=142+1.8x-4I(B)-0.6xI(B). $$

For group A, \(I(B)=0\), so its fitted line is \(\hat y_A=142+1.8x\). Its slope is \(1.8\) score points per exercise hour. For group B, \(I(B)=1\), so \(\hat y_B=(142-4)+(1.8-0.6)x=138+1.2x\). Its slope is \(1.2\) score points per exercise hour. The group B interaction coefficient is \(-0.6\), and the slope difference is

$$ 1.2-1.8=-0.6\text{ score points per exercise hour}. $$

The same result follows from fitted-value changes. From \(x=2\) to \(x=5\), group A’s fitted value changes from \(142+1.8(2)=145.6\) to \(142+1.8(5)=151\), a change of \(151-145.6=5.4\) points. Group B’s fitted value changes from \(138+1.2(2)=140.4\) to \(138+1.2(5)=144\), a change of \(144-140.4=3.6\) points. The difference in changes per hour is

$$ \frac{3.6-5.4}{5-2}=\frac{-1.8}{3}=-0.6\text{ score points per exercise hour}. $$

Thus, the fitted score increases by 0.6 fewer points per additional weekly exercise hour in group B than in group A. This describes the fitted association; it does not establish that exercise causes the score to change.

Worked Example: Two Interaction Coefficients and One Reference Slope

Consider a hypothetical model of a task score, in points, versus training hours. The reference group is in-person training; the other groups are remote and hybrid. Suppose the fitted model is

$$ \hat y=40+0.75x+3I(\text{remote})-2I(\text{hybrid})+0.20xI(\text{remote})-0.15xI(\text{hybrid}). $$

The reference-group fitted line is \(\hat y_{\mathrm{in\ person}}=40+0.75x\), with slope \(0.75\) points per training hour. For remote training, the slope is \(0.75+0.20=0.95\) points per hour. Its interaction coefficient compares the remote slope with the in-person slope:

$$ 0.95-0.75=0.20\text{ points per training hour}. $$

For hybrid training, the slope is \(0.75-0.15=0.60\) points per hour, so its interaction coefficient compares the hybrid slope with that same in-person reference slope:

$$ 0.60-0.75=-0.15\text{ points per training hour}. $$

Check these comparisons using fitted-value changes from \(x=4\) to \(x=8\). The in-person change is \(0.75(8-4)=3.00\) points. The remote change is \(0.95(8-4)=3.80\) points, so its change per hour beyond the reference is \((3.80-3.00)/4=0.20\). The hybrid change is \(0.60(8-4)=2.40\) points, so its difference per hour from the reference is \((2.40-3.00)/4=-0.15\). Each coefficient compares its own non-reference group with the same reference group; neither coefficient is the group’s entire slope.

Worked Example: Recovering the Interaction From Fitted Values

Suppose a hypothetical fitted model predicts an outcome in milligrams per liter from a quantitative exposure \(x\), measured in units. Group R is the reference group and group S is the non-reference group. The fitted values are \(20+2.4x\) for R and \(26+1.5x\) for S. Find the interaction coefficient for S using fitted values, and interpret it.

Use \(x=1\) and \(x=4\), a change of \(4-1=3\) exposure units. For R, the fitted values are \(20+2.4(1)=22.4\) and \(20+2.4(4)=29.6\) mg/L. Its change is \(29.6-22.4=7.2\) mg/L. For S, the fitted values are \(26+1.5(1)=27.5\) and \(26+1.5(4)=32.0\) mg/L. Its change is \(32.0-27.5=4.5\) mg/L.

The difference in fitted changes, divided by the predictor change, is

$$ \frac{4.5-7.2}{4-1}=\frac{-2.7}{3}=-0.90\text{ mg/L per exposure unit}. $$

The group S slope is \(1.5\) mg/L per exposure unit and the reference slope is \(2.4\) mg/L per exposure unit, giving \(1.5-2.4=-0.90\) mg/L per exposure unit. The interaction coefficient is therefore \(-0.90\). In this fitted model, group S’s outcome changes by 0.90 mg/L less per exposure unit than group R’s outcome.

Reading the Coefficient Correctly

The sign of an interaction coefficient gives the direction of the slope difference relative to the reference group. A positive coefficient means the non-reference group’s fitted slope is greater; a negative coefficient means it is smaller. “Greater” and “smaller” refer to the numerical slopes, which may themselves be positive, negative, or zero. For example, a positive interaction could mean that one group’s outcome decreases less steeply, rather than increases more steeply.

The coefficient’s units are outcome units per predictor unit, just like a slope. An intercept indicator coefficient has outcome units, because it describes a fitted difference in outcome at \(x=0\); it does not measure a slope change. The interaction coefficient instead compares changes in fitted outcomes across \(x\). These units are a useful check: a quantity stated only in outcome units cannot be a slope difference.

With several groups, each interaction coefficient is measured against the one reference group specified in the model. For three groups, the remote interaction coefficient compares the remote slope with the reference slope, and the hybrid interaction coefficient compares the hybrid slope with that same reference slope. It does not compare remote with hybrid, and it is not the non-reference group’s slope itself.

Common Mistake

  • Wrong reasoning: “The interaction coefficient for group B is \(-0.6\), so group B’s slope is \(-0.6\).” This confuses the amount of slope change with the resulting slope.
  • Correction: Add the interaction coefficient to the reference slope. If the reference slope is \(1.8\) and the interaction coefficient is \(-0.6\), group B’s slope is \(1.8-0.6=1.2\). Equivalently, the coefficient is \(1.2-1.8=-0.6\).
  • Another check: Compute the fitted-value change within each group over the same predictor interval. Subtract the reference group’s change from the other group’s change, then divide by the predictor interval. The result is the interaction coefficient.

This fitted-value argument is useful because it connects the algebraic term in the model to the quantity it describes: how much the fitted outcome’s rate of change differs between groups. It also provides a direct way to check an interpretation without relying on a verbal rule about signs.

Check Your Understanding

For each question, distinguish the non-reference group’s slope from its interaction coefficient.

  1. The reference slope is 3 outcome units per predictor unit, and a group’s interaction coefficient is \(-0.8\). What is that group’s fitted slope, and how should the interaction be interpreted?
  2. Why do group-specific intercept terms disappear when calculating the change in fitted value from \(x\) to \(x+h\)?
  3. In a three-group model, why does each non-reference group’s interaction coefficient compare that group’s slope with the same reference group’s slope?
  4. A group’s fitted outcome changes by 6 units over a 2-unit increase in \(x\), while the reference group’s fitted outcome changes by 5 units over that same increase. What is the interaction coefficient for that group?
  5. If a group’s slope is \(-1.2\) and the reference slope is \(-0.7\), what is the interaction coefficient? Is the group’s outcome decreasing more or less steeply than the reference group’s fitted outcome?