Simple Algorithm
Artificial Intelligence · Deep Layer · 30 min

Causal Inference

Correlation, intervention and the do-calculus.

In a well-known kidney-stone study, open surgery succeeded more often than a newer keyhole procedure for small stones and for large stones, yet less often overall. Which should a patient choose? The data alone cannot say; the answer depends on how the data were generated. Causal inference makes that dependence precise: graphs encode the assumptions, the do-operator defines interventions, and a handful of theorems say exactly when observational data can stand in for an experiment.

What you’ll learn

  • Define structural causal models and interventions, and derive the truncated factorization of P(v∣do(x))P(v\mid\mathrm{do}(x)).
  • Resolve Simpson's paradox with the backdoor criterion, and apply the front-door formula when the confounder is unobserved.
  • State the three rules of the do-calculus, derive the backdoor formula from them, and state the completeness theorem for identification.
  • Prove that randomization identifies the average treatment effect, and use propensity scores under ignorability.

Structural causal models and the do-operator

Simpson's paradox and the backdoor criterion

StonesOpen surgeryPercutaneous
Small93% (81/87)87% (234/270)
Large73% (192/263)69% (55/80)
All78% (273/350)83% (289/350)
Success rates from Charig et al. (1986), the standard illustration of Simpson's paradox. Open surgery wins in each stratum and loses in the pooled data, because surgeons gave it mostly to the harder, large stones: 263 of its 350 patients, against 80 of 350 for the keyhole procedure.

Stone size affects both the choice of treatment and the outcome, so it is a confounder: in the graph S→TS\to T, S→YS\to Y, T→YT\to Y, the path T←S→YT\leftarrow S\to Y carries association that is not causation. The general condition for removing such paths is graphical.

Predict before you look

Stone size satisfies the backdoor criterion, and 357 of the 700 patients (51%) had small stones. Using the stratum success rates of open surgery, 93.1% and 73.0%, what is P(success∣do(open surgery))P(\text{success}\mid\mathrm{do}(\text{open surgery}))?

Show the answer

83 %

0.931×0.51+0.730×0.49≈0.8330.931\times0.51+0.730\times0.49\approx0.833. The same adjustment for the keyhole procedure gives 0.867×0.51+0.6875×0.49≈0.7790.867\times0.51+0.6875\times0.49\approx0.779, so open surgery is better by about 5 points, reversing the pooled comparison (78% against 83%). Conditioning weights the strata by P(z∣t)P(z\mid t): 25% small stones among open-surgery patients but 77% among keyhole patients.

The table never decides by itself. If the third variable were a mediator, caused by the treatment and affecting the outcome (say, blood pressure measured after the operation), adjusting for it would remove part of the very effect being estimated; if it were a collider, adjusting would create bias. Identical numbers can call for opposite analyses, which is Pearl's resolution of the paradox: the graph, not the data, says which comparison answers the causal question.

When the confounder is unobserved, a mediator can still rescue identification. If MM intercepts every directed path from XX to YY, nothing confounds XX and MM, and XX blocks every backdoor path from MM to YY, the front-door formula holds (the textbook case is smoking, tar deposits and cancer, with an unobserved genotype):

P(y∣do(x))=∑mP(m∣x)∑x′P(y∣m,x′) P(x′).P(y\mid\mathrm{do}(x))=\sum_mP(m\mid x)\sum_{x'}P(y\mid m,x')\,P(x').

The do-calculus and identifiability

Write GX‾G_{\overline X} for the graph with the arrows into XX deleted and GZ‾G_{\underline Z} for the graph with the arrows out of ZZ deleted. An effect is identifiable if it is determined by the observational distribution in every model compatible with the graph, latent confounders included (drawn as bidirected edges).

DerivationThe backdoor formula from the rules
  1. P(y∣do(x))=∑zP(y∣do(x),z) P(z∣do(x))P(y\mid\mathrm{do}(x))=\sum_zP(y\mid\mathrm{do}(x),z)\,P(z\mid\mathrm{do}(x))

    Condition on ZZ inside the interventional distribution:

  2. P(y∣do(x),z)=P(y∣x,z)P(y\mid\mathrm{do}(x),z)=P(y\mid x,z)

    Rule 2: in GX‾G_{\underline X} every remaining path from XX to YY starts with an arrow into XX, and ZZ blocks them all, so (Y⊥ ⁣ ⁣ ⁣⊥X∣Z)(Y\indep X\mid Z) holds there and the action becomes an observation:

  3. P(z∣do(x))=P(z)⟹P(y∣do(x))=∑zP(y∣x,z) P(z)P(z\mid\mathrm{do}(x))=P(z)\qquad\Longrightarrow\qquad P(y\mid\mathrm{do}(x))=\sum_zP(y\mid x,z)\,P(z)

    Rule 3: ZZ contains no descendant of XX, and in GX‾G_{\overline X} the node XX has no parents, so (Z⊥ ⁣ ⁣ ⁣⊥X)(Z\indep X) there and the intervention does not change ZZ. ∎

Some effects are not identifiable at all. With X→YX\to Y and a latent common cause of XX and YY, two models can share every observational probability P(x,y)P(x,y) yet disagree on P(y∣do(x))P(y\mid\mathrm{do}(x)); only an experiment, or further assumptions, can settle it. Pearl's ladder of causation orders the questions: association P(y∣x)P(y\mid x), intervention P(y∣do(x))P(y\mid\mathrm{do}(x)), and counterfactuals such as "would this patient have recovered without the drug?". Bareinboim, Correa, Ibeling and Icard (2022) proved that, in a precise measure-theoretic sense, the rungs almost never collapse: without causal assumptions, observational data almost never determine interventional answers.

Experiments, potential outcomes and the frontier

In the potential outcomes framework (Neyman, 1923; Rubin, 1974), each unit has outcomes Y(1)Y(1) and Y(0)Y(0) under treatment and control, and the average treatment effect is ATE=E[Y(1)−Y(0)]\mathrm{ATE}=\E[Y(1)-Y(0)]. Only one is ever observed, Y=T Y(1)+(1−T) Y(0)Y=T\,Y(1)+(1-T)\,Y(0). The two languages agree: Y(x)Y(x) is YY in the model modified by do(T=x)\mathrm{do}(T=x), so E[Y(1)]=E[Y∣do(T=1)]\E[Y(1)]=\E[Y\mid\mathrm{do}(T=1)].

DerivationWithout randomization: propensity scores (Rosenbaum & Rubin, 1983)
  1. (Y(0),Y(1))⊥ ⁣ ⁣ ⁣⊥T∣e(X)\big(Y(0),Y(1)\big)\indep T\mid e(X)

    Assume ignorability given covariates, (Y(0),Y(1))⊥ ⁣ ⁣ ⁣⊥T∣X\big(Y(0),Y(1)\big)\indep T\mid X (the backdoor criterion with Z=XZ=X), and positivity, 0<e(X)<10<e(X)<1 for the propensity score e(x)=P(T=1∣X=x)e(x)=P(T=1\mid X=x). Rosenbaum and Rubin proved that the scalar e(X)e(X) then suffices for adjustment:

  2. E[TYe(X)]=E[E[T∣X] E[Y(1)∣X]e(X)]=E[E[Y(1)∣X]]=E[Y(1)]\E\Big[\frac{TY}{e(X)}\Big]=\E\Big[\frac{\E[T\mid X]\,\E[Y(1)\mid X]}{e(X)}\Big]=\E\big[\E[Y(1)\mid X]\big]=\E[Y(1)]

    Inverse-propensity weighting recovers each mean. Condition on XX, and use consistency (TY=T Y(1)TY=T\,Y(1)) and ignorability:

  3. ATE^IPW=1n∑i=1n(TiYie^(Xi)−(1−Ti) Yi1−e^(Xi))\widehat{\mathrm{ATE}}_{\mathrm{IPW}}=\frac1n\sum_{i=1}^n\Big(\frac{T_iY_i}{\hat e(X_i)}-\frac{(1-T_i)\,Y_i}{1-\hat e(X_i)}\Big)

    Weights explode when e(X)e(X) nears 0 or 1, which is positivity failing in practice. Doubly robust estimators combine outcome regression with weighting and stay consistent if either model is right; double/debiased machine learning (Chernozhukov et al., 2018) fits both with flexible models and cross-fitting while keeping n\sqrt n-rate confidence intervals.

Check your understanding

In a randomized trial, treatment TT lowers blood pressure MM, measured afterwards, and both TT and MM affect the outcome YY. To estimate the total effect of TT on YY, should you adjust for MM?

  1. Yes: adjusting for more variables always reduces bias
  2. Yes, because MM is correlated with both TT and YY
  3. No: MM is a mediator, so adjusting for it removes part of the effect being estimated
  4. Only if MM is binary
Show the answer

C. No: MM is a mediator, so adjusting for it removes part of the effect being estimated

Randomization already identifies the total effect by the plain difference in means. Conditioning on a mediator blocks the path T→M→YT\to M\to Y, and if MM shares an unobserved cause with YY, it also opens a collider path and introduces bias.

Key takeaways

  • An intervention replaces a mechanism. In Markovian models P(v∣do(x))P(v\mid\mathrm{do}(x)) is the truncated factorization, and seeing differs from doing: observing the sprinkler lowers P(Rain) to 30%, switching it on leaves 50%.
  • Simpson's paradox is resolved by the causal graph. Adjust for confounders with ∑zP(y∣x,z)P(z)\sum_zP(y\mid x,z)P(z) (open surgery: 83% against 78% for the keyhole procedure), never for mediators or colliders; the front-door formula handles some unobserved confounders.
  • The do-calculus has three rules and is complete for identification; some effects, such as the bow graph's, are not identifiable without experiments.
  • Randomization identifies the average treatment effect. Under ignorability and positivity, propensity scores and inverse weighting do too, and doubly robust and double machine-learning estimators add flexibility with valid inference.

Check yourself

In the interactive lesson these are scored with your confidence, and what you miss comes back for review.

Question 1

In the sprinkler network (Cloudy causes both Sprinkler and Rain, with P(Rain)=0.5P(\text{Rain})=0.5), what is P(Rain∣do(Sprinkler=on))P(\text{Rain}\mid\mathrm{do}(\text{Sprinkler}=\text{on}))?

  1. 30%
  2. 50%
  3. 80%
  4. 71%
Show the answer

B. 50%

The intervention cuts Cloudy → Sprinkler and leaves every other mechanism alone, so Rain keeps its marginal, 50%. Observing the sprinkler on gives 30%, because it is evidence of a clear day.

Question 2

The graph has Z→XZ\to X, Z→YZ\to Y, X→MX\to M and M→YM\to Y. Which adjustment set satisfies the backdoor criterion for the effect of XX on YY?

  1. {M}\{M\}
  2. {Z,M}\{Z,M\}
  3. The empty set
  4. {Z}\{Z\}
Show the answer

D. {Z}\{Z\}

The only backdoor path is X←Z→YX\leftarrow Z\to Y, which ZZ blocks, and ZZ is not a descendant of XX. MM is a descendant of XX (a mediator), so it may not be in the set.

Question 3

XX causes YY, and an unobserved variable causes both. Nothing else is measured. Is P(y∣do(x))P(y\mid\mathrm{do}(x)) identifiable from P(x,y)P(x,y)?

  1. Yes, it equals P(y∣x)P(y\mid x)
  2. No: models with the same P(x,y)P(x,y) can disagree on it
  3. Yes, by the front-door formula
  4. Yes, if the sample is large enough
Show the answer

B. No: models with the same P(x,y)P(x,y) can disagree on it

This "bow" graph is the canonical non-identifiable case: the latent confounder can produce any observed association, so an experiment or extra structure, such as a front-door mediator or an instrument, is needed.

Question 4

Why is the difference in mean outcomes between treated and control groups an unbiased estimate of the average treatment effect in a randomized trial?

  1. Because randomization makes treatment independent of the potential outcomes, so E[Y∣T=t]=E[Y(t)]\E[Y\mid T=t]=\E[Y(t)]
  2. Because randomization removes all variance from the outcomes
  3. Because trials always use large samples
  4. Because the treated and control groups have identical members
Show the answer

A. Because randomization makes treatment independent of the potential outcomes, so E[Y∣T=t]=E[Y(t)]\E[Y\mid T=t]=\E[Y(t)]

Consistency gives E[Y∣T=1]=E[Y(1)∣T=1]\E[Y\mid T=1]=\E[Y(1)\mid T=1], and independence removes the conditioning. Randomization balances confounders, measured or not, in expectation.

Further reading

  • J. Pearl, Causality: Models, Reasoning, and Inference, 2nd ed. (Cambridge University Press, 2009).
  • J. Pearl, "Causal diagrams for empirical research," Biometrika 82(4), 669–688 (1995).
  • I. Shpitser & J. Pearl, "Identification of joint interventional distributions in recursive semi-Markovian causal models," AAAI (2006).
  • P. R. Rosenbaum & D. B. Rubin, "The central role of the propensity score in observational studies for causal effects," Biometrika 70(1), 41–55 (1983).
  • M. A. Hernán & J. M. Robins, Causal Inference: What If (Chapman & Hall/CRC, 2020).