A mediator explains how or why an independent variable affects an outcome: it sits on the causal path, so X changes M and M changes Y. A moderator changes when, for whom or how strongly X affects Y, and it is tested as an interaction term. This guide runs one hypothetical study through both analyses with numbers, then shows published examples and how to report each.
Key Takeaways
- A mediator answers “how” or “why” and sits between X and Y (X → M → Y). A moderator answers “when” or “for whom” and changes the size or direction of the X → Y link.
- Mediation is measured by the indirect effect a × b, which in ordinary regression equals c − c′, the drop in the X effect once M is added.
- Moderation is an X × W interaction term, explained with simple slopes at two or more values of W.
- A bootstrap confidence interval for a × b is now the recommended test in place of Baron and Kenny’s (1986) causal steps; a significant total effect is no longer required.
- Adjusting for a mediator removes part of the effect; adjusting for a confounder removes bias.
What is the difference between a mediator and a moderator?
A mediator is the mechanism: the independent variable changes it, and it in turn changes the outcome. A moderator is a condition: it does not carry the effect but changes how large the effect is, or its direction, for different people or settings. Kraemer and colleagues put it in two sentences: moderators “identify on whom and under what circumstances treatments have different effects. Mediators identify why and how treatments have effects.”
| Mediator | Moderator | |
|---|---|---|
| Question it answers | How or why does X affect Y? | When, for whom or how strongly does X affect Y? |
| Causal position | Between X and Y: X causes M, M causes Y | Outside the chain: W is not caused by X |
| Diagram | Arrows X → M → Y, plus a direct arrow X → Y | An arrow from W pointing at the X → Y arrow |
| How it is tested | Indirect effect a × b with a bootstrap confidence interval | X × W interaction term in a regression, then simple slopes |
| Hypothesis wording | “X increases Y through M” | “The effect of X on Y is weaker when W is high” |
| Adjust for it as a covariate? | No: it removes part of the effect | Include it with its interaction term |
Both are third variables, beside the independent and dependent variables a study is built around, and the glossary entry on variables in research lists the other types. Baron and Kenny wrote their 1986 paper partly to make researchers aware “of the importance of not using the terms moderator and mediator interchangeably”.
What is a mediating variable?
A mediating variable carries the effect of X to Y. Mediation is described with four paths: c is the total effect of X on Y; a is the effect of X on the mediator; b is the effect of the mediator on Y holding X constant; and c′ is the direct effect of X on Y once the mediator is in the model. The indirect effect, a × b, measures the amount of mediation.
David Kenny’s mediation page ties them together: c = c′ + ab, so the indirect effect also equals c − c′. That holds exactly in multiple regression when “the same cases are used in all the analyses” and every equation has the same covariates; for logistic models it is only approximate.
What is a moderating variable?
A moderating variable changes the relationship between X and Y without being part of it. Fairchild and MacKinnon describe moderators as variables that “affect the strength and/or direction of the relation between a predictor and an outcome: enhancing, reducing, or changing the influence of the predictor.” Age, gender, prior ability and context are common moderators because they are not caused by the treatment.
Moderation is tested in one regression with an interaction term: Y = b₀ + b₁X + b₂W + b₃XW. If b₃ differs from zero, the slope of Y on X depends on W; the slope at one chosen value of W is a simple slope.
Mediator vs moderator: a worked example with numbers
The study and every number in this section are invented for illustration. Two hundred first-year students either join a study-skills programme (X = 1) or do not (X = 0). We record weekly study hours (M), exam score out of 100 (Y) and test anxiety from 0 to 10 (W, mean 5, standard deviation 3).
Mediation: does study time explain the programme’s effect?
Three ordinary least squares regressions on the same 200 students give the four paths:
| Equation | Fitted model | Path |
|---|---|---|
| 1. Y on X | Y = 62 + 6.0X | c = 6.0 (total effect) |
| 2. M on X | M = 8 + 2.5X | a = 2.5 hours |
| 3. Y on X and M | Y = 49.2 + 2.0X + 1.6M | c′ = 2.0, b = 1.6 |
The programme adds 2.5 study hours a week, and each hour is worth 1.6 exam points within the same group. The indirect effect is 2.5 × 1.6 = 4.0 points, and the difference method agrees: 6.0 − 2.0 = 4.0. Two thirds of the 6-point gain runs through study time; the other 2.0 points come from something else the programme does.
To test the 4.0, resample the 200 students with replacement 5,000 times, recompute a × b each time, and take the 2.5th and 97.5th percentiles. Suppose that gives 2.1 to 6.2: the interval excludes zero, so the indirect effect is significant. It is not centred on 4.0 because a product of two estimates has a skewed sampling distribution. Note also that adding M cut the programme’s coefficient from 6.0 to 2.0, which is why a mediator is not a control variable when you want the total effect.
Moderation: does anxiety change the programme’s effect?
A second regression adds anxiety and its product with the programme: Y = 64.5 + 12.0X − 0.5W − 1.2XW. The interaction coefficient is −1.2 (SE = 0.52, t(196) = −2.30, p = .022). Each point of anxiety shrinks the programme’s effect by 1.2 exam points, so the effect is 12.0 − 1.2W. Simple slopes one standard deviation below and above the mean of anxiety:
| Anxiety (W) | No programme | Programme | Programme effect |
|---|---|---|---|
| Low (2, mean − 1 SD) | 63.5 | 73.1 | 9.6 points |
| Average (5) | 62.0 | 68.0 | 6.0 points |
| High (8, mean + 1 SD) | 60.5 | 62.9 | 2.4 points |
Two details trip students up. First, b₁ = 12.0 is the programme effect at zero anxiety; centre W at its mean, as Fairchild and MacKinnon recommend, and the X coefficient becomes 12.0 − 1.2 × 5 = 6.0, the effect at average anxiety. Second, the interaction alone does not say where the effect is strong; the simple slopes do.
How do you test for mediation? Baron and Kenny and the indirect effect
The classic test is Baron and Kenny’s three regressions: the mediator on X, Y on X, and Y on both. Mediation was claimed if X predicted the mediator, X predicted Y, the mediator predicted Y with X controlled, and the X effect shrank once the mediator was added. Current practice tests the indirect effect a × b directly, usually with a percentile bootstrap confidence interval, and drops the requirement that X predicts Y.
As quoted by Zhao, Lynch and Chen, Baron and Kenny required that “a previously significant relation between the independent and dependent variables is no longer significant, with the strongest demonstration of mediation occurring when Path c is zero.” (Their Path c is the direct effect, c′ in this guide.) In 2010 Zhao and colleagues argued that the strength of mediation is the size of the indirect effect, not the absence of a direct effect; that “There should be only one requirement to establish mediation, that the indirect effect a × b be significant”; and that the Sobel test Baron and Kenny recommended “is low in power compared to a bootstrap test popularized by Preacher and Hayes (2004)”. Kenny’s own page now says of the Sobel test: “It should no longer be used,” and recommends the percentile bootstrap without bias correction.
Zhao and colleagues also renamed the types: indirect-only mediation (no direct effect) overlaps with full mediation, complementary mediation (both effects in the same direction) with partial mediation, and competitive mediation has effects of opposite sign. In the worked example c′ = 2.0 is not significant (t(197) = 1.43, p = .15), so the result is indirect-only.
A published case where the old rule failed. Zhao and colleagues reanalysed data on brands advertised during the 1994 Super Bowl: X was the number of ads a brand placed, M was clutter, “the total number of other ads in the same commercial breaks”, and Y was audience liking on a 0 to 1 scale. More ads meant more clutter (a = 2.53), and clutter lowered liking (b = −.0208), an indirect effect of −.0527 (95% CI −.0930 to −.0268). The direct effect was +.057, so the two cancelled out: the total effect was .0043 (p = .74), and the paper was rejected by the first journal it went to for failing Baron and Kenny’s X-to-Y test. In Kenny’s notation that is c = .0043 and c′ = .057; Zhao and colleagues swap the two letters.
Preacher and Hayes (2008) published SPSS and SAS macros for the bootstrap test of the indirect effect. Hayes’s PROCESS macro now runs it in SPSS, SAS and, from the 2022 third edition of his book, R; lavaan and Mplus bootstrap too.
How do you test for moderation?
Fit one regression with X, W and their product, and test the product’s coefficient. If it is significant, compute the effect of X at chosen values of W (often the mean and one standard deviation either side, or each group of a categorical moderator) and plot the lines. Report the interaction coefficient and the simple slopes together.
A published example. Tharakan and Ford (2026) linked Gallup survey answers from Chicago residents (5,054 observations in the moderation models) to the time the city took to fill reported potholes in each ZIP code; longer repair times went with lower life satisfaction. With a binary moderator, whether a ZIP code’s Black and Hispanic share was above the city average, the slope for weeks to completion in the whiter ZIP codes was −0.33 and the interaction coefficient 0.27 (Wald p = .04). In the authors’ words, the relationship in whiter neighbourhoods “is negative, while the relationship for above-average Black/Hispanic is close to zero.” Individual race and ethnicity was not a significant moderator, so the level at which a moderator is measured matters.
Why does mediation need time order and causal assumptions?
Mediation is a causal claim about a chain: X must come before M, and M before Y. A regression on data collected at one moment still produces a, b and an indirect effect, but the numbers mean little if Y could cause M or a third variable drives both. Randomly assigning X does not randomise the mediator.
Kenny lists four assumptions for the indirect effect: no X × M interaction, causal direction (M causes Y, not the reverse), perfect reliability of M, and “No Confounding: There is no variable that causes M and Y.” He notes that Baron and Kenny (1986) “does not even mention confounding as an assumption.”
Time order is the assumption a one-time survey cannot check. Maxwell and Cole (2007) observed that “Most empirical tests of mediation utilize cross-sectional data despite the fact that mediation consists of causal processes that unfold over time,” and showed that such analyses typically give substantially biased estimates, even when mediation is complete. Kenny reports a review by Gelfand and colleagues of 50 mediation studies published in 2002, where 54% used cross-sectional data. If your design is a cross-sectional study, call the result an indirect association and say so in the limitations.
Mediator vs confounder vs moderator
All three are third variables; they differ in where they sit. A confounder causes both X and Y and biases the estimate unless you control it. A mediator is caused by X and causes Y, so it is part of the effect. A moderator sits off the path and changes the size of the X effect.
| Variable | Position | Example in the worked study | What to do with it |
|---|---|---|---|
| Confounder | Causes both X and Y | Motivation: motivated students join the programme and also score higher | Control it (design or adjustment) |
| Mediator | Caused by X, causes Y | Weekly study hours | Estimate a × b; do not adjust for it when you want the total effect |
| Moderator | Changes the X → Y effect | Test anxiety | Add an X × W interaction and report simple slopes |
Our guide to confounding variables gives a medical version of the mediator row: cholesterol sits on the path from diet to heart disease, so adjusting for it removes part of the effect, just as adding study hours cut the programme’s coefficient from 6.0 to 2.0.
What is moderated mediation?
Moderated mediation means the indirect effect itself depends on a moderator: the path through M is stronger for some people than for others. Fairchild and MacKinnon describe the question as “whether the indirect effect is moderated, or whether the mediated effect depends on levels of another variable.” Hayes’s book covers such models under the name conditional process analysis.
Fairchild and MacKinnon’s illustration: calcium intake (X) raises bone density (M), which reduces broken bones (Y), and gender (W) moderates the first link because “the relation between calcium intake and bone density is stronger in women than it is in men.” In the worked example, if anxious students added fewer study hours, path a and with it a × b would shrink at high anxiety.
How to write mediation and moderation hypotheses
A mediation hypothesis names the mechanism and its direction. A moderation hypothesis names the condition and says whether it strengthens, weakens or reverses the effect. State each before collecting data, using the variable names from your methods section, so every hypothesis maps to one test.
- Mediation: “Joining the study-skills programme will increase exam scores indirectly, by increasing weekly study hours.”
- Moderation: “The effect of the programme on exam scores will be weaker for students with higher test anxiety.”
- Moderated mediation: “The indirect effect of the programme through study hours will be smaller for students with higher test anxiety.”
Directional and null versions are in our hypothesis examples, and the glossary defines a hypothesis statement.
How to report mediation and moderation in APA style
For mediation, report the unstandardised coefficient for each path, the indirect effect with its bootstrap confidence interval, and the number of resamples. For moderation, report the interaction coefficient with its test, then the simple slopes. Zhao and colleagues ask for “the mean value of a × b and the 95% confidence interval from the bootstrap analysis” alongside the unstandardised paths.
Two illustrative sentences using the invented numbers above:
The programme increased weekly study hours, a = 2.50, SE = 0.60, p < .001, and study hours predicted exam scores controlling for the programme, b = 1.60, SE = 0.16, p < .001. The indirect effect was 4.00 points, 95% CI [2.10, 6.20], based on 5,000 percentile bootstrap resamples; the direct effect was not significant, c′ = 2.00, SE = 1.40, p = .15.
Test anxiety moderated the effect of the programme, b = −1.20, SE = 0.52, t(196) = −2.30, p = .022. The programme raised scores by 9.60 points at low anxiety (1 SD below the mean) and by 2.40 points at high anxiety (1 SD above).
Put the path diagram in a figure and the regression output in a table. Our guide to writing a results section covers where each statistic goes and how to report a non-significant result.
Where Papero fits
Papero is an AI writing workspace for students and researchers. It does not run regressions, bootstraps or any other statistical analysis; you do those in SPSS, R or similar software. Papero helps with the writing around them: finding and citing the methods papers, and drafting each section from its prompt.
Search scholarly works in OpenAlex or paste the DOI of a methods paper, such as the 2010 critique by Zhao and colleagues, save it to your source library, and cite it in APA 7 or any of the over 10,000 styles Papero supports. Regression equations can be written in TeX, and on Plus, cited suggestions draw on your own sources first. The thesis writing page shows the whole workflow. What each plan includes is on the pricing page.
Frequently Asked Questions
What is an example of a mediator?
If a study-skills programme raises exam scores partly because it increases the hours students spend studying, study hours are the mediator. In a published case, brands that placed more ads in the 1994 Super Bowl faced more advertising clutter, and clutter lowered how much viewers liked their ads: clutter mediated the effect of ad frequency on liking.
What is an example of a moderator variable?
Test anxiety would moderate the effect of a study-skills programme if the programme raised scores by about 10 points for calm students and about 2 points for anxious ones. In a 2026 Chicago study, faster pothole repairs went with higher life satisfaction in whiter neighbourhoods, but the link was close to zero in neighbourhoods with an above-average Black and Hispanic population.
Can a variable be both a mediator and a moderator?
The same variable can mediate in one research question and moderate in another. A mediator must be changed by the independent variable, while a moderator is usually measured before it and not changed by it. Anxiety that the treatment changes is a candidate mediator; anxiety measured before the treatment that alters its effect is a moderator.
Is age a mediator or a moderator?
Age is almost always a moderator or a confounder, not a mediator, because no treatment or exposure changes a person’s age. If age alters how strongly a treatment works, it is a moderator; if it affects both the exposure and the outcome, it is a confounder.
Sources
- Baron, R. M., & Kenny, D. A. (1986). The moderator–mediator variable distinction in social psychological research: Conceptual, strategic, and statistical considerations. Journal of Personality and Social Psychology, 51(6), 1173–1182. https://doi.org/10.1037/0022-3514.51.6.1173
- Zhao, X., Lynch, J. G., Jr., & Chen, Q. (2010). Reconsidering Baron and Kenny: Myths and truths about mediation analysis. Journal of Consumer Research, 37(2), 197–206. https://doi.org/10.1086/651257
- Kenny, D. A. (2025, March 7). SEM: Mediation (davidakenny.net, November 2026). https://davidakenny.net/cm/mediate.htm
- Kraemer, H. C., Wilson, G. T., Fairburn, C. G., & Agras, W. S. (2002). Mediators and moderators of treatment effects in randomized clinical trials. Archives of General Psychiatry, 59(10), 877–883. https://doi.org/10.1001/archpsyc.59.10.877
- Fairchild, A. J., & MacKinnon, D. P. (2009). A general model for testing mediation and moderation effects. Prevention Science, 10(2), 87–99. https://doi.org/10.1007/s11121-008-0109-6
- Maxwell, S. E., & Cole, D. A. (2007). Bias in cross-sectional analyses of longitudinal mediation. Psychological Methods, 12(1), 23–44. https://doi.org/10.1037/1082-989X.12.1.23
- Preacher, K. J., & Hayes, A. F. (2008). Asymptotic and resampling strategies for assessing and comparing indirect effects in multiple mediator models. Behavior Research Methods, 40(3), 879–891. https://doi.org/10.3758/BRM.40.3.879
- Hayes, A. F. (2022). Introduction to mediation, moderation, and conditional process analysis: A regression-based approach (3rd ed.). Guilford Press. https://www.guilford.com/books/Introduction-to-Mediation-Moderation-and-Conditional-Process-Analysis/Andrew-Hayes/9781462549030
- Tharakan, D. P. L., & Ford, T. N. (2026). Responsiveness to city service requests, life satisfaction, and horizontal inequality: Does good local governance improve subjective well-being for all? International Journal of Environmental Research and Public Health, 23(1), Article 132. https://doi.org/10.3390/ijerph23010132