Inferensys

Glossary

Causal Mediation Analysis

Causal mediation analysis is a method to decompose a total treatment effect into direct and indirect effects, quantifying the extent to which the effect operates through a specific intermediate variable, or mediator.
Stylish WeWork-like workspace with hot desks and document wall, professional searching through enterprise knowledge base on a mounted ultrawide display, warm industrial pendants overhead.
CAUSAL REASONING MODELS

What is Causal Mediation Analysis?

Causal mediation analysis is a statistical method used to decompose a total treatment effect into direct and indirect effects, quantifying the extent to which the effect operates through a specific intermediate variable, or mediator.

Causal mediation analysis is a formal method for decomposing a total causal effect into its direct effect (the treatment's impact on the outcome not through the mediator) and its indirect effect (the portion transmitted through the mediator). This requires specifying a causal model, often a Structural Causal Model (SCM) or causal graph, that defines the relationships between treatment, mediator, outcome, and potential confounders. The analysis moves beyond correlation to answer how a cause produces its effect.

The method relies on the counterfactual framework to define effects like the Natural Direct Effect (NDE) and Natural Indirect Effect (NIE), which sum to the Average Treatment Effect (ATE). Key assumptions include sequential ignorability (no unmeasured confounding of either the treatment-mediator or mediator-outcome relationships). It is distinct from traditional path analysis as it explicitly models interventions using the do-operator, enabling the estimation of effects that have a clear causal interpretation under the specified model.

CAUSAL REASONING MODELS

Key Components of Mediation Analysis

Causal mediation analysis decomposes a total treatment effect into direct and indirect pathways. These components define the formal quantities, assumptions, and methods required to estimate how much of an effect operates through a specific intermediate variable.

01

Total Effect (TE)

The Total Effect (TE) is the overall causal effect of a treatment (X) on an outcome (Y), encompassing all possible pathways. It is the difference in the expected outcome when the treatment is present versus absent, formally: TE = E[Y | do(X=1)] - E[Y | do(X=0)]. In mediation, the TE is the sum of the direct and indirect effects.

02

Natural Direct Effect (NDE)

The Natural Direct Effect (NDE) quantifies the portion of the total effect that operates on the outcome through pathways not involving the specified mediator (M). It measures the change in Y when X changes, but the mediator is held at the value it would have naturally taken without the treatment. It answers: 'What is the effect of X on Y if we disable the path through M?'

03

Natural Indirect Effect (NIE)

The Natural Indirect Effect (NIE) quantifies the portion of the total effect that operates on the outcome through the specified mediator (M). It measures the change in Y when the treatment is fixed, but the mediator changes to the value it would have under treatment. Formally, it captures: TE = NDE + NIE. It answers: 'What is the effect of X on Y that is transmitted via M?'

04

Controlled Direct Effect (CDE)

The Controlled Direct Effect (CDE) is an alternative to the NDE. It measures the effect of the treatment on the outcome when the mediator is experimentally set to a specific, fixed value for the entire population (M = m). Unlike the NDE, it does not allow the mediator to vary naturally. The CDE is useful for policy questions about manipulating both X and M simultaneously.

05

Sequential Ignorability

Sequential Ignorability is the core set of assumptions required to identify natural direct and indirect effects from observational data. It consists of two main conditions:

  • No Unmeasured Confounding of X->Y and X->M: All common causes of treatment and outcome/mediator are observed.
  • No Unmeasured Confounding of M->Y: After conditioning on treatment and pre-treatment covariates, there are no unobserved common causes of the mediator and outcome. Violations of these assumptions, particularly the second, are a major source of bias.
06

Mediation Formulas

The Mediation Formulas provide the mathematical expressions to estimate NDE and NIE from observed data under the sequential ignorability assumptions. For a binary treatment, they integrate over the distribution of covariates (C) and the mediator:

  • NDE = Σ_c Σ_m [E(Y | X=1, M=m, C=c) - E(Y | X=0, M=m, C=c)] * P(M=m | X=0, C=c) * P(C=c)
  • NIE = Σ_c Σ_m E(Y | X=1, M=m, C=c) * [P(M=m | X=1, C=c) - P(M=m | X=0, C=c)] * P(C=c) These formulas are implemented in software packages like mediation in R.
CAUSAL REASONING MODELS

How Causal Mediation Analysis Works

Causal mediation analysis is a statistical method used to decompose the total effect of a treatment or intervention into its constituent direct and indirect pathways, quantifying the role of an intermediate variable, or mediator.

Causal mediation analysis formally decomposes a total treatment effect into a direct effect and an indirect effect (or mediated effect). The direct effect is the impact of the treatment on the outcome that does not pass through the specified mediator variable. The indirect effect is the portion of the total effect that operates through the mediator, quantifying how much the treatment changes the mediator, which in turn changes the outcome. This decomposition relies on a causal graph and assumptions like sequential ignorability to identify these effects from data.

The analysis employs a counterfactual framework, comparing potential outcomes under different treatment and mediator states. Key estimands include the Natural Direct Effect (NDE) and Natural Indirect Effect (NIE), which sum to the Average Total Effect (ATE). This method is crucial for explainable AI and causal fairness, as it reveals the mechanisms behind an observed effect, distinguishing between direct discrimination and effects mediated by permissible factors. It requires careful control for post-treatment confounding to avoid bias.

CAUSAL MEDIATION ANALYSIS

Frequently Asked Questions

Causal mediation analysis is a statistical technique used to decompose the total effect of a treatment or intervention into its direct and indirect components, quantifying the role of intermediate variables. These FAQs address its core mechanisms, applications, and implementation for engineers and data scientists.

Causal mediation analysis is a method for quantifying the extent to which a treatment's effect on an outcome operates through a specific intermediate variable, known as a mediator. It works by decomposing the total treatment effect into two components: the direct effect (the effect of the treatment not passing through the mediator) and the indirect effect (the effect transmitted via the mediator). This is formalized using a counterfactual framework and structural causal models (SCMs), where potential outcomes are defined under different combinations of treatment and mediator values. The analysis requires strong assumptions, primarily sequential ignorability, which posits no unmeasured confounding of either the treatment-mediator or mediator-outcome relationships after conditioning on observed covariates.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.