liveBook · Manning

Mediator

As explained in Causal Inference for Data Science

A mediating variable is a variable through which part or all of the causal influence of one variable on another operates.

A mediator is a variable through which part or all of the causal influence of one variable on another operates. In a causal diagram, treatment affects the mediator, which affects the outcome: T → M → O. A treatment may also affect the outcome directly, so the mediator identifies one route rather than the entire effect. section 2.5.4 section 6.1.2

Kidney-stone treatment

Suppose treatment changes post-treatment kidney-stone size, and stone size affects recovery. Post-treatment size is a mediator: treatment influences recovery directly and indirectly through the change in size. The overall treatment effect includes both routes. section 2.5.4 section 6.1.2

Figure 2.13 Graph with a mediator. For example, post-treatment size is a mediator in the kidney stone example. Once a treatment is given to a patient, their kidney stone’s size may change. M stands for Mediator, T for Treatment, and O for Outcome.
figure

Use the causal graph to distinguish the direct treatment-to-outcome path from the indirect path through post-treatment size. section 2.5.4

A mediator changes how causal effects should be interpreted and estimated:

  • Estimate the total effect without adjusting for the mediator when the goal is to capture every way treatment affects the outcome. Adjusting for the mediator can introduce bias. section 2.5.4 section 2.5.9
  • Separate direct and indirect effects when the mechanism matters. In linear models, total effect equals direct effect plus indirect effect; this equality does not generally hold for nonlinear models. section 6.1.2
  • Classify the middle variable before choosing an adjustment strategy: a mediator differs from a confounder and a collider, even when all appear in a three-node graph. section 6.1.2 section 2.5.9
Table 2.7 Types of variables to consider in the adjustment formula
Type of variable
Should it be included in the adjustment formula for calculating P( Y = 1|do( X = x))?
Confounder
Definitely.
Missing confounder
Definitely, but not possible. This is a problem!
Mediator
No: it will introduce bias.
Outcome predictive variable
It doesn’t introduce bias; in general, it is recommended because it may improve statistical accuracy.
Treatment predictive variable
It doesn’t introduce bias; in general, it is not recommended because it may hurt statistical accuracy.

Check the adjustment table for the contrast between mediators, confounders, and predictive variables. section 2.5.9

Regression makes the distinction operational: with a mediator Z, a model including X and Z estimates the direct effect, while a model using X alone estimates the total effect. The treatment, mediator, or confounder role depends on the causal question being asked. section 6.1.2 section 6.1.2

Table 6.6 Mediator: causal paths
DAG
In equations
Mediator: causal paths shown with double-headed arrows comprise the direct path from X to Y and the path that goes through Z.
sidebar figure
sidebar figure
where ε Z, ε X, and ε Y are independent of each other.

Compare the equation and diagram for the two causal paths connecting X and Y through mediator Z. section 6.1.2

How Causal Inference for Data Science covers it

How deep it goes
Explains DAG roles, adjustment consequences, and linear-regression estimates, but defers nonlinear effects and counterfactual definitions.
Examples
Uses kidney-stone size, pageview platforms, and clinical-trial side effects to contrast mediators with other causal roles.
What it assumes
Assumes familiarity with treatments, outcomes, causal graphs, confounding, and adjustment while distinguishing these roles through examples.
What you can do after
Diagnose mediator roles in causal graphs and choose whether adjustment estimates a total or direct effect.
How it connects
Connects mediators with causal diagrams, confounders, colliders, direct effects, indirect effects, total effects, and regression.

Also explained in

Compare how 2 books explain mediator →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Causal Inference for Data Science. The section links point to the parts of the book it draws on.