Math for Causal Inference

Day 52. The Back-Door Criterion

A graphical test for which covariates to adjust for. A set Z is admissible if it contains no descendant of the treatment and blocks every path that enters the treatment through an arrow pointing into it; then the adjustment formula identifies the causal effect.

Video coming soon
Learning outcomes
  • ●Identify back-door paths and test whether a set satisfies the back-door criterion.
  • ●Find all minimal admissible adjustment sets in small DAGs.
  • ●Compute causal effects with the back-door adjustment formula and its weighting form.
  • ●Connect the criterion to Phase 3's unconfoundedness and to regression adjustment.
2-HOUR SESSION PLAN
Theory 25′Warm-up (1–5) 20′Proofs (6–10) 35′Applied (11–15) 25′Python & Lab 15′
Colab notebook (.ipynb) Jump to the simulator

Theory

Back-door paths

A back-door path from XX to YY is a path that starts with an arrow into XX: X←⋯YX \leftarrow \cdots Y. Directed paths X→⋯→YX \to \cdots \to Y carry the effect; back-door paths carry confounding.

The criterion

A set of variables Z\mathbf Z satisfies the back-door criterion relative to (X,Y)(X, Y) if

  1. no node in Z\mathbf Z is a descendant of XX, and
  2. Z\mathbf Z blocks every back-door path from XX to YY (in the sense of d-separation).

The back-door adjustment formula

If Z\mathbf Z satisfies the criterion, the causal effect is identified:

P(y∣do⁡(x))=∑zP(y∣x,z) P(z).P(y \mid \operatorname{do}(x)) = \sum_{\mathbf z} P(y \mid x, \mathbf z)\,P(\mathbf z).

Equivalently, in weighting form,

P(y∣do⁡(x))=∑zP(x,y,z)P(x∣z),P(y \mid \operatorname{do}(x)) = \sum_{\mathbf z} \frac{P(x, y, \mathbf z)}{P(x \mid \mathbf z)},

which is IPW (Day 44) with propensity P(x∣z)P(x \mid \mathbf z).

Why the two conditions?

  • Condition 2 removes all non-causal association.
  • Condition 1 keeps the causal paths intact: conditioning on a mediator would block part of the effect; conditioning on a descendant of XX that is also affected by YY's causes could open new paths.

In SCM terms, Z\mathbf Z satisfying the back-door criterion implies conditional ignorability, Y(x)⊥ ⁣ ⁣ ⁣⊥X∣ZY(x) \perp\!\!\!\perp X \mid \mathbf Z (generalising Day 51, Exercise 9). The criterion is a way to check Phase 3's unconfoundedness assumption from a graph, and to choose which XX variables to include.

Several valid sets

There may be many admissible sets, or none among the observed variables. The parents of XX always qualify if they are observed. Different admissible sets give the same estimand but different precision (Day 53).

Linear models

If E[Y∣x,z]E[Y \mid x, \mathbf z] is linear, E[Y∣x,z]=a+bx+c⊤zE[Y \mid x, \mathbf z] = a + bx + \mathbf c^\top\mathbf z, then by the adjustment formula E[Y∣do⁡(x)]=a+bx+c⊤E[Z]E[Y \mid \operatorname{do}(x)] = a + bx + \mathbf c^\top E[\mathbf Z]: the regression coefficient bb is the causal effect when Z\mathbf Z is admissible.

Part 1 · Warm-up

Exercises 1–3 and 5 use this DAG: Z1→Z3←Z2Z_1 \to Z_3 \leftarrow Z_2, Z1→XZ_1 \to X, Z2→YZ_2 \to Y, Z3→XZ_3 \to X, Z3→YZ_3 \to Y, X→W→YX \to W \to Y.

Exercise 1 · Find the back-door paths

List every back-door path from XX to YY and say which are open given no conditioning.

Show solution

Step 1. X←Z3→YX \leftarrow Z_3 \to Y: fork at Z3Z_3: open.

Step 2. X←Z1→Z3→YX \leftarrow Z_1 \to Z_3 \to Y: fork at Z1Z_1, chain at Z3Z_3: open.

Step 3. X←Z3←Z2→YX \leftarrow Z_3 \leftarrow Z_2 \to Y: chain at Z3Z_3, fork at Z2Z_2: open.

Step 4. X←Z1→Z3←Z2→YX \leftarrow Z_1 \to Z_3 \leftarrow Z_2 \to Y: collider at Z3Z_3: blocked.

Answer: four back-door paths, three open.

Exercise 2 · Is {Z3}\{Z_3\} enough?

Does {Z3}\{Z_3\} satisfy the back-door criterion?

Show solution

Step 1. Z3Z_3 blocks the first three paths (it is a fork or chain middle on each).

Step 2. But Z3Z_3 is the collider on the fourth path; conditioning on it opens X←Z1→Z3←Z2→YX \leftarrow Z_1 \to Z_3 \leftarrow Z_2 \to Y.

Answer: no. Z3Z_3 is both a confounder and a collider.

Exercise 3 · All minimal admissible sets

Find every minimal set (no proper subset admissible) among {Z1,Z2,Z3}\{Z_1, Z_2, Z_3\}.

Show solution

Step 1. Z3Z_3 must be included: otherwise X←Z3→YX \leftarrow Z_3 \to Y stays open.

Step 2. With Z3Z_3 included, the fourth path is open unless Z1Z_1 or Z2Z_2 is also conditioned (each is a fork on it).

Step 3. {Z1,Z3}\{Z_1, Z_3\}: blocks paths 1, 2 (at Z1Z_1 or Z3Z_3), 3 (at Z3Z_3) and 4 (at Z1Z_1). Admissible.

Step 4. {Z2,Z3}\{Z_2, Z_3\}: blocks paths 1, 2 and 3 at Z3Z_3, path 4 at Z2Z_2. Admissible.

Answer: {Z1,Z3}\{Z_1, Z_3\} and {Z2,Z3}\{Z_2, Z_3\} (and their superset {Z1,Z2,Z3}\{Z_1, Z_2, Z_3\}).

Exercise 4 · A one-variable adjustment

ZZ is binary with P(Z=1)=0.3P(Z = 1) = 0.3 and satisfies the back-door criterion. E[Y∣X=1,Z=1]=10E[Y \mid X = 1, Z = 1] = 10, E[Y∣X=1,Z=0]=6E[Y \mid X = 1, Z = 0] = 6, E[Y∣X=0,Z=1]=8E[Y \mid X = 0, Z = 1] = 8, E[Y∣X=0,Z=0]=5E[Y \mid X = 0, Z = 0] = 5. Compute the average causal effect.

Show solution

Step 1. E[Y∣do⁡(X=1)]=0.3(10)+0.7(6)=3+4.2=7.2E[Y \mid \operatorname{do}(X = 1)] = 0.3(10) + 0.7(6) = 3 + 4.2 = 7.2.

Step 2. E[Y∣do⁡(X=0)]=0.3(8)+0.7(5)=2.4+3.5=5.9E[Y \mid \operatorname{do}(X = 0)] = 0.3(8) + 0.7(5) = 2.4 + 3.5 = 5.9.

Answer: 7.2−5.9=1.37.2 - 5.9 = 1.3.

Exercise 5 · Adding WW

Is {Z1,Z3,W}\{Z_1, Z_3, W\} admissible? What does adjusting for it estimate?

Show solution

Step 1. WW is a descendant of XX, so condition 1 fails.

Step 2. WW is the middle of the only causal path X→W→YX \to W \to Y; conditioning on it blocks the effect.

Answer: not admissible; the adjusted contrast is 0 in population (no direct effect remains), however large the true effect.

Part 2 · Proofs

Exercise 6 · Deriving the adjustment formula

Assume Z\mathbf Z satisfies the back-door criterion. Prove P(y∣do⁡(x))=∑zP(y∣x,z)P(z)P(y \mid \operatorname{do}(x)) = \sum_{\mathbf z} P(y \mid x, \mathbf z)P(\mathbf z), using two facts: (a) interventions do not change the distribution of non-descendants of XX (Day 51), and (b) if Z\mathbf Z blocks all back-door paths, then P(y∣do⁡(x),z)=P(y∣x,z)P(y \mid \operatorname{do}(x), \mathbf z) = P(y \mid x, \mathbf z) (proved formally on Day 55).

Show solution

Step 1. Law of total probability in the intervened model: P(y∣do⁡(x))=∑zP(y∣do⁡(x),z) P(z∣do⁡(x))P(y \mid \operatorname{do}(x)) = \sum_{\mathbf z} P(y \mid \operatorname{do}(x), \mathbf z)\,P(\mathbf z \mid \operatorname{do}(x)).

Step 2. Z\mathbf Z contains no descendant of XX (condition 1), so by (a) P(z∣do⁡(x))=P(z)P(\mathbf z \mid \operatorname{do}(x)) = P(\mathbf z).

Step 3. By (b), P(y∣do⁡(x),z)=P(y∣x,z)P(y \mid \operatorname{do}(x), \mathbf z) = P(y \mid x, \mathbf z): once Z\mathbf Z blocks the back-door paths, the only remaining association between XX and YY is causal, so observing xx and setting xx are the same.

Step 4. Substitute. ■\blacksquare

Exercise 7 · Parents are admissible

Prove that pa⁡(X)\operatorname{pa}(X) satisfies the back-door criterion (assuming Y∉pa⁡(X)Y \notin \operatorname{pa}(X)).

Show solution

Step 1. Condition 1: a parent of XX cannot be a descendant of XX (that would create a cycle).

Step 2. Condition 2: every back-door path starts X←PX \leftarrow P with P∈pa⁡(X)P \in \operatorname{pa}(X).

Step 3. At PP the path continues out of PP (P→XP \to X points away), so PP is a chain or fork middle, not a collider.

Step 4. PP is conditioned, so the path is blocked. ■\blacksquare

Exercise 8 · The weighting form

Prove ∑zP(y∣x,z)P(z)=∑zP(x,y,z)/P(x∣z)\sum_{\mathbf z} P(y \mid x, \mathbf z)P(\mathbf z) = \sum_{\mathbf z} P(x, y, \mathbf z)/P(x \mid \mathbf z).

Show solution

Step 1. P(x,y,z)=P(y∣x,z)P(x∣z)P(z)P(x, y, \mathbf z) = P(y \mid x, \mathbf z)P(x \mid \mathbf z)P(\mathbf z).

Step 2. Divide by P(x∣z)P(x \mid \mathbf z) (positive by overlap): P(x,y,z)/P(x∣z)=P(y∣x,z)P(z)P(x, y, \mathbf z)/P(x \mid \mathbf z) = P(y \mid x, \mathbf z)P(\mathbf z).

Step 3. Sum over z\mathbf z. ■\blacksquare

Exercise 9 · Regression coefficients under linearity

Suppose Z\mathbf Z is admissible and E[Y∣x,z]=a+bx+c⊤zE[Y \mid x, \mathbf z] = a + bx + \mathbf c^\top\mathbf z. Prove E[Y∣do⁡(x+1)]−E[Y∣do⁡(x)]=bE[Y \mid \operatorname{do}(x + 1)] - E[Y \mid \operatorname{do}(x)] = b.

Show solution

Step 1. Take expectations in the adjustment formula: E[Y∣do⁡(x)]=∑zE[Y∣x,z]P(z)=EZ[a+bx+c⊤Z]E[Y \mid \operatorname{do}(x)] = \sum_{\mathbf z} E[Y \mid x, \mathbf z]P(\mathbf z) = E_{\mathbf Z}[a + bx + \mathbf c^\top\mathbf Z].

Step 2. =a+bx+c⊤E[Z]= a + bx + \mathbf c^\top E[\mathbf Z].

Step 3. The difference between x+1x + 1 and xx is bb. ■\blacksquare

Exercise 10 · Why descendants are excluded

In the chain X→M→YX \to M \to Y with M:=aX+UMM := aX + U_M and Y:=bM+UYY := bM + U_Y, there are no back-door paths, so {M}\{M\} blocks all of them. Show that "adjusting" for MM gives the wrong answer.

Show solution

Step 1. True effect: E[Y∣do⁡(x)]=abxE[Y \mid \operatorname{do}(x)] = abx, slope abab.

Step 2. E[Y∣x,m]=bmE[Y \mid x, m] = bm (given MM, XX adds nothing: chain).

Step 3. "Adjusted" formula: ∑mE[Y∣x,m]P(m)=bE[M]\sum_m E[Y \mid x, m]P(m) = bE[M], which does not depend on xx: slope 0.

Answer: condition 1 is necessary in general; conditioning on a mediator removes the effect it carries. ■\blacksquare

Part 3 · Applied

Exercise 11 · Returns to schooling, revisited

In Day 46's DAG (F→AF \to A, F→SF \to S, A→SA \to S, A→WA \to W, S→OS \to O, S→WS \to W, O→WO \to W), which sets identify the effect of schooling SS on wages WW? What if ability AA is unobserved?

Show solution

Step 1. Back-door paths: S←A→WS \leftarrow A \to W and S←F→A→WS \leftarrow F \to A \to W.

Step 2. {A}\{A\} blocks both (fork or chain middle on each), and AA is not a descendant of SS: admissible. So is {A,F}\{A, F\}.

Step 3. {F}\{F\} blocks the second but not the first path: not admissible. Occupation OO is a descendant: never include it.

Answer: you must observe ability. Without it no back-door set exists among {F,O}\{F, O\}, and other strategies are needed (instruments, Phase 5; or bounds, Day 79).

Exercise 12 · A training programme with a sign reversal

Half the jobseekers were previously employed (Z=1Z = 1). Caseworkers send 30% of previously employed and 70% of others to training TT. Employment rates P(E=1∣T,Z)P(E = 1 \mid T, Z): previously employed 0.60 untrained, 0.70 trained; others 0.20 untrained, 0.35 trained. ZZ is the only confounder. Compute the naive and adjusted effects.

Show solution

Step 1. P(T=1)=0.5(0.3)+0.5(0.7)=0.5P(T = 1) = 0.5(0.3) + 0.5(0.7) = 0.5.

Step 2. Naive, trained: 0.5(0.3)(0.70)+0.5(0.7)(0.35)0.5=0.105+0.12250.5=0.455\dfrac{0.5(0.3)(0.70) + 0.5(0.7)(0.35)}{0.5} = \dfrac{0.105 + 0.1225}{0.5} = 0.455.

Step 3. Naive, untrained: 0.5(0.7)(0.60)+0.5(0.3)(0.20)0.5=0.21+0.030.5=0.480\dfrac{0.5(0.7)(0.60) + 0.5(0.3)(0.20)}{0.5} = \dfrac{0.21 + 0.03}{0.5} = 0.480.

Step 4. Adjusted: P(E∣do⁡(T=1))=0.5(0.70)+0.5(0.35)=0.525P(E \mid \operatorname{do}(T = 1)) = 0.5(0.70) + 0.5(0.35) = 0.525 and P(E∣do⁡(T=0))=0.5(0.60)+0.5(0.20)=0.40P(E \mid \operatorname{do}(T = 0)) = 0.5(0.60) + 0.5(0.20) = 0.40.

Answer: naive −2.5-2.5 points; adjusted +12.5+12.5 points. Training helps, but caseworkers send those with worse prospects.

Exercise 13 · Breastfeeding and child health

A DAG: mother's education E→E \to income II, E→E \to breastfeeding BB, I→BI \to B, I→I \to child health HH, B→B \to infections N→HN \to H, and B→B \to clinic visits C←HC \leftarrow H. Which minimal set identifies the effect of breastfeeding on child health? Which candidate controls must be excluded, and why?

Show solution

Step 1. Back-door paths from BB: B←I→HB \leftarrow I \to H and B←E→I→HB \leftarrow E \to I \to H.

Step 2. {I}\{I\} blocks both (fork on the first, chain on the second): minimal admissible set. {E,I}\{E, I\} is also admissible; {E}\{E\} alone leaves B←I→HB \leftarrow I \to H open.

Step 3. Exclude infections NN: a mediator (descendant of BB) on the causal path.

Step 4. Exclude clinic visits CC: a descendant of BB and a collider (B→C←HB \to C \leftarrow H); conditioning opens a non-causal path.

Answer: adjust for income (optionally education); never for infections or clinic visits.

Exercise 14 · Over-controlling a wage regression

In a simulated programme (code below), prior earnings PP confound training TT and later earnings YY; training raises job tenure JJ, which raises earnings. True total effect of training: 1.0 ($1,000), of which 0.4 runs through tenure. What do regressions of YY on TT with controls ∅\varnothing, {P}\{P\} and {P,J}\{P, J\} estimate?

Show solution

Step 1. ∅\varnothing: the back-door path T←P→YT \leftarrow P \to Y is open: badly biased (the code finds about 4.4).

Step 2. {P}\{P\}: admissible: about 1.0, the total effect.

Step 3. {P,J}\{P, J\}: tenure is a descendant (mediator): the coefficient drops to about 0.6, the effect not running through tenure.

Answer: only {P}\{P\} answers "what does training do to earnings?". The "control for everything" regression answers a different question, and only if tenure is itself unconfounded (Day 58).

Exercise 15 · Hospital report cards

A regulator compares 30-day mortality across hospitals. Candidate adjustment variables: patient severity at admission, age, insurance type, length of stay, and severity at discharge. Draw the relevant DAG fragment and choose the adjustment set for "the effect of being treated at hospital HH".

Show solution

Step 1. Pre-treatment (non-descendants of hospital choice): admission severity, age, insurance. They affect which hospital patients use and their mortality: back-door paths through them must be blocked.

Step 2. Length of stay and discharge severity are affected by the hospital (descendants), often mediators of quality.

Step 3. Adjusting for discharge severity would credit a hospital for patients it made sicker; length of stay is also affected by deaths themselves.

Answer: adjust for admission severity, age and insurance; exclude length of stay and discharge severity. If unmeasured severity remains, hospital comparisons stay confounded, and a sensitivity analysis (Day 95) is needed.

Verify in Python

import itertools
import numpy as np
import networkx as nx

dsep = getattr(nx, "is_d_separator", None) or nx.d_separated   # name changed in networkx 3.3

def backdoor_ok(G, x, y, Z):
    """Back-door criterion: no descendant of x, and Z d-separates x and y once x's outgoing edges are removed."""
    if Z & nx.descendants(G, x):
        return False
    H = G.copy(); H.remove_edges_from(list(G.out_edges(x)))
    return dsep(H, {x}, {y}, set(Z))

G = nx.DiGraph([("Z1", "Z3"), ("Z2", "Z3"), ("Z1", "X"), ("Z2", "Y"), ("Z3", "X"), ("Z3", "Y"), ("X", "W"), ("W", "Y")])
cands = ["Z1", "Z2", "Z3", "W"]
valid = [set(c) for k in range(5) for c in itertools.combinations(cands, k) if backdoor_ok(G, "X", "Y", set(c))]
print("admissible sets:", [sorted(v) for v in valid])

# Exercise 12: sign reversal
pT = {1: .3, 0: .7}; pE = {(1, 0): .60, (1, 1): .70, (0, 0): .20, (0, 1): .35}     # key (z, t)
naive = {t: sum(.5 * (pT[z] if t else 1 - pT[z]) * pE[z, t] for z in (0, 1)) / .5 for t in (0, 1)}
adj = {t: sum(.5 * pE[z, t] for z in (0, 1)) for t in (0, 1)}
print("naive:", round(naive[1] - naive[0], 4), " adjusted:", round(adj[1] - adj[0], 4))

# Exercise 14: over-control
rng = np.random.default_rng(52); n = 200_000
P = rng.normal(size=n)
T = (P + rng.normal(size=n) > 0).astype(float)
J = 2 * T + rng.normal(size=n)
Y = 0.6 * T + 0.2 * J + 3 * P + rng.normal(size=n)          # total effect 0.6 + 0.2*2 = 1.0
for name, cols in [("none", []), ("P", [P]), ("P, J", [P, J])]:
    X = np.column_stack([np.ones(n), T] + cols)
    print(f"controls {name:5s}: coefficient on T = {np.linalg.lstsq(X, Y, rcond=None)[0][1]:.3f}")

Key takeaways

  • Back-door paths start with an arrow into the treatment; they carry confounding.
  • A set is admissible if it blocks them all and contains no descendant of the treatment; then P(y∣do⁡(x))=∑zP(y∣x,z)P(z)P(y \mid \operatorname{do}(x)) = \sum_{\mathbf z} P(y \mid x, \mathbf z)P(\mathbf z).
  • A variable can be both a confounder and a collider; the criterion, not intuition, decides what to add.

Simulation Lab: Back-Door Adjustment

Open full screen →

Choose an adjustment set by clicking; the exact regression coefficient shows which sets remove confounding.

Z1Z2Z3XWY
Adjustment set {Z3}: fails the back-door criterion.
coefficient on X
0.377
true causal effect
0.500
X → W → Y
X ← Z1 → Z3 ← Z2 → Y — open
X ← Z1 → Z3 → Y — blocked at Z3
X ← Z3 ← Z2 → Y — blocked at Z3
X ← Z3 → Y — blocked at Z3

A linear model with unit-variance disturbances. Click nodes to choose the adjustment set; the regression coefficient on X is computed exactly from the implied covariance matrix (no sampling noise). Z3 is both a confounder and a collider; W is a mediator. Open back-door paths are drawn in orange.

Day 51Day 53