Mediation Analysis Explained: How to Run, Read and Report It
Mediation analysis asks how or through what mechanism a predictor affects an outcome. It splits the total effect of X on Y into an indirect effect, passing through a mediator M, and a direct effect that remains. This guide explains the logic, the indirect effect and its bootstrap confidence interval, and a fully worked example.
What is mediation?
The simplest model has X → M → Y. Two regressions are estimated:
M = i1 + aX + e1 Y = i2 + c′X + bM + e2
The indirect effect is a × b. The direct effect is c′. The total effect c, from the regression Y = i3 + cX + e3, equals c′ + ab in linear models fitted to the same complete data. The proportion mediated, ab/c, is often reported but is unstable in small samples and when direct and indirect effects have opposite signs.
How the indirect effect is tested
The older Baron and Kenny (1986) steps rely on a significant total effect and on a series of separate tests; they have low power and do not test ab directly. Modern practice tests the indirect effect itself. The Sobel (1982) test uses z = ab / SE(ab) with SE(ab) = √(b²SEa² + a²SEb²), but it assumes ab is normally distributed, which is rarely true. Bootstrapping the product, resampling cases and recomputing ab many times, gives a percentile confidence interval that does not rely on that assumption (Preacher & Hayes, 2008). If the interval excludes zero, the indirect effect is supported.
Assumptions and causal caution
Regression assumptions apply to each equation. More importantly, causal interpretation requires temporal ordering and no unmeasured confounding of the X–M, M–Y and X–Y relationships, and no X–M interaction. A statistically significant indirect effect in cross-sectional data shows consistency with a mediation model, not proof of mechanism.
Original example (illustrative)
Question. Does weekly mentoring (X, hours) improve job performance (Y) by raising self-efficacy (M)? Data for n = 20 employees (invented):
| # | Mentoring | Self-efficacy | Performance | # | Mentoring | Self-efficacy | Performance |
|---|---|---|---|---|---|---|---|
| 1 | 12.3 | 28.4 | 52.6 | 11 | 12.5 | 28.2 | 53.9 |
| 2 | 12.3 | 29.7 | 49.8 | 12 | 3.0 | 15.8 | 40.6 |
| 3 | 4.2 | 21.1 | 43.4 | 13 | 9.4 | 27.0 | 50.7 |
| 4 | 10.8 | 27.5 | 55.2 | 14 | 6.0 | 25.7 | 46.8 |
| 5 | 13.5 | 29.8 | 56.2 | 15 | 7.6 | 24.3 | 49.4 |
| 6 | 8.0 | 30.0 | 57.1 | 16 | 9.5 | 29.5 | 54.5 |
| 7 | 6.3 | 23.5 | 42.2 | 17 | 10.5 | 32.9 | 56.6 |
| 8 | 9.6 | 21.1 | 44.3 | 18 | 8.6 | 23.1 | 46.5 |
| 9 | 11.8 | 27.1 | 50.7 | 19 | 17.9 | 29.3 | 55.7 |
| 10 | 13.1 | 29.8 | 54.7 | 20 | 11.1 | 29.7 | 50.3 |
| Path | Estimate | SE | t | p | 95% CI |
|---|---|---|---|---|---|
| a: Mentoring → Self-efficacy | 0.834 | 0.195 | 4.28 | < .001 | [0.42, 1.24] |
| b: Self-efficacy → Performance (controlling X) | 0.956 | 0.190 | 5.03 | < .001 | [0.55, 1.36] |
| c′: direct effect | 0.260 | 0.223 | 1.16 | .260 | [−0.21, 0.73] |
| c: total effect | 1.057 | 0.241 | 4.39 | < .001 | [0.55, 1.56] |
The indirect effect is ab = 0.834 × 0.956 = 0.797. Check: c′ + ab = 0.260 + 0.797 = 1.057, which equals c = 1.057. The Sobel statistic is z = 0.797/0.245 = 3.26, p = .001. A percentile bootstrap with 5,000 resamples gives a 95% CI for ab of [0.368, 1.278], which excludes zero. Proportion mediated = 0.797/1.057 = 75%.
Interpretation. Mentoring is associated with higher self-efficacy, and higher self-efficacy is associated with better performance after accounting for mentoring. The indirect effect is positive and its bootstrap interval excludes zero, so the data are consistent with self-efficacy carrying part of the mentoring effect. The remaining direct effect (c′ = 0.260) suggests other pathways or measurement limitations. Bootstrap results vary slightly with the random seed, so report the number of resamples. These invented data come from a cross-sectional layout, so this does not demonstrate that mentoring changes performance through self-efficacy.
How to run mediation analysis with StatFAS
Open the Mediation Analysis Calculator. Arrange columns for X, M and Y (and covariates if supported).
Understanding the output
- Paths a, b, c′, c with standard errors and intervals.
- Indirect effect ab with a bootstrap CI (preferred) or Sobel test.
- Proportion mediated: descriptive only; treat with caution.
- Path diagram: helps readers, but the arrows depict your hypothesis, not proof.
APA 7 reporting example
Mentoring hours were positively associated with self-efficacy (a = 0.83, 95% CI [0.42, 1.24]), which in turn predicted performance (b = 0.96, 95% CI [0.55, 1.36]). The indirect effect of mentoring on performance through self-efficacy was ab = 0.80, 95% bootstrap CI [0.37, 1.28] (5,000 resamples). The direct effect was c′ = 0.26, 95% CI [−0.21, 0.73].
Common mistakes and troubleshooting
- Requiring a significant total effect before testing ab. Indirect effects can exist without a significant c, for example when opposing paths cancel.
- Relying on the Sobel test in small samples; use bootstrap intervals.
- Claiming causation from cross-sectional data, or measuring M and Y at the same time.
- Ignoring measurement error in the mediator, which biases b and ab.
- Confusing mediation with moderation. If the effect varies across groups or levels, see moderation analysis.
Limitations and alternatives
With many mediators or latent variables, structural equation modelling is more flexible (see the SEM tool). For the underlying regressions, see simple linear and multiple linear regression. Causal mediation methods address confounding more explicitly when the design allows.
Conclusion
Mediation analysis estimates how much of an effect passes through an intermediate variable. Test the indirect effect with a bootstrap interval, report all paths with uncertainty, and be explicit that the causal story depends on the design, not on the statistics.
1.
statfas-mediation-analysis-interface.png, alt: "StatFAS Mediation Analysis Calculator interface"2.
statfas-mediation-analysis-example-data.png, alt: "Example data entered in the StatFAS Mediation Analysis Calculator"3.
statfas-mediation-analysis-settings.png, alt: "Mediation Analysis Calculator settings in StatFAS"4.
statfas-mediation-analysis-result.png, alt: "Mediation Analysis Calculator results generated in StatFAS"Frequently asked questions
Do I need a significant total effect to test mediation?
No. Current guidance is to test the indirect effect directly. An indirect effect can be present even when the total effect is not significant, for instance when direct and indirect effects have opposite signs.
Why is bootstrapping preferred to the Sobel test?
The product of two coefficients is usually not normally distributed, so the Sobel test's normality assumption fails, particularly in small samples. Bootstrap intervals make no such assumption.
Can I conclude causation from a mediation analysis?
Not from the statistics alone. Causal conclusions need a design with temporal ordering and control of confounding of the X–M, M–Y and X–Y relationships.
References
- Baron, R. M., & Kenny, D. A. (1986). The moderator–mediator variable distinction in social psychological research. Journal of Personality and Social Psychology, 51(6), 1173–1182.
- 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.
- Sobel, M. E. (1982). Asymptotic confidence intervals for indirect effects in structural equation models. Sociological Methodology, 13, 290–312.
- Hayes, A. F. (2018). Introduction to mediation, moderation, and conditional process analysis (2nd ed.). Guilford Press.