Mediation analysis tests whether the effect of one variable (X) on an outcome (Y) runs through a third variable, the mediator (M). You use it when your research question asks how or why X affects Y, not just whether it does. The modern approach centers on one number: the indirect effect, tested with a bootstrap confidence interval.
What mediation analysis is
A simple mediation model has three variables and four paths you need to know.
- a path: the effect of X on M.
- b path: the effect of M on Y, controlling for X.
- c′ path (c-prime): the direct effect of X on Y, controlling for M.
- c path: the total effect of X on Y, with no mediator in the model.
The indirect effect is the product a × b. It estimates how much of X's effect on Y travels through M. With ordinary least squares regression and a continuous mediator, the paths add up exactly: c = c′ + ab.
When to use it
Use mediation when you have a theory that explains a mechanism. For example, training (X) may raise self-efficacy (M), which in turn raises job satisfaction (Y). If you only want to know whether a relationship changes at different levels of a third variable, you need moderation analysis instead.
From Baron and Kenny to bootstrapping
Baron and Kenny (1986) proposed a four-step approach. You tested whether X predicts Y (c), whether X predicts M (a), whether M predicts Y controlling for X (b), and whether c′ shrinks compared with c. Many textbooks still teach these steps, so your committee may ask about them.
Methodologists now treat those steps as a description, not as the test. The main problems are:
- The steps never test the indirect effect a × b directly.
- Requiring a significant total effect (c) is not necessary. Zhao, Lynch and Chen (2010) show that mediation can exist when c is not significant.
- The Sobel (1982) test does test a × b, but it assumes the product is normally distributed. It usually is not, so the test has low power.
Preacher and Hayes (2008) recommended bootstrapping the indirect effect instead. You resample your data thousands of times, estimate a × b in each resample, and build a confidence interval from that distribution. Hayes's PROCESS macro, Model 4, does this for a simple mediation model.
Full versus partial mediation
Older papers call it "full" mediation when c′ is not significant and "partial" when it is. Many methodologists discourage these labels. Rucker, Preacher, Tormala and Petty (2011) point out that the labels depend heavily on sample size. A large sample makes almost any c′ significant, so "full" mediation becomes rarer as power grows.
A better practice is to report the indirect effect and the direct effect with their confidence intervals. Then describe their size and direction in plain words.
Assumptions and requirements
Mediation is a causal claim, so the statistics alone cannot prove it. Check these points before you run anything.
- Temporal order: X should come before M, and M before Y. Cross-sectional data make this hard to defend. Maxwell and Cole (2007) show that cross-sectional mediation estimates can be badly biased.
- No unmeasured confounding: in particular, nothing left out should affect both M and Y.
- Regression assumptions: linear relationships, independent observations, and no extreme outliers. Bootstrapping helps with non-normal indirect effects, not with a badly specified model.
- Reliable measures: measurement error in M tends to underestimate the b path.
- Sample size: Fritz and MacKinnon (2007) give sample sizes needed to detect mediated effects. Small a and b paths can need several hundred cases. See our G*Power sample size guide for planning.
How to run mediation analysis
In SPSS with PROCESS (Model 4)
PROCESS is a free add-on by Andrew Hayes. Once installed as a custom dialog, it appears in the Regression menu. You can also run it through syntax after opening and running the process.sps file.
- Enter your outcome as Y, your predictor as X and your mediator as M.
- Choose Model number 4.
- Set the number of bootstrap samples to 5,000 (the default in recent versions).
- Ask for the total effect so you can report c.
- Set a random seed if you want reproducible bootstrap results.
The equivalent syntax looks like this:
process y=jobsat/x=training/m=effic/model=4/total=1/boot=5000/seed=31216.
In R with lavaan
In lavaan you label each path and define the indirect effect with the := operator.
library(lavaan)
model <- '
effic ~ a * training
jobsat ~ b * effic + cp * training
indirect := a * b
total := cp + a * b
'
fit <- sem(model, data = df, se = "bootstrap", bootstrap = 5000)
parameterEstimates(fit, boot.ci.type = "perc")
The := lines create defined parameters. With se = "bootstrap", lavaan gives bootstrap standard errors and percentile confidence intervals for them. For latent variables, the same logic extends to full structural equation modeling.
How to interpret the output
Focus on the indirect effect and its 95% bootstrap confidence interval. If the interval does not include zero, the indirect effect is statistically significant at the .05 level. Do not rely on a p value for a × b; PROCESS does not print one for the bootstrapped effect.
| Output element | What it tells you | How to read it |
|---|---|---|
| a path | X → M | Sign and size of X's effect on the mediator |
| b path | M → Y, controlling for X | Whether the mediator relates to the outcome |
| c′ (direct effect) | X → Y, controlling for M | Effect of X not explained by M |
| c (total effect) | X → Y, no mediator | Overall effect; c = c′ + ab with OLS |
| ab (indirect effect) | X → M → Y | Significant if the bootstrap CI excludes 0 |
| Boot LLCI / ULCI | Lower and upper CI limits | Both above 0 or both below 0 = significant |
Report unstandardized coefficients by default. They keep the original units, so readers can judge the practical size. Our effect size guide covers how to describe magnitude.
Worked example
Example (invented data): a researcher surveys 210 employees. X is hours of training, M is self-efficacy and Y is job satisfaction. PROCESS Model 4 with 5,000 bootstrap samples gives these results.
| Path | B | SE | 95% CI | p |
|---|---|---|---|---|
| a: training → self-efficacy | 0.42 | 0.07 | [0.28, 0.56] | < .001 |
| b: self-efficacy → satisfaction | 0.35 | 0.06 | [0.23, 0.47] | < .001 |
| c′: direct effect | 0.18 | 0.07 | [0.04, 0.32] | .011 |
| c: total effect | 0.33 | 0.07 | [0.19, 0.47] | < .001 |
| ab: indirect effect | 0.15 | 0.04 | [0.08, 0.22] (bootstrap) | — |
The indirect effect is 0.42 × 0.35 = 0.147. Its bootstrap interval runs from 0.08 to 0.22 and excludes zero. The direct effect is also significant. So training relates to satisfaction both through self-efficacy and by other routes the model does not capture. About 45% of the total effect (0.15 / 0.33) runs through self-efficacy, though this ratio is unstable in small samples.
How to report mediation in APA 7
Report each path, the indirect effect with its bootstrap CI, the number of resamples and the software. Italicize statistical symbols such as a, b, B, SE and p.
A simple mediation analysis was conducted using PROCESS Model 4 (Hayes) with 5,000 bootstrap samples. Training hours predicted self-efficacy, a = 0.42, SE = 0.07, p < .001, and self-efficacy predicted job satisfaction controlling for training, b = 0.35, SE = 0.06, p < .001. The indirect effect of training on job satisfaction through self-efficacy was significant, ab = 0.15, 95% CI [0.08, 0.22]. The direct effect remained significant, c′ = 0.18, p = .011.
Use the numbers from your own output, and adapt the wording to your hypotheses. A path diagram with coefficients on each arrow also helps readers. For the wider structure of chapter 4, see our APA results section guide.
Common mistakes
- Treating Baron and Kenny steps as the test. Test the indirect effect with a bootstrap CI.
- Stopping because c is not significant. An indirect effect can exist without a significant total effect.
- Claiming causation from cross-sectional data. Say the results are "consistent with" mediation and note the design limit.
- Reporting a p value for the bootstrapped indirect effect. Report the confidence interval instead.
- Leaning on "full" and "partial" labels. Describe the size of the direct and indirect effects instead.
- Forgetting the seed. Without a seed, your CI limits will change slightly every time you rerun.
FAQ
What is the difference between mediation and moderation?
Mediation explains how X affects Y, through a mediator M. Moderation asks when or for whom the effect of X on Y changes, depending on a moderator W. They answer different questions and use different models.
How many bootstrap samples do I need?
5,000 is a common choice and the PROCESS default in recent versions. More samples give slightly more stable CI limits. Always report the number you used.
Can I test mediation with a categorical X?
Yes. A binary X (such as treatment versus control) works directly in PROCESS and lavaan. With three or more groups, PROCESS can code X as a multicategorical variable, which gives one indirect effect per contrast.
Do I still need the Sobel test?
Usually not. The Sobel test has low power because the indirect effect is rarely normally distributed. Some examiners still ask for it, so you can add it as a secondary result.
Can I have more than one mediator?
Yes. PROCESS Model 4 accepts several mediators in parallel, and Model 6 tests mediators in sequence. In lavaan you add more labeled paths and define each indirect effect separately.
Get help with your mediation model
If your paths do not match your theory or your committee questions the design, our SEM analysis service can run and check your mediation model in PROCESS, lavaan, AMOS or SmartPLS. You get the output, an APA-style table and a plain-English explanation you can defend.
Not sure mediation is the right analysis for your research question? Send us your questions and variables for a free methods check, and we will reply within 24 hours.
Need help with this analysis?
A statistician can run, check and explain it with you. Fixed quote before we start.