Quant Memo
Core

Mediation Analysis

Mediation analysis splits a treatment's total effect on an outcome into the part that flows through a specific intermediate channel and the part that doesn't, answering not just whether something works but how.

Prerequisites: Bad Controls and Post-Treatment Bias, Structural Causal Models and Counterfactuals

A trading firm finds that a new onboarding program raises new hires' first-year P&L by an average of $80k. Leadership wants to know why: is it because the program teaches better risk management (which then improves P&L), or does it work through some entirely different route, like faster desk integration or manager attention? Knowing the total effect alone doesn't tell you which lever to pull if you want to redesign or scale the program. Mediation analysis is the tool for decomposing a total effect into the piece that flows through a specific proposed mechanism and the piece that doesn't.

An analogy: why did the plant grow taller

A gardener notices plants given a new fertilizer grow 20cm taller on average than untreated plants, and suspects it's because the fertilizer increases root mass, which in turn supports more growth. To check this story, the gardener needs more than the total height difference — measuring root mass separately, and asking "how much of the 20cm difference is explained by the extra root mass, and how much would still show up even if root mass hadn't changed at all?" splits one observed number into a mechanism-explained piece and a leftover piece, telling the gardener whether "boost root mass" is actually the right lever to focus on, or whether something else about the fertilizer (a leaf-level effect, say) is doing most of the work.

The decomposition, one symbol at a time

Let DD be treatment (onboarding program), MM the proposed mediator (risk-management competency score), and YY the outcome (P&L). Using the counterfactual notation from structural causal models and counterfactuals, define Yi(d,m)Y_i(d, m) as the outcome under treatment dd and mediator value mm, and Mi(d)M_i(d) as the mediator value that would arise under treatment dd. The total effect decomposes as:

E[Yi(1,Mi(1))Yi(0,Mi(0))]total effect=E[Yi(1,Mi(0))Yi(0,Mi(0))]natural direct effect+E[Yi(0,Mi(1))Yi(0,Mi(0))]natural indirect effect\underbrace{\mathbb{E}[Y_i(1, M_i(1)) - Y_i(0, M_i(0))]}_{\text{total effect}} = \underbrace{\mathbb{E}[Y_i(1, M_i(0)) - Y_i(0, M_i(0))]}_{\text{natural direct effect}} + \underbrace{\mathbb{E}[Y_i(0, M_i(1)) - Y_i(0, M_i(0))]}_{\text{natural indirect effect}}

In plain English: the natural direct effect asks "how much would YY change from treatment alone, if we could hold the mediator fixed at whatever value it would have taken without treatment?" — the part of the effect not explained by MM. The natural indirect effect asks "how much would YY change purely from the mediator shifting to its treated-level value, with treatment itself held at the untreated baseline?" — the part of the effect explained specifically by MM changing. Together, direct plus indirect reconstructs the total effect exactly.

Worked example 1: decomposing the $80k

Suppose careful measurement (using a mediation model that accounts for confounders of the mediator-outcome relationship) finds the natural indirect effect through risk-management competency is +$55k, and the natural direct effect (desk integration, manager attention, general confidence) is +$25k. These sum to the total +$80k. Roughly 69% (55/80) of the program's value flows through the risk-management training component specifically — a strong signal that if the firm needs to cut costs, that module is the piece to protect.

direct \$25k indirect (via risk skill) \$55k
The two natural effects stack to reconstruct the observed \$80k total, showing that most of the program's value runs through the risk-management channel.

Worked example 2: a case where the naive approach (bad control) gets it wrong

A less careful analyst, unaware of the mediation framework, instead just adds risk-management competency score as a control variable in a regression of P&L on program participation — exactly the mistake covered in bad controls and post-treatment bias. Suppose that regression's coefficient on program participation shrinks to roughly +$25k (matching the natural direct effect above) — the analyst might then wrongly report "the program's effect, controlling for risk-management skill, is only $25k" as if that were a smaller but still valid total effect estimate, rather than recognizing it as specifically the direct effect with the mediated pathway deliberately blocked. The number itself can be identical to a properly computed natural direct effect, but the interpretation is entirely different: one says "here's the effect not working through this channel" (a meaningful, specific claim), the other implies "here's a corrected, more accurate total effect" (false — it throws away $55k of real, mediator-driven impact).

D (program) M (risk skill) Y (P&L) indirect +\$55k direct +\$25k direct \$25k indirect \$55k total = \$80k
The total effect of the program splits cleanly into a direct effect (bypassing the mediator) and an indirect effect (flowing through it) — the two numbers add up to the total, and each answers a different design question.

What this means in practice

Mediation analysis matters whenever "did it work" is less useful than "how did it work" — designing interventions, deciding which component of a multi-part program to invest in, or diagnosing which specific channel a policy operates through so a firm can replicate that channel more directly. It requires a stronger set of assumptions than estimating a total effect alone: not just that treatment is unconfounded with the outcome, but that the mediator itself is unconfounded with the outcome given treatment — a second ignorability condition (see confounding and the backdoor criterion) that's easy to overlook and often harder to defend than the first.

Mediation analysis decomposes a treatment's total effect into a direct effect (bypassing a specific proposed mechanism) and an indirect effect (flowing through it), answering not just whether a treatment works but which channel does the work — the two pieces always sum back to the total effect.

Simply adding a candidate mediator as a control variable in a regression is not mediation analysis, even though the resulting coefficient can numerically resemble a natural direct effect — this is the bad-control trap from bad controls and post-treatment bias in disguise. Proper mediation analysis requires separately modeling the mediator's own confounders and explicitly computing the indirect effect, not just watching a coefficient shrink and calling the leftover the "true" effect.

Related concepts

Practice in interviews

Further reading

  • Imai, Keele & Tingley, Psychological Methods 2010
  • Pearl, Causality, ch. 4
ShareTwitterLinkedIn