Ask Mallard

Mediation analysis

Mediation analysis asks how much of an exposure's effect on an outcome travels through a particular intermediate variable, and how much does not.

What question does this help answer?

It addresses mechanism: not whether something works, but by what route. That is a genuinely different question from the total effect, and it needs genuinely stronger assumptions.

When to use it

Use it when the total effect is already established or being estimated alongside, when a specific mediator is plausible on prior grounds, and when exposure, mediator and outcome are measured in that temporal order.

When not to use it

Avoid it when the mediator is measured at the same time as the outcome, when it could plausibly be a consequence of the outcome, or when the study was not designed with mediation in mind. A mediation analysis added to answer a reviewer is rarely supportable.

How it works in plain language

The effect is decomposed into an indirect part running through the mediator and a direct part that does not. Modern practice defines these with counterfactuals rather than by comparing regression coefficients, which lets the analysis handle exposure-mediator interaction and binary outcomes properly. The decomposition is only meaningful if there is no unmeasured confounding of THREE relationships: exposure-outcome, mediator-outcome, and exposure-mediator. The middle one is the assumption most often unexamined, and randomizing the exposure does nothing to secure it.

The relationships that must be free of confounding

A mediation diagram. Exposure affects the outcome directly and indirectly through a mediator. Three groups of confounders are shown: of exposure and outcome, of mediator and outcome, and of exposure and mediator. All three must be absent or measured for the decomposition to hold.Mediation: three relationships that must each be free of unmeasured confoundingIndirectDirectExposureMediatorOutcomeExposure-outcomeconfoundersMediator-outcomeconfoundersExposure-mediatorconfoundersRandomizing the exposure removes exposure-outcome and exposure-mediator confounding, and does nothing aboutmediator-outcome confounding.
Conceptual diagram. It shows the structure of the idea, not data from any study.

Why Mallard may recommend it

Mallard may recommend mediation analysis when the question explicitly asks through what mechanism an effect operates, and when the data support the required temporal ordering.

Key assumptions and design requirements

  • All three no-unmeasured-confounding assumptions are stated, including mediator-outcome, which randomization does not deliver.
  • Temporal order is real: exposure, then mediator, then outcome.
  • With a BINARY outcome, a counterfactual or g-computation framework is used. Baron-Kenny and product-of-coefficients are invalid there because the odds ratio is non-collapsible.
  • Exposure-mediator interaction is allowed for rather than assumed absent.
  • Power is assessed by simulation; mediation has no simple closed-form sizing.
  • Sensitivity analysis for unmeasured mediator-outcome confounding is reported.

What to watch out for

Mediation needs no unmeasured confounding of exposure-outcome, mediator-outcome AND exposure-mediator relationships, which is far stronger than what the total effect required. With a binary outcome the product-of-coefficients and Baron-Kenny approaches are invalid because the odds ratio is non-collapsible; a counterfactual or g-computation framework is required.

Clinical example

Question: Does a care-coordination programme reduce readmission by improving medication adherence? Design: Measure the programme, then adherence, then readmission, and decompose the effect within a counterfactual framework because the outcome is binary, reporting a sensitivity analysis for unmeasured confounding between adherence and readmission.

Code for this method
Loading…
Recent studies that used this
Searching PubMed…
Related Learn pages
Sources & further reading
  1. Mediation Analysis: A Practitioner's Guide (opens in a new tab) · Annu Rev Public Health · doi 10.1146/annurev-publhealth-032315-021402
  2. Tutorial on directed acyclic graphs (opens in a new tab) · J Clin Epidemiol · doi 10.1016/j.jclinepi.2021.08.001
The first reference covers binary outcomes, exposure-mediator interaction and case-control designs specifically, which is why it is preferred here over older mediation guidance built on comparing regression coefficients.
Last source review: 2026-09-06
AI-generated educational content
Mallard uses reputable methodological and reporting sources, but this material may contain errors or omit important context. Verify important methodological decisions with the cited sources and, when appropriate, a qualified research methodologist or statistician.