DAGs, Mediation & the Structural Causal Model

Python · from scratch + networkx  ·  R · dagitty, ggdag, mediation  ·  simulations with known effects

Which Variables Belong in the Model

Every page in this arc so far chose an estimator — matching, instrumental variables, a discontinuity, a policy date. None of them answered the question that comes first: which variables belong in the adjustment set at all? That question has a formal answer, and it is graphical.

A structural causal model is one equation per variable, each writing that variable as a function of its direct causes plus noise. Its directed acyclic graph draws an arrow from each cause to each effect. Pearl's do-operator, P(Ydo(X=x))P(Y \mid do(X=x)), is the distribution of YY under an intervention that sets X=xX = x — surgically deleting the arrows into XX — as against merely observing X=xX = x. The whole enterprise is to write the first using only quantities you can compute from the second.

The back-door criterion is the first rule: to identify the effect of XX on YY, adjust for a set that blocks every path from XX to YY beginning with an arrow into XX, without opening new ones. On a simulated fork — ZZ causing both XX and YY, with a true effect of 2 — the naive regression returns 3.48 and the adjusted one returns 2.00. That is not a new technique. It is unconfoundedness, the assumption the entire selection-on-observables group rests on, restated as a property of a picture.

The Control That Creates the Bias

Then the rule that runs the other way, and it is the reason this page exists. A collider is a common effect of two variables: XCYX \rightarrow C \leftarrow Y. Along a path a collider is naturally blocked. Conditioning on it opens the path, manufacturing an association with no causal content whatever.

regressionestimatetrue effectverdict
Y ~ X1.982correct — the collider path is blocked
Y ~ X + C0.502conditioning opened it

The algebra gives exactly 0.5 for this design, so the miss is structural, not sampling noise.

Simulated with a true effect of 2, the correct regression gives 1.98 and adding the collider as a “control” gives 0.50 — a quarter of the truth, and the algebra says exactly 0.5, so this is structural rather than unlucky. Nothing about the output looks wrong. The coefficient is precise, the model fits better, and the estimate is off by a factor of four.

This is not a curiosity about a third variable. Selection into a sample is conditioning on a collider. Surviving to be surveyed, being admitted to hospital, remaining in a panel, appearing in an administrative file — each is a common effect of the things being studied, and each induces the same spurious association silently, in data that looks complete. The instinct that more controls are safer is not merely imperfect here; it is backwards, and no amount of care with standard errors detects it.

Identification Through a Mediator

Sometimes the back door cannot be closed at all. If an unobserved UU causes both XX and YY, no set of measured variables blocks the path. Pearl's front-door criterion recovers identification anyway, provided a mediator MM carries the whole effect, is not itself affected by UU, and has its own effect on YY unconfounded given XX. The effect is then chained through two identified pieces:

P(Ydo(X))=mP(mX)xP(Ym,x)P(x)P(Y\mid do(X))=\sum_{m}P(m\mid X)\sum_{x'}P(Y\mid m,x')\,P(x')

The motivating story is smoking → tar → cancer with an unobserved genetic confounder: the gene cannot be adjusted away, and the effect can still be identified through tar. Simulated with a true effect of 0.8×1.5=1.20.8 \times 1.5 = 1.2, the naive regression gives 2.24 and the front-door estimate gives 1.246.

One note on what is actually computed. The displayed formula is a sum over mm; the notebook evaluates the product aba \cdot b. Those coincide in the linear-Gaussian case and only there — with a binary or nonlinear mediator the sum is what must be evaluated, and the product quietly stops being the same quantity.

And then the condition the criterion actually turns on. Front door requires that UU does not affect MM. That is a claim about an unobserved variable, so it cannot be checked — which makes its price worth knowing. Varying the UMU \rightarrow M arrow upward from zero:

UM strengthfront-door estimateerrornaive Y ~ X
0.0 criterion holds1.21+1%2.20
0.31.71+43%2.46
0.62.18+82%2.63
1.02.81+134%2.97

True effect 1.2 throughout. The estimator returns a number in every row.

A violation the size of the XMX \rightarrow M path itself puts the estimate 134% above the truth, and the direction matters: it slides back toward the naive value it was brought in to escape, reaching 2.81 against a naive 2.97. The estimator returns a number in every row and nothing in the data indicates which row you are in. The front door does not remove an untestable assumption; it exchanges one for another — often a more defensible one, which is a real gain, but a trade rather than an escape.

Through What Mechanism — and What the Experiment Does Not Buy

The last rule asks a different question: not whether XX affects YY but through what. Causal mediation splits the total effect into an indirect part running through the mediator — the ACME — and a direct part that does not. In the linear case the indirect effect is the product of the XMX \rightarrow M and MYM \rightarrow Y paths. Simulated with a true direct effect of 0.50 and indirect of 0.7×1.2=0.840.7 \times 1.2 = 0.84, the decomposition recovers 0.50 and 0.88, summing exactly to the total.

The decomposition rests on more than the experiment does, and this is the sharpest finding on the page. Randomizing XX identifies the total effect. It does not identify the split, which additionally requires no unobserved confounding of the mediator–outcome relationship — sequential ignorability. Adding a confounder of MM and YY while leaving XX randomized exactly as before:

confounder strengthtotaldirect (ADE)indirect (ACME)MY coefficient
0.0 assumption holds1.320.520.801.23
0.51.430.401.031.38
1.01.300.121.181.68
1.51.420.061.361.89
truth1.340.500.841.20

X stays randomized in every row. Only the mediator–outcome relationship is confounded.

Read the total column first. It never moves more than 0.09 from the true 1.34, because XX was randomized and nothing about the confounder touches that. The experiment is fine. The mechanism story is not: the MYM \rightarrow Y coefficient absorbs the confounder, climbing from 1.23 to 1.89, so the indirect effect inflates and the direct effect is pushed down to compensate — reaching 0.06 against a true 0.50, which is 87% of it gone.

At that point the output reads almost entirely mediated, and it is wrong: 37% of the true effect never passes through the mediator at all. This is the most transferable version of a pattern the arc keeps producing. A randomized experiment buys the total effect and nothing else. Every mechanism claim layered on top of it is observational, rests on an assumption the randomization did not purchase, and is printed in the same table with the same standard errors.

Two Languages, One Problem

Which makes the closing point of the whole arc available. DAGs and potential outcomes are two languages for one problem. The do-operator P(Ydo(X))P(Y \mid do(X)) corresponds to the potential outcome Y(x)Y(x); d-separation in the graph corresponds to conditional independence in the data; and the back-door criterion is ignorability. They are not competing frameworks and the choice between them is not ideological. Graphs are better at encoding assumptions transparently and deriving what is identified from them; potential outcomes are better at defining estimands and estimators precisely. Back-door adjustment, instrumental variables and the front door are three graphically distinct identification strategies, and seeing that they are distinct is the thing that separates causal reasoning from tool use.

Where this sits

The back-door criterion formalises the assumption behind matching, and the collider warning explains why the variable-selection step for a propensity model must include confounders while excluding colliders and mediators — a distinction no fit statistic can make. The front door is a third identification route alongside instrumental variables and regression discontinuity, used when the back door is closed. And the next page inverts this one: here the graph was given and identification read off it; there the graph itself is learned from data.

Notebooks

References