Mediation explains how or why an independent variable affects an outcome (a variable sits in the causal path between them), while moderation explains when, for whom, or under what conditions the effect is stronger or weaker (a variable changes the size or direction of the effect). If you've been staring at your thesis model wondering whether your third variable is a "mediator" or a "moderator," the confusion is completely normal — the two concepts sound similar but answer entirely different research questions.
Key Takeaways
- Mediation tests a mechanism: X → M → Y. The mediator (M) is the middle step that transmits the effect (e.g., exercise → better sleep → lower anxiety).
- Moderation tests a condition: the effect of X on Y depends on the level of a moderator (W). The moderator interacts with X (e.g., therapy reduces depression more for people with strong social support).
- The quickest test: ask "Does this variable carry the effect (mediation) or change the strength of the effect (moderation)?"
- Mediation is usually assessed with an indirect effect and a bootstrapped 95% confidence interval; moderation is assessed with an interaction term in a regression.
- A single study can test both together (moderated mediation or conditional indirect effects).
What Is Mediation Analysis?
Mediation analysis tests whether a third variable, called a mediator, explains the relationship between an independent variable and an outcome — it answers the question "how does X affect Y?" The logic is a chain: X influences the mediator (M), and the mediator in turn influences Y.
A classic example: suppose higher socioeconomic status (X) predicts better academic performance (Y). Mediation asks why. Maybe SES leads to more access to tutoring (M), and tutoring is what actually drives performance. Here tutoring is the mechanism carrying the effect.
Mediation splits the total effect of X on Y into two parts:
- Direct effect — the influence of X on Y that does not pass through the mediator.
- Indirect effect — the influence of X on Y that flows through the mediator (calculated as a × b, where a is X → M and b is M → Y).
Full mediation means the indirect effect explains essentially all of the relationship; partial mediation means some direct effect remains.
What Is Moderation Analysis?
Moderation analysis tests whether the strength or direction of the relationship between X and Y changes depending on the level of a third variable, called a moderator — it answers "when or for whom does X affect Y?" Unlike a mediator, a moderator does not sit in the causal chain; it sits alongside it and bends the effect.
An example: suppose a stress-management program (X) reduces burnout (Y). Moderation asks whether that works equally for everyone. Perhaps the program helps employees with low job control (W) far more than those with high job control. Job control is the moderator — the program's effect depends on it.
Statistically, moderation is captured by an interaction term: you multiply X by W and enter that product into a regression. A significant interaction coefficient tells you the effect of X on Y is not constant.
Mediation vs Moderation: Key Differences
| Feature | Mediation | Moderation |
|---|---|---|
| Core question | How / why does X affect Y? | When / for whom does X affect Y? |
| Role of third variable | Mechanism in the causal path (X → M → Y) | Condition that alters the effect (X × W → Y) |
| Statistical signature | Indirect effect (a × b) | Interaction term (X × W) |
| Causal assumption | M is caused by X | W is independent of X |
| Typical output | Bootstrapped CI for indirect effect | Regression coefficient for the interaction |
| Plain-English label | "Because of…" | "It depends on…" |
The one-line memory trick: mediation is a relay race (the baton passes through the mediator); moderation is a dimmer switch (the moderator turns the effect up or down).
A Worked Example With Real Numbers
Imagine a study of 120 college students examining whether mindfulness practice (X) predicts lower exam anxiety (Y).
Testing mediation. You hypothesise that mindfulness works by improving sleep quality (M). Using bootstrapping (5,000 resamples) in a tool like StatRyx, you find:
- Path a (mindfulness → sleep): b = 0.42, p = .003
- Path b (sleep → anxiety): b = −0.38, p = .001
- Indirect effect (a × b) = −0.16, 95% CI [−0.28, −0.06]
Because the 95% confidence interval does not include zero, the indirect effect is significant — sleep quality mediates the mindfulness–anxiety link. In APA 7 you'd write: The indirect effect of mindfulness on exam anxiety through sleep quality was significant, b = −0.16, 95% CI [−0.28, −0.06].
Testing moderation. Now you wonder whether mindfulness helps first-year students more than final-year students, so year of study (W) is your moderator. You run a regression with the interaction term and find:
- Interaction (mindfulness × year): b = 0.21, t(116) = 2.34, p = .021
The significant interaction means the effect of mindfulness on anxiety differs by year group. Probing it (simple slopes) shows mindfulness strongly reduces anxiety for first-years (b = −0.45, p < .001) but not for final-years (b = −0.09, p = .38). In APA 7: Year of study moderated the effect of mindfulness on anxiety, b = 0.21, t(116) = 2.34, p = .021.
Same dataset, two utterly different stories: one about mechanism, one about condition.
Which Analysis Do I Actually Need?
Pick mediation when your research question contains a process word — "explains," "because," "mechanism," "pathway," "through." You believe X changes something (M) that then changes Y.
Pick moderation when your question contains a contingency word — "depends," "differs by," "stronger for," "only when," "for whom." You believe the same effect isn't the same for everybody.
A quick reality check: a mediator must be measured after X (it's an outcome of X), while a moderator is typically measured before or independent of X (like gender, age, or a baseline trait). If your third variable is a stable characteristic that X can't plausibly cause, it's almost certainly a moderator, not a mediator. If you're still unsure which regression setup applies, our guide on choosing the right statistical test walks through the decision tree.
How to Run Mediation and Moderation Correctly
Both analyses trip people up in the same place: the calculations are fiddly and the reporting is unforgiving. Mediation requires bootstrapped confidence intervals (the old Sobel test and the four-step Baron & Kenny method are now considered underpowered), and moderation requires you to mean-centre or standardise your predictors before building the interaction term to avoid multicollinearity.
This is exactly the kind of workflow StatRyx was built for — you upload your data, tell it your X, Y, and third variable, and it selects the correct model, runs the bootstrapping, probes the interaction with simple slopes, and returns an APA 7-formatted write-up you can paste straight into your results section. Where SPSS requires the separate PROCESS macro (and around $99+/month for a subsc