Why Include an Interaction?
A regression with separate terms for two regressors allows each to contribute to the fitted outcome, but it assumes that the slope for one regressor does not vary with the value of the other. An interaction relaxes that restriction: the association between one regressor and the outcome can depend on another regressor. For example, the fitted change in an outcome for one more hour of training might differ according to a person’s experience level.
An interaction is represented by a product of regressors. The product makes the fitted value nonlinear in the regressors, but the regression remains linear in its coefficients, so it can be estimated by OLS using the regressors and their product as columns of the design matrix. The central interpretive task is to derive the slope at a stated value of the other regressor.
If \(E[u\mid X,Z]=0\), the displayed regression equation specifies the conditional mean of \(Y\) given \(X\) and \(Z\). Without that condition, the equation can still describe a linear projection or fitted regression, but its fitted values should not automatically be called the true conditional mean. In either case, the algebra for interpreting the specified fitted function is the same. An interaction alone does not establish a causal effect.
Deriving Conditional Slopes and Intercepts
Treat \(Z=z\) as fixed in the interaction model. Collect the terms involving \(X\). The result is a straight-line expression in \(X\), whose slope and intercept depend on \(z\).
Thus the conditional intercept, meaning the fitted value at \(X=0\) for a given \(Z=z\), is \(\beta_0+\beta_2z\). The conditional slope with respect to \(X\) is \(\beta_1+\beta_3z\). Reversing the roles of the regressors gives the conditional intercept and slope when \(X=x\) is held fixed.
The coefficient \(\beta_3\) measures how much the slope with respect to \(X\) changes when \(Z\) increases by one unit; equivalently, it measures the change in the slope with respect to \(Z\) when \(X\) increases by one unit. Its units are outcome units per unit of \(X\) per unit of \(Z\). It is not, by itself, the slope of \(Y\) with respect to either regressor at every value.
Include the main effects and the product term, then substitute the coefficient estimates when calculating a prediction.
For the slope in \(X\), hold \(Z=z\) and collect the constant and \(X\) terms.
Report the conditional slope, the value of the variable it is conditional on, and the relevant units.
Worked Example: A Binary-by-Continuous Interaction
Suppose a hypothetical analysis relates a training outcome score \(Y\), measured in points, to training hours \(X\) and a binary indicator \(D\) for prior experience. Let \(D=1\) indicate prior experience and \(D=0\) indicate no prior experience. The fitted model is
Group-specific lines. For the no-experience group, set \(D=0\). The product and \(D\) terms are zero, giving \(\widehat{Y}=20+2X\): the intercept is 20 points and the slope is 2 points per training hour. For the experienced group, set \(D=1\), giving \(\widehat{Y}=25+3.5X\). Its intercept is 25 points and its slope is 3.5 points per training hour.
Fitted values at four training hours. For \(X=4,D=0\), the fitted value is \(20+2(4)+5(0)+1.5(4)(0)=28\) points. For \(X=4,D=1\), it is \(20+2(4)+5(1)+1.5(4)(1)=39\) points.
At four hours, the fitted difference between the experienced and no-experience groups is \(39-28=11\) points. In general, the group difference at \(X=x\) is \(5+1.5x\), not simply 5 points: the coefficient on \(D\) is the group difference when training hours equal zero. These are fitted associations, not evidence that experience or training hours caused score differences.
Continuous-by-Continuous Interactions
When both regressors are continuous, the same algebra applies, but neither variable merely labels a group. Each conditional slope can vary smoothly with the value of the other. The fitted value at a particular pair \((x,z)\) is obtained by substituting both values into the complete equation, including their product.
Worked Example: Slopes That Vary With Both Regressors
Consider a hypothetical model for crop yield \(Y\), measured in kilograms per hectare. Let \(X\) be rainfall measured in units of 10 centimeters, and \(Z\) be fertilizer measured in units of 10 kilograms per hectare. Suppose the fitted equation is
At \(Z=6\), the fitted slope with respect to rainfall is \(3+0.5(6)=6\) kilograms per hectare per 10 centimeters of rainfall. At \(X=4\), the fitted slope with respect to fertilizer is \(2+0.5(4)=4\) kilograms per hectare per 10 kilograms of fertilizer. These are slopes of the fitted function at the stated values, not universal slopes.
For \(X=4\) and \(Z=6\), the fitted yield is
kilograms per hectare. Holding \(Z=6\) fixed, rewrite the fitted function as \(\widehat{Y}=(40+2(6))+(3+0.5(6))X=52+6X\). This shows directly that the conditional intercept at \(X=0\) is 52 kilograms per hectare and the conditional rainfall slope is 6. If \(X=0\) or \(Z=0\) is outside the range of observed data, the corresponding intercept is still a mathematical feature of the fitted line, but may be an extrapolation with limited practical meaning.
Reference Values, Centering, and Group Differences
The main-effect coefficients in an interaction model refer to a particular reference value. In the equation with \(X\), \(D\), and \(XD\), the coefficient on \(D\) is the fitted group difference when \(X=0\); the coefficient on \(X\) is the slope for the group with \(D=0\). If zero is an inconvenient reference, replacing \(X\) by a centered variable can make the coefficients easier to interpret. Centering changes the reference point, not the fitted values.
Worked Example: Centering Changes the Reference Point
Use the fitted training model \(\widehat{Y}=20+2X+5D+1.5XD\), and define \(C=X-5\). Thus \(C=0\) represents five training hours, and \(X=C+5\). Substituting gives
In this centered model, the coefficient 12.5 on \(D\) is the fitted group difference at five hours, since \(C=0\) there. The group difference at \(X=5\) can also be computed from the original model as \(5+1.5(5)=12.5\) points. The interaction coefficient remains 1.5, because shifting the reference point changes the main-effect coefficients but not the difference in slopes.
For an experienced participant with seven training hours, \(C=7-5=2\), so the centered equation gives \(30+2(2)+12.5(1)+1.5(2)(1)=49.5\) fitted points. Substitution in the original equation gives \(20+2(7)+5(1)+1.5(7)(1)=49.5\) points as well. The two equations therefore give the same fitted value.
Common Mistakes and Interpretation Checks
- Calling the interaction coefficient the slope. In a continuous-by-continuous model, the slope in \(X\) is \(\beta_1+\beta_3Z\), not just \(\beta_3\). Substitute the stated value of \(Z\) before interpreting the slope.
- Reading a binary main effect as the group difference everywhere. With a binary-by-continuous interaction, the group difference at \(X=x\) is \(\beta_2+\beta_3x\). The main-effect coefficient \(\beta_2\) gives that difference only at \(X=0\).
- Forgetting the product when predicting. Calculate \(XZ\) from the specified regressor values and include \(\beta_3XZ\). Leaving out the product does not evaluate the fitted interaction model.
- Interpreting a fitted interaction causally. A conditional slope describes a feature of the fitted regression (or, under the stated conditional-mean assumption, the specified conditional mean). Causal interpretation requires additional assumptions beyond the presence of a product term.
Before reporting a result, check the reference value, the units, and whether the relevant regressor values are within the data’s support. A mathematically defined slope or intercept can be difficult to interpret in practice if it refers to an implausible or unobserved combination of regressors.
Check Your Understanding
For each question, state the relevant conditional value or calculation rather than interpreting an interaction coefficient in isolation.
- In \(\widehat{Y}=8+2X+3Z+0.4XZ\), what is the fitted slope with respect to \(X\) when \(Z=5\)?
- For \(\widehat{Y}=10+X+4D+2XD\), where \(D\) is binary, what is the fitted group difference when \(X=3\)?
- Using the model in question 2, calculate the fitted value when \(X=3\) and \(D=1\).
- In a continuous-by-continuous interaction, what does the interaction coefficient measure in terms of conditional slopes?
- Why might the coefficient on a binary regressor not equal the fitted group difference at a practically relevant value of the continuous regressor?