Example
The tool shows an example from learning psychology: self-regulation (X) → study time (M) → exam performance (Y). The parameter sliders control the true population effects; the tool simulates a sample from these and estimates the coefficients.
Model structure (Hayes Model 4)
A mediation analysis decomposes the total effect of X on Y into two paths:
Direct effect: c′ (X→Y, with M held constant)
Total effect: c = c′ + a·b
c corresponds exactly to the bivariate regression coefficient from the simple regression Y ~ X (with M omitted from the model).
Four scenarios
A — No mediation: a·b ≈ 0, because a or b is zero. X affects Y directly, but not through M.
B — Full mediation: c′ ≈ 0, the entire effect runs through M. Without M in the model, c ≠ 0 — but once M is controlled for, it vanishes.
C — Partial mediation: both a·b and c′ are nonzero. The most common case in practice.
D — Suppression: a and b have opposite signs, so a·b is negative. Since c = c′ + a·b, the total effect turns out smaller than the direct one: |c| < |c′|. Under strong suppression, c can be near zero even though c′ is substantial.
The Sobel test assumes that a·b is approximately normally distributed. That only holds at large n — at small sample sizes, the product distribution is skewed and leptokurtic, which makes the test too conservative.
The bootstrap CI (Preacher & Hayes, 2008) makes no distributional assumption: 5000 resamples approximate the actual shape of the a·b distribution. In simulations it has better power and more correct α control — especially at n < 100 or with asymmetric effects.
Causality
A significant a·b does not prove causation. Causal claims require (1) all confounders between X and Y and (2) all confounders between M and Y to be controlled. Condition 2 is rarely attainable in observational studies. DAGs help identify the necessary control variables.
Further Reading
Baron, R. M. & Kenny, D. A. (1986). The moderator-mediator variable distinction in social psychological research. JPSP, 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.
MacKinnon, D. P., Lockwood, C. M., Hoffman, J. M., West, S. G. & Sheets, V. (2002). A comparison of methods to test mediation and other intervening variable effects. Psychological Methods, 7(1), 83–104.
Hayes, A. F. (2022). Introduction to Mediation, Moderation, and Conditional Process Analysis (3rd ed.). Guilford.