← Methods repository
CONCEPTADVANCEDPYTHON · R · SASlast reviewed 2026-10-31 · updated 2026-11-01 · 1 citation

Causal Mediation Analysis

Estimation of pathway-specific causal contrasts through a post-treatment mediator, with explicit direct/indirect estimands and assumptions beyond those needed for the total treatment effect.

Causal Inference Methodcausal-inference-methodoperational-specificationsynthetic-worked-example
On this page
Methods reference only. Use primary source citations and local policy before applying this in a study protocol, regulatory submission, payer dossier, or clinical decision.
In plain language

Estimation of pathway-specific causal contrasts through a post-treatment mediator, with explicit direct/indirect estimands and assumptions beyond those needed for the total treatment effect. Use when the scientific question concerns a specified pathway and the data and assumptions support more than a total-effect comparison.

When to use it
—Compared with total-effect estimation, mediation can illuminate a pathway but needs stronger assumptions and more temporal/measurement detail.
Watch out for
—Do not call the coefficient change after adjusting for a mediator a causal indirect effect, condition on an exposure-induced collider without justification, assume randomized treatment randomizes the mediator, or...

Definition and scope

Estimation of pathway-specific causal contrasts through a post-treatment mediator, with explicit direct/indirect estimands and assumptions beyond those needed for the total treatment effect. The target population, use, and analysis remain protocol decisions; this card explains the choices and their consequences rather than approving a study.

Operational specification

Define treatment, mediator, outcome, their timing, baseline confounders, exposure-induced mediator-outcome confounders, target population, and controlled, natural, or interventional direct/indirect contrasts. Natural effects involve cross-world counterfactual structure; alternative interventional effects can target different questions under different identification conditions.

Analysis and diagnostics

Use an identification argument and estimator compatible with mediator/outcome types and the assumed confounding structure. Check positivity, measurement and temporal ordering, treatment-mediator interaction, and sensitivity to unmeasured mediator-outcome confounding. Explain the effect scale before decomposing a total effect or calculating a proportion mediated.

When NOT to use and common errors

Do not call the coefficient change after adjusting for a mediator a causal indirect effect, condition on an exposure-induced collider without justification, assume randomized treatment randomizes the mediator, or report a proportion mediated without checking scale, interaction, and near-zero/opposite-signed effects.

Worked example and implementation boundary

Under a synthetic additive decomposition already justified by a causal model, direct risk difference is 0.03 and indirect risk difference is 0.02. Sum them; the arithmetic does not establish identification. The stated additive total is 0.05. Natural or interventional decomposition assumptions must be justified separately. The code performs that explicitly stated calculation with synthetic inputs. It is not a complete fitted analysis and does not demonstrate the identification assumptions, estimate sampling uncertainty, or certify application in another population.

Data-source and reporting requirements

Preserve the provenance, dates, units, and observation rule for each input. Claims capture services and transactions under observable benefits; absence of a record is not proof that an event or resource use did not occur. EHR and registry measurements depend on the collection process and may miss care outside the system. Linked sources add reconciliation and selection questions. Primary collection can improve a missing domain but still requires valid measurement and follow-up. Report which of these limitations affects the stated use, which evidence supports the chosen inputs, and what remains uncertain.

Worked example

Scenario

Under a synthetic additive decomposition already justified by a causal model, direct risk difference is 0.03 and indirect risk difference is 0.02. Sum them; the arithmetic does not establish identification.

Dataset

Synthetic inputs with units defined in the scenario; no patient data.

inputvalue
direct_rd0.03
indirect_rd0.02

Steps

1Use an identification argument and estimator compatible with mediator/outcome types and the assumed confounding structure. Check positivity, measurement and temporal ordering, treatment-mediator interaction, and sensitivity to unmeasured mediator-outcome confounding. Explain the effect scale before decomposing a total effect or calculating a proportion mediated.
2Evaluate direct_rd+indirect_rd using the stated synthetic inputs.

Result

The stated additive total is 0.05. Natural or interventional decomposition assumptions must be justified separately.

Trade-offs

vs. The alternative described in the method comparison
Pros of this
—Use when the scientific question concerns a specified pathway and the data and assumptions support more than a total-effect comparison.

Code example

Executed example · Python 3.11.15 · 2026-11-01T02:04:28+00:00

Self-contained synthetic calculation for the worked example only. Inputs and units are listed in the dataset; output is the displayed scalar. This does not fit the full study/model, estimate uncertainty, or select an analysis for a real study.

direct_rd = 0.03
indirect_rd = 0.02
result = direct_rd+indirect_rd
assert abs(result - 0.05) < 1e-9
print(result)

Citations

FOUNDATIONAL / METHODS
  1. [1]Valeri L, et al. Mediation analysis allowing for exposure–mediator interactions and causal interpretation: Theoretical assumptions and implementation with SAS and SPSS macros.. Psychological Methods. 2013.