Interactions in Regression
Sometimes the effect of one predictor depends on another. A training program might help beginners a lot and experts barely at all; a drug's benefit might grow with the dose only for younger patients. The factorial-ANOVA interaction idea lives in regression too, through an interaction term.
Adding a product term
A model with two predictors and their interaction looks like this:
ŷ = b₀ + b₁·x + b₂·group + b₃·(x × group)
That last term (the product of the two predictors) is the whole trick. Its coefficient b₃ measures how much the slope of x changes between groups. If b₃ = 0, both groups share one slope (the lines are parallel, just a level difference). If b₃ ≠ 0, the groups have different slopes: x matters more for one than the other.
🎮 The Interaction Term Tilts the Lines
Two groups, one continuous predictor x. Slide the interaction: at zero the lines are parallel; turn it up and the orange group's slope pulls away from the blue group's.
Why the main effects get tricky
When an interaction is present, the "main effect" of x is no longer a single number: it's different in each group, so quoting one average slope can be misleading. With a product term in the model, b₁ becomes the slope of x specifically when group = 0 (the reference), not an overall effect. This is the #1 source of confusion in interpreting interaction models.
Center your predictors. Interpreting interactions is far easier when continuous predictors are mean-centered first. Then b₁ and b₂ read as effects "at the average" of the other variable, instead of at the often-meaningless value of zero. It also reduces multicollinearity between the predictors and their product.
Continuous × continuous interactions
Interactions aren't just for groups. Two continuous predictors can interact too: the effect of advertising spend on sales might depend on the season. These are harder to picture (the "lines" become a tilted surface), so we usually probe them with simple slopes: plot the effect of x at a few representative values of the moderator (say, low / medium / high), exactly as we did with two groups here.
Why it matters: "it depends" is one of the most honest and useful things data can tell you, and interactions are how you say it rigorously. They're essential whenever an effect isn't one-size-fits-all — which is most of the time.
One warning before you design around one: an interaction is estimated less precisely than the effects it qualifies, so a study powered to find a main effect is usually not powered to find the interaction that explains it. Power analysis for complex designs works out what that costs.
Problem 24 of the practice problems puts a group difference and a pretest covariate in one model and asks what the raw 6.4-point advantage was really measuring, and Problem 26 is the classic trap: an abstract that reports the main effect when the interaction is the whole story.
Common questions
Why should I center variables before creating an interaction term?
Two reasons. Interpretability: with a product term in the model, b₁ is the effect of x₁ when the other variable equals zero — often a meaningless value (age 0, income 0); centering moves "zero" to the mean, so b₁ reads as the effect at a typical value. Stability: centering also reduces the artificial correlation between x and x×z, taming multicollinearity in the estimates.
Do I have to keep the main effects if only the interaction is significant?
Yes, keep them. This is the principle of marginality: a model containing x·z should also contain x and z. Drop a main effect and you force that variable's line through a constrained origin, so the surviving coefficients no longer mean what their names suggest and the interaction absorbs whatever the dropped term was carrying. The fit also stops being invariant to how you coded the variables, which means rescaling a predictor can change your conclusion. A non-significant main effect alongside a significant interaction is not a problem to tidy away; it is the ordinary result of an effect that is real in one condition and absent in the other, and it is the finding.
What are simple slopes?
The effect of x computed at chosen values of the moderator — conventionally at its mean and ±1 SD. They turn an abstract product coefficient into direct statements: "among low-experience users the feature gains 4 points; among high-experience users, 0.5." Simple-slope tests then tell you at which moderator values the effect is significantly different from zero.