Causal Mediation Analysis
Goes beyond 'does the treatment work?' to ask 'through which pathway does it work?' — extends the Baron-Kenny framework by addressing its identification challenges.
Quick Reference
- When to Use
- When you want to understand the mechanism through which a treatment affects an outcome — decomposing the total effect into natural direct and natural indirect (mediated) components.
- Key Assumption
- Sequential ignorability: (1) treatment is unconfounded given covariates, AND (2) the mediator is unconfounded given treatment and covariates. Assumption 2 is much stronger than standard unconfoundedness because the mediator is not randomized, even in experiments.
- Common Mistake
- Using Baron & Kenny (1986) three-step method without recognizing its strong assumptions about no treatment-mediator interaction and no mediator-outcome confounding. Conducting sensitivity analysis for sequential ignorability is recommended (Imai et al., 2010).
- Estimated Time
- 3 hours
One-Line Implementation
medeff (reg mediator treatment x1 x2) (reg outcome mediator treatment x1 x2), treat(treatment) mediate(mediator) sims(1000)mediate(model.m, model.y, treat = 'treatment', mediator = 'mediator', boot = TRUE, sims = 1000)# No mature Python mediation package; use R mediation via rpy2Download Full Analysis Code
Complete scripts with diagnostics, robustness checks, and result export.
Motivating Example
You run a randomized experiment: a job training program for unemployed workers. The randomization is clean, and you find a significant positive effect on earnings. The program works.
But your program officer asks the most natural follow-up question: How does it work? Does the program boost earnings because it builds human capital (workers learn new skills)? Because it provides a signal to employers (a certificate on the resume)? Or because it expands the workers' professional networks (connections lead to job offers)?
These queries are mechanism questions, and they require mediation analysis. You want to decompose the total effect into the parts that flow through each pathway:
This decomposition turns out to be much harder than it looks.
A. Overview
The Baron and Kenny Legacy
For decades, management researchers followed the Baron and Kenny (1986) approach to mediation.
(Baron & Kenny, 1986)The approach involves three OLS regressions:
- Regress the outcome on the treatment: (check that is significant)
- Regress the mediator on the treatment: (check that is significant)
- Regress the outcome on both treatment and mediator: (check that is significant and that is reduced compared to )
The indirect effect is , and mediation is "established" if is smaller than (partial mediation) or non-significant (full mediation).
This procedure is intuitive, easy to implement, and has been widely cited in the social sciences. It is also, in many settings, deeply problematic. Here is why.
What Baron and Kenny Gets Wrong
The Baron and Kenny approach implicitly assumes:
-
No treatment-mediator interaction. The effect of on is the same regardless of treatment status. This assumption rules out, for example, the possibility that human capital matters more for program participants than for non-participants.
-
No unmeasured confounders of the mediator-outcome relationship. This requirement is the killer assumption. Even if is randomized, is not randomized. Workers who gain the most human capital from training might also be the most motivated, and motivation independently affects earnings.
-
Linear, additive effects. The three-regression approach assumes a specific parametric structure.
The modern causal mediation framework, developed by Imai et al. (2010) and by , makes these assumptions explicit and provides tools for assessing whether they are plausible.
(Imai et al., 2010)Common Confusions
"What is sequential ignorability?"
is the key assumption of the modern causal mediation framework. It has two parts:
-
Treatment is ignorable given pre-treatment covariates. Satisfied by randomization of or by assuming selection on observables.
-
The mediator is ignorable given treatment and pre-treatment covariates. Conditional on and observed covariates, is as good as randomly assigned. This condition is the much harder assumption.
The second part is demanding because even when is randomized, is typically endogenous. Workers who gain more human capital from training may differ from those who gain less, in ways that also affect earnings. Sequential ignorability requires that all such confounders are observed and controlled for.
"Can I do mediation with observational data?"
Technically yes, but the bar is very high. Doubly robust methods can help with model misspecification in the outcome and mediator equations, but they do not solve the fundamental confounding problem. You need both parts of sequential ignorability to hold. Without randomization of treatment, you need unconfoundedness of . Without randomization of conditional on , you need unconfoundedness of given and . In practice, this requirement means you need an extremely rich set of covariates and a strong theoretical justification.
Even with experimental data (randomized ), the second part of sequential ignorability is a strong assumption because is not randomized.
"What about Zhao et al. (2010)?"
(Zhao et al., 2010)Zhao et al. (2010) provided an important critique of Baron and Kenny from within the management literature. They argued that the "step 1" requirement (significant total effect) is unnecessary and introduced a more sensible classification of mediation types (complementary, competitive, indirect-only, direct-only, no-effect). This classification was a significant step forward, but it still operates within the regression framework rather than the full causal framework.
B. Identification
Potential Outcomes Framework for Mediation
Let be the mediator value under treatment . Let be the outcome under treatment and mediator value .
The Natural Direct Effect (NDE) is:
The NDE captures all paths from to that do not go through .
The Natural Indirect Effect (NIE) is:
The NIE captures the path from to that goes through .
The total effect decomposes cleanly:
Sequential Ignorability (Formal)
Assumption 1: for all
Assumption 2: for all
C. Visual Intuition
The classic mediation DAG:
T --> M --> Y
T ---------> Y
The problem arises from unmeasured confounders:
T --> M --> Y
T ---------> Y
U ----> M
U ----> Y
If exists and is unobserved, controlling for does not isolate the indirect effect — it introduces bias through .
Mediation: Baron-Kenny vs. Causal Framework
Adjust the strength of the indirect path, the direct path, and the confounding of the mediator-outcome relationship. Compare the Baron-Kenny indirect effect estimate to the true causal indirect effect.
Mediation: Decomposing the Total Effect
DGP: D → M → Y and D → Y. Direct effect = 2.0, indirect effect = 2.0, total = 4.0. Confounding of M = 0.00. N = 400.
Estimation Results
| Estimator | β̂ | SE | 95% CI | Bias |
|---|---|---|---|---|
| Total effect (target: 4.00)closest | 3.950 | 0.070 | [3.81, 4.09] | -0.050 |
| Baron-Kenny a*b (target: 2.00) | 2.083 | 0.111 | [1.86, 2.30] | +0.083 |
| Modern ACME (target: 2.00) | 2.088 | 0.115 | [1.86, 2.31] | +0.088 |
| Naive D coef (target: 2.00) | 1.867 | 0.110 | [1.65, 2.08] | -0.133 |
| True β | 4.000 | — | — | — |
Number of observations
Causal effect of D on Y not through M
Causal effect of D on Y flowing through M
Violation of sequential ignorability (U affects both M and Y)
Why the difference?
The total effect of D on Y is 3.95. Of the total effect, 2.09 flows through the mediator M (indirect/ACME) and 1.86 operates directly (ADE). The Baron-Kenny product of coefficients gives 2.08, which is close to the modern causal mediation estimate (2.09). In the linear case, these converge to the same population quantity, but the modern approach (quasi-Bayesian Monte Carlo) propagates parameter uncertainty through simulation, yielding more accurate confidence intervals—especially for small samples or near-zero effects where the delta method can be unreliable. With no confounding (sequential ignorability satisfied), naively controlling for M gives 1.87, which closely approximates the true direct effect.
D. Mathematical Derivation
Don't worry about the notation yet — here's what this means in words: Under sequential ignorability, the natural indirect effect can be identified from observed data by integrating the outcome model over the mediator distribution under treatment and control.
Under sequential ignorability, Imai et al. (2010) show that the ACME for treatment group is:
Each inner integral averages the outcome model over the mediator distribution under treatment () and control () separately; the ACME is the difference between these two averages.
In the linear case with no interaction:
The indirect effect simplifies to:
This expression is the Baron-Kenny product of coefficients. Under linearity and no interaction, the modern framework gives the same answer.
With a treatment-mediator interaction:
The indirect effect becomes:
Now the indirect effect depends on the treatment level . Baron-Kenny cannot capture this dependence.
Sensitivity analysis. Since Assumption 2 is untestable, the sensitivity parameter represents the correlation between the error terms in the mediator and outcome models. When , sequential ignorability holds. Reporting how large must be to nullify the indirect effect gives the reader a sense of robustness.
E. Implementation
library(mediation)
# Step 1: Mediator model
model.m <- lm(mediator ~ treatment + x1 + x2, data = df)
# Step 2: Outcome model
model.y <- lm(outcome ~ treatment + mediator + x1 + x2, data = df)
# Step 3: Causal mediation analysis
med_out <- mediate(model.m, model.y,
treat = "treatment",
mediator = "mediator",
boot = TRUE, sims = 1000)
summary(med_out)
plot(med_out)
# Step 4: Sensitivity analysis
sens_out <- medsens(med_out, rho.by = 0.05, effect.type = "indirect")
summary(sens_out)
plot(sens_out)
# Report: at what value of rho does the indirect effect cross zero?F. Diagnostics
-
Sensitivity analysis for sequential ignorability. Report the Imai-Keele-Tingley sensitivity parameter . How large must the mediator-outcome confounding be to nullify the indirect effect? If the breakpoint is small (e.g., 0.05-0.10), your finding is fragile.
-
Treatment-mediator interaction. Test for interactions in the outcome model. If significant, the simple decomposition is biased.
-
Multiple mediators. If you have several mediators, check whether they are causally ordered. If causes , you cannot simply run separate mediation analyses for each.
-
Pre-treatment covariates. Check that all covariates you condition on are truly pre-treatment. Including post-treatment variables introduces bias.
-
Comparison with Baron and Kenny. Report both the product and the modern causal mediation estimates. If they agree, your results are robust to the choice of framework.
-
Placebo mediators. Test mediators that should not be affected by the treatment. If you find "mediation" through a placebo mediator, something is wrong.
Interpreting Your Results
Significant indirect effect, robust to sensitivity analysis: You have credible evidence for mediation. Report the proportion mediated and the sensitivity parameter at which the indirect effect becomes zero.
Significant indirect effect, sensitive to confounding: The indirect effect is suggestive but not robust. Be honest. Report that even moderate confounding of the mediator-outcome relationship could explain the result.
Non-significant indirect effect: Be careful about concluding "no mediation." You might lack statistical power, or the mediator might be poorly measured. Measurement error in the mediator attenuates the indirect effect.
G. What Can Go Wrong
Ignoring Mediator-Outcome Confounding (Sequential Ignorability Violation)
Randomize the treatment, acknowledge that the mediator is not randomized, and conduct a sensitivity analysis for mediator-outcome confounding using the Imai-Keele-Tingley rho parameter.
Indirect effect: 0.12 (SE = 0.04, p = 0.003). Sensitivity analysis: the indirect effect crosses zero at rho = 0.25, suggesting moderate robustness to unmeasured confounding of the mediator-outcome path.
Ignoring Treatment-Mediator Interaction
Include a treatment-by-mediator interaction term in the outcome model and use the modern causal mediation framework, which allows the indirect effect to depend on the treatment level.
NIE at T=1: 0.14 (SE = 0.04). NIE at T=0: 0.06 (SE = 0.03). The indirect effect is larger for treated units, indicating a meaningful treatment-mediator interaction that Baron-Kenny would miss.
Post-Treatment Confounders Creating Intermediate Confounding
Carefully check that all covariates in the mediation model are pre-treatment. If a post-treatment variable confounds the mediator-outcome relationship, acknowledge the 'intermediate confounder' problem and discuss its implications.
After removing the post-treatment variable (job search intensity), the indirect effect estimate changes from 0.20 to 0.11 (SE = 0.04). The researcher discusses the intermediate confounder problem and reports both estimates with appropriate caveats.
H. Practice
You conduct a randomized experiment testing a leadership training program (T) on employee performance (Y). You measure 'leadership self-efficacy' (M) as a potential mediator. You find: T significantly affects M (a = 0.4), and in the joint model, M significantly predicts Y (b = 0.3), while the direct effect of T on Y is non-significant. A colleague says: 'Great, we have full mediation.' What is the problem?
Causal Mediation: How Does Job Training Improve Earnings?
A labor economist studies a randomized job training program and asks: does training raise earnings by improving technical skills (the mediator), or does it work through other pathways like confidence and networking? The treatment T is random assignment to training. The mediator M is a technical skills test score measured 6 months after training. The outcome Y is earnings at 2 years.
Read the analysis below carefully and identify the errors.
Select all errors you can find:
Read the paper summary below and write a brief referee critique (2-3 sentences) of the identification strategy.
Paper Summary
The authors study whether CEO social capital affects firm innovation through knowledge alliances. Using a panel of 3,000 firms, they find a total effect of 0.15 and an indirect effect through alliances of 0.09, concluding that 60% of the social capital effect on innovation operates through knowledge alliances.
Key Table
| Estimate | Coef | SE | 95% CI |
|---|---|---|---|
| Total Effect | 0.15 | 0.04 | [0.07, 0.23] |
| ACME (indirect) | 0.09 | 0.03 | [0.03, 0.15] |
| ADE (direct) | 0.06 | 0.04 | [-0.02, 0.14] |
| Prop. Mediated | 60% | ||
| Sensitivity rho | 0.12 |
Authors' Identification Claim
We use the Imai-Keele-Tingley framework with 1,000 bootstrap replications. The sequential ignorability assumption is supported by our rich set of controls including firm size, age, industry, and R&D intensity.
I. Swap-In: When to Use Something Else
- Total-effect estimation (DiD, IV, RDD): When the total effect is sufficient and the mediator is not well-measured or the mechanism is not the primary question.
- Structural equation modeling (SEM): When the causal model involves multiple mediators with known structure and the goal is simultaneous estimation of all pathways.
- Instrumental mediation: When the sequential ignorability assumption is implausible and an instrument for the mediator is available to identify the indirect effect.
- Controlled direct effects: When the question is about blocking a specific pathway (what would happen if the mediator were held fixed) rather than decomposing the total effect into indirect and direct components.
J. Reviewer Checklist
Critical Reading Checklist
Paper Library
Foundational (6)
Baron, R. M., & Kenny, D. A. (1986). The Moderator-Mediator Variable Distinction in Social Psychological Research: Conceptual, Strategic, and Statistical Considerations.
Baron and Kenny introduced the widely used four-step approach to testing mediation, comparing total, direct, and indirect effects using sequential regressions. While later work has identified limitations of this approach, it remains one of the most cited papers in all of social science.
Imai, K., Keele, L., & Tingley, D. (2010). A General Approach to Causal Mediation Analysis.
Imai, Keele, and Tingley developed a general framework for causal mediation analysis grounded in the potential outcomes framework. They clarified the assumptions needed for identifying causal mediation effects, particularly the sequential ignorability assumption, and provided sensitivity analyses for violations.
Pearl, J. (2001). Direct and Indirect Effects.
Pearl formalized the concepts of natural direct and indirect effects using structural causal models and do-calculus. This paper established the nonparametric identification conditions for mediation effects and showed that traditional mediation analysis conflates causal and non-causal pathways.
Robins, J. M., & Greenland, S. (1992). Identifiability and Exchangeability for Direct and Indirect Effects.
Robins and Greenland provided early formal conditions for identifying direct and indirect causal effects in epidemiology. Their work on controlled direct effects and the assumptions required for mediation analysis laid important groundwork for the modern causal mediation literature.
Pearl, J. (2014). Interpretation and Identification of Causal Mediation.
Pearl provided a structural causal model perspective on mediation, clarifying the interpretation and identification of natural direct and indirect effects. He showed how graphical criteria can determine when mediation effects are identifiable and contrasted the structural approach with the potential outcomes framework used by Imai, Keele, and Tingley.
Acharya, A., Blackwell, M., & Sen, M. (2016). Explaining Causal Findings Without Bias: Detecting and Assessing Direct Effects.
Acharya, Blackwell, and Sen developed a sequential g-estimation approach for estimating controlled direct effects in observational studies, addressing the problem that conditioning on a post-treatment mediator can introduce collider bias. Their method is particularly useful in political science and social science settings where intermediate confounders make standard mediation analysis unreliable.
Application (5)
VanderWeele, T. J. (2015). Explanation in Causal Inference: Methods for Mediation and Interaction.
VanderWeele's comprehensive textbook unified the causal mediation literature, covering potential outcomes and structural equation approaches, sensitivity analysis, time-varying treatments, and interaction effects. It is the standard reference for researchers conducting mediation analysis.
MacKinnon, D. P., Fairchild, A. J., & Fritz, M. S. (2007). Mediation Analysis.
MacKinnon, Fairchild, and Fritz provided an accessible review of mediation analysis methods for psychologists, covering the Baron-Kenny approach, the Sobel test, bootstrapping methods, and extensions to multiple mediators. This survey helped bridge the gap between traditional and modern approaches.
Preacher, K. J., & Hayes, A. F. (2008). Asymptotic and Resampling Strategies for Assessing and Comparing Indirect Effects in Multiple Mediator Models.
Preacher and Hayes developed methods and software for testing indirect effects through multiple mediators simultaneously, using bootstrapping to construct confidence intervals. Their approach and accompanying SPSS and SAS macros became extremely widely used in psychology and management research.
Aguinis, H., Edwards, J. R., & Bradley, K. J. (2017). Improving Our Understanding of Moderation and Mediation in Strategic Management Research.
Aguinis, Edwards, and Bradley reviewed how mediation and moderation analyses are conducted in strategic management research and identified common errors. They provided recommendations for improving practice, including using causal mediation frameworks and proper inference procedures.
Zhao, X., Lynch, J. G., & Chen, Q. (2010). Reconsidering Baron and Kenny: Myths and Truths about Mediation Analysis.
Zhao, Lynch, and Chen provided an important critique of the Baron and Kenny mediation framework from within the management literature. They argued that the 'step 1' requirement of a significant total effect is unnecessary and introduced a more sensible classification of mediation types (complementary, competitive, indirect-only, direct-only, no-effect). While still operating within the regression framework rather than the full causal framework, this paper was a significant step forward for applied researchers.
Survey (1)
VanderWeele, T. J. (2016). Mediation Analysis: A Practitioner's Guide.
VanderWeele provided an accessible practitioner-oriented guide to modern causal mediation analysis, covering the assumptions required for identification, sensitivity analysis for unmeasured confounding, and extensions to multiple mediators and interactions. This review is an excellent entry point for applied researchers seeking to move beyond the Baron-Kenny framework.