Moderation (When the Effect Depends on Something Else)

Info sheet · Statistics for Psychology & Neuroscience

Author

Andrew Bell

Published

August 13, 2026

Info sheet 0.2 (draft) · Prerequisites: multiple regression; interactions (factorial ANOVA) · Give feedback ↗

Working notes for the author — not shown to students once collapsed; remove before publishing.

  • [ ]

What you’ll get from this sheet

When a third variable changes a relationship rather than explaining it. By the end you should be able to:

  1. Define moderation and see why it’s just an interaction in a regression.
  2. Say why you mean‑centre the predictors first.

Moderation is when a third variable — the moderator — changes the strength or direction of the A→B relationship. In a regression it’s an interaction term (A × moderator); a significant interaction coefficient means the slope of A on the outcome differs across the moderator. Mean‑centre continuous predictors first.

Moderation is an interaction

Where mediation asks does a third variable carry the effect?, moderation asks does the effect’s strength depend on a third variable? If that sounds like the interactions you met in factorial ANOVA — it is. Running a moderated regression is almost exactly like adding an interaction term.

Take a real dataset of IT salaries versus years of experience, and ask a provocative question: is the experience→salary relationship moderated by gender? i.e. does each extra year of experience pay off differently for different groups? Slide the moderation strength and watch the two group slopes.

At moderation strength zero the two lines are parallel: experience pays the same for both groups — no moderation (the interaction coefficient is ~0). Turn it up and the slopes fan apart — experience buys more salary for one group than the other — and turning it negative makes them cross, where the relationship reverses across the moderator. That divergence is the interaction; a significant interaction coefficient is exactly what a moderation test looks for.

Mean‑centre first

One important prep step: mean‑centre the continuous predictors — subtract the mean so each is centred on zero. Why? In a model with an interaction, the individual (“main effect”) coefficients are read off at the point where the other predictor equals zero. “Zero years of experience” sits at the edge of the data, which makes those coefficients awkward and can look wrong. Centring moves zero to the average, where interpretation is natural, and it reduces collinearity between a predictor and its own interaction term. In R that’s scale(x, scale = FALSE).

When the moderator is itself continuous (does the effect of GRE scores on admission depend on reference‑letter strength?), the idea is identical — you just visualise the slope at a few representative moderator values (low / medium / high), since you can’t draw a line for every value.

See it in code

import statsmodels.formula.api as smf
df["exp_c"] = df["experience"] - df["experience"].mean()      # mean-centre
smf.ols("salary ~ exp_c * C(gender)", df).fit().summary()     # interaction = moderation
exp_c = experience - mean(experience);
T = table(exp_c, gender, salary);
fitlm(T, 'salary ~ exp_c*gender')     % the exp_c:gender term is the moderation

The R tab runs live; Python and MATLAB are static references.

The experience × gender interaction is significant. What does that tell you, and why did we mean‑centre?

It tells you the slope relating experience to salary differs by gender — the relationship is moderated by gender (each year of experience pays off differently across groups). We mean‑centred so the lower‑order coefficients are interpreted at the average experience rather than at zero years (which is off at the edge of the data), and to reduce collinearity between experience and its interaction term — neither changes the interaction itself, but both make the rest of the model readable.

Because a moderation is an interaction, the same rules apply: interpret the interaction before the main effects, and don’t read a lower‑order coefficient as “the effect of experience” — it’s the effect when the moderator is zero. Skip mean‑centring and those coefficients get evaluated at zero on each predictor (often outside the data), so they can look non‑significant or wrong even when the effect is real. And a non‑significant interaction doesn’t prove the slopes are equal — it may just be underpowered.

Where this shows up next

Moderation and its sibling mediation round out the GLM extensions. If you can run a factorial ANOVA, you already know almost everything you need here. See Chapter (GLM Extensions).