Math for Causal Inference

Day 54. The Front-Door Criterion

When the confounder of treatment and outcome is unobserved, a fully mediating, unconfounded mechanism can still identify the effect. Estimate how the treatment moves the mediator, then how the mediator moves the outcome, and chain the two.

Video coming soon
Learning outcomes
  • ●State the three front-door conditions and check them in a DAG.
  • ●Derive and apply the front-door adjustment formula.
  • ●Compute front-door estimates with binary tables and as a product of regression coefficients.
  • ●Judge the plausibility of the front-door assumptions in applied settings.
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

When back-door fails

Suppose X←U→YX \leftarrow U \to Y with UU unobserved. No back-door set exists. But if XX affects YY only through a mediator MM that is not itself confounded with XX, we can still identify the effect:

U→X,U→Y,X→M→Y.U \to X, \quad U \to Y, \quad X \to M \to Y.

Classic example: smoking XX, tar deposits MM, lung cancer YY, unobserved genotype UU.

The criterion

A set M\mathbf M satisfies the front-door criterion relative to (X,Y)(X, Y) if

  1. M\mathbf M intercepts all directed paths from XX to YY;
  2. there is no unblocked back-door path from XX to M\mathbf M;
  3. all back-door paths from M\mathbf M to YY are blocked by XX.

The formula

If M\mathbf M satisfies the criterion and P(x,m)>0P(x, \mathbf m) > 0,

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

The logic in two steps

  1. Effect of XX on MM. By condition 2, P(m∣do⁡(x))=P(m∣x)P(m \mid \operatorname{do}(x)) = P(m \mid x).
  2. Effect of MM on YY. By condition 3, XX is a back-door set for M→YM \to Y: P(y∣do⁡(m))=∑x′P(y∣m,x′)P(x′)P(y \mid \operatorname{do}(m)) = \sum_{x'} P(y \mid m, x')P(x').
  3. Chain them. By condition 1, XX affects YY only via MM: P(y∣do⁡(x))=∑mP(m∣do⁡(x)) P(y∣do⁡(m))P(y \mid \operatorname{do}(x)) = \sum_m P(m \mid \operatorname{do}(x))\,P(y \mid \operatorname{do}(m)).

The linear case

With M=aX+eMM = aX + e_M and Y=bM+cU+eYY = bM + cU + e_Y, XX correlated with UU: estimate aa by regressing MM on XX, and bb by regressing YY on MM and XX. The effect is a^b^\hat a\hat b.

Plausibility

The conditions are strong: no direct effect of XX on YY outside MM, and no unobserved common cause of MM and YY. They hold most credibly when MM is a mechanical step: signing up versus attending, being offered versus receiving, prescribed versus dispensed.

Part 1 · Warm-up

Exercise 1 · Check the conditions

For each graph, does {M}\{M\} satisfy the front-door criterion for X→YX \to Y? (a) U→XU \to X, U→YU \to Y, X→M→YX \to M \to Y. (b) Add X→YX \to Y. (c) Instead add U→MU \to M. (d) Instead add V→MV \to M, V→YV \to Y with VV unobserved.

Show solution

Step 1. (a) MM intercepts X→M→YX \to M \to Y; back-door paths from XX to MM: X←U→Y←MX \leftarrow U \to Y \leftarrow M, blocked at the collider YY; back-door from MM to YY: M←X←U→YM \leftarrow X \leftarrow U \to Y, blocked by XX. Satisfied.

Step 2. (b) X→YX \to Y is a directed path not through MM: condition 1 fails.

Step 3. (c) X←U→MX \leftarrow U \to M is an open back-door path from XX to MM: condition 2 fails.

Step 4. (d) M←V→YM \leftarrow V \to Y is a back-door path from MM to YY not blocked by XX: condition 3 fails.

Exercise 2 · Linear front door

Regressing MM on XX gives 0.5; regressing YY on MM and XX gives 2.0 on MM. The front-door conditions hold. What is the effect of a one-unit increase in XX?

Show solution

Step 1. Effect of XX on MM: 0.5. Effect of MM on YY: 2.0.

Answer: 0.5×2.0=1.00.5 \times 2.0 = 1.0.

Exercise 3 · The first step

Why is P(m∣do⁡(x))=P(m∣x)P(m \mid \operatorname{do}(x)) = P(m \mid x) in graph (a) of Exercise 1?

Show solution

Step 1. The only back-door path from XX to MM is X←U→Y←MX \leftarrow U \to Y \leftarrow M.

Step 2. It has a collider at YY, so it is blocked by the empty set.

Answer: ∅\varnothing satisfies the back-door criterion for X→MX \to M, so conditioning equals intervening.

Exercise 4 · A small front-door computation

P(X=1)=0.4P(X = 1) = 0.4. P(M=1∣X=1)=0.8P(M = 1 \mid X = 1) = 0.8, P(M=1∣X=0)=0.3P(M = 1 \mid X = 0) = 0.3. P(Y=1∣M,X)P(Y = 1 \mid M, X): (M,X)=(1,1)(M, X) = (1, 1): 0.6; (0,1)(0, 1): 0.4; (1,0)(1, 0): 0.5; (0,0)(0, 0): 0.3. Compute P(Y=1∣do⁡(X=1))P(Y = 1 \mid \operatorname{do}(X = 1)) by the front-door formula.

Show solution

Step 1. Inner sums: m=1m = 1: 0.4(0.6)+0.6(0.5)=0.24+0.30=0.540.4(0.6) + 0.6(0.5) = 0.24 + 0.30 = 0.54; m=0m = 0: 0.4(0.4)+0.6(0.3)=0.16+0.18=0.340.4(0.4) + 0.6(0.3) = 0.16 + 0.18 = 0.34.

Step 2. Outer sum with P(m∣X=1)P(m \mid X = 1): 0.8(0.54)+0.2(0.34)=0.432+0.068=0.500.8(0.54) + 0.2(0.34) = 0.432 + 0.068 = 0.50.

Answer: 0.50.

Exercise 5 · Why average over x′x'?

In the second step, why do we average P(y∣m,x′)P(y \mid m, x') over P(x′)P(x') instead of using P(y∣m,x)P(y \mid m, x) at the treatment value xx?

Show solution

Step 1. We need the effect of MM on YY in the whole population, P(y∣do⁡(m))P(y \mid \operatorname{do}(m)).

Step 2. XX is used only as a back-door adjustment variable for M→YM \to Y (it blocks M←X←U→YM \leftarrow X \leftarrow U \to Y), so it must be averaged over its marginal distribution, as in any back-door formula.

Answer: using P(y∣m,x)P(y \mid m, x) alone would describe the UU-mix of people with X=xX = x, which is confounded.

Part 2 · Proofs

Exercise 6 · Step 1 in general

Prove P(m∣do⁡(x))=P(m∣x)P(m \mid \operatorname{do}(x)) = P(m \mid x) under condition 2.

Show solution

Step 1. Condition 2 says ∅\varnothing blocks every back-door path from XX to MM, and ∅\varnothing contains no descendants of XX.

Step 2. So ∅\varnothing satisfies the back-door criterion for (X,M)(X, M), and the adjustment formula reduces to P(m∣do⁡(x))=P(m∣x)P(m \mid \operatorname{do}(x)) = P(m \mid x). ■\blacksquare

Exercise 7 · Step 2 in general

Prove P(y∣do⁡(m))=∑xP(y∣m,x)P(x)P(y \mid \operatorname{do}(m)) = \sum_{x} P(y \mid m, x)P(x) under the front-door conditions.

Show solution

Step 1. Condition 3: {X}\{X\} blocks all back-door paths from MM to YY.

Step 2. XX is not a descendant of MM: MM lies on the directed paths from XX, and acyclicity forbids M→⋯→XM \to \cdots \to X.

Step 3. So {X}\{X\} satisfies the back-door criterion for (M,Y)(M, Y) and the adjustment formula gives the result. ■\blacksquare

Exercise 8 · Chaining the steps

Using the SCM U→XU \to X, U→YU \to Y, X→M→YX \to M \to Y, prove P(y∣do⁡(x))=∑mP(m∣do⁡(x))P(y∣do⁡(m))P(y \mid \operatorname{do}(x)) = \sum_m P(m \mid \operatorname{do}(x))P(y \mid \operatorname{do}(m)).

Show solution

Step 1. Truncated factorisation for do⁡(x)\operatorname{do}(x): P(u,m,y∣do⁡(x))=P(u)P(m∣x)P(y∣m,u)P(u, m, y \mid \operatorname{do}(x)) = P(u)P(m \mid x)P(y \mid m, u).

Step 2. Sum over uu and mm: P(y∣do⁡(x))=∑mP(m∣x)∑uP(y∣m,u)P(u)P(y \mid \operatorname{do}(x)) = \sum_m P(m \mid x)\sum_u P(y \mid m, u)P(u).

Step 3. Truncated factorisation for do⁡(m)\operatorname{do}(m): P(u,x,y∣do⁡(m))=P(u)P(x∣u)P(y∣m,u)P(u, x, y \mid \operatorname{do}(m)) = P(u)P(x \mid u)P(y \mid m, u); summing over u,xu, x gives P(y∣do⁡(m))=∑uP(y∣m,u)P(u)P(y \mid \operatorname{do}(m)) = \sum_u P(y \mid m, u)P(u).

Step 4. By Exercise 6, P(m∣x)=P(m∣do⁡(x))P(m \mid x) = P(m \mid \operatorname{do}(x)). Substitute both into Step 2. ■\blacksquare Combined with Exercise 7, this proves the front-door formula.

Exercise 9 · The linear product

With X=gU+eXX = gU + e_X, M=aX+eMM = aX + e_M, Y=bM+cU+eYY = bM + cU + e_Y (all disturbances independent), prove the population coefficient on MM in the regression of YY on (M,X)(M, X) is bb, so a^b^→ab\hat a\hat b \to ab.

Show solution

Step 1. E[Y∣M,X]=bM+cE[U∣M,X]E[Y \mid M, X] = bM + cE[U \mid M, X].

Step 2. M=aX+eMM = aX + e_M with eMe_M independent of (U,X)(U, X); so given XX, MM carries no information about UU: E[U∣M,X]=E[U∣X]E[U \mid M, X] = E[U \mid X], a linear function of XX only.

Step 3. So E[Y∣M,X]=bM+(function of X)E[Y \mid M, X] = bM + (\text{function of } X): the coefficient on MM is bb.

Step 4. The regression of MM on XX recovers aa because eMe_M is independent of XX. ■\blacksquare

Exercise 10 · A direct effect breaks it

Add a direct effect, Y=bM+dX+cU+eYY = bM + dX + cU + e_Y. What does a^b^\hat a\hat b converge to, and what is the true total effect?

Show solution

Step 1. The argument of Exercise 9 still gives coefficient bb on MM (the dXdX term is a function of XX).

Step 2. So a^b^→ab\hat a\hat b \to ab.

Step 3. True total effect: ab+dab + d.

Answer: the front-door estimate misses the direct effect entirely; condition 1 is essential. ■\blacksquare

Part 3 · Applied

Exercise 11 · Smoking, tar and cancer

Observational data: P(X=1)=0.5P(X = 1) = 0.5 smokers; P(M=1∣X=1)=0.9P(M = 1 \mid X = 1) = 0.9 and P(M=1∣X=0)=0.1P(M = 1 \mid X = 0) = 0.1 heavy tar deposits; cancer rates P(Y=1∣M,X)P(Y = 1 \mid M, X): (1,1)(1, 1): 0.44; (0,1)(0, 1): 0.34; (1,0)(1, 0): 0.26; (0,0)(0, 0): 0.16. Compute the naive risk difference and the front-door effect.

Show solution

Step 1. Naive: P(Y=1∣X=1)=0.9(0.44)+0.1(0.34)=0.43P(Y = 1 \mid X = 1) = 0.9(0.44) + 0.1(0.34) = 0.43 and P(Y=1∣X=0)=0.1(0.26)+0.9(0.16)=0.17P(Y = 1 \mid X = 0) = 0.1(0.26) + 0.9(0.16) = 0.17; difference 0.26.

Step 2. Effect of tar, averaging over smoking: P(Y∣do⁡(M=1))=0.5(0.44)+0.5(0.26)=0.35P(Y \mid \operatorname{do}(M = 1)) = 0.5(0.44) + 0.5(0.26) = 0.35; P(Y∣do⁡(M=0))=0.5(0.34)+0.5(0.16)=0.25P(Y \mid \operatorname{do}(M = 0)) = 0.5(0.34) + 0.5(0.16) = 0.25.

Step 3. P(Y∣do⁡(X=1))=0.9(0.35)+0.1(0.25)=0.34P(Y \mid \operatorname{do}(X = 1)) = 0.9(0.35) + 0.1(0.25) = 0.34.

Step 4. P(Y∣do⁡(X=0))=0.1(0.35)+0.9(0.25)=0.26P(Y \mid \operatorname{do}(X = 0)) = 0.1(0.35) + 0.9(0.25) = 0.26.

Answer: causal risk difference 0.08, versus a naive 0.26. (These numbers come from an SCM with a genotype that raises both smoking and cancer; the code checks that 0.08 is the true effect.)

Exercise 12 · Signing up versus showing up

A job-training programme records who signed up (XX), who attended (MM) and later earnings (YY). Motivation is unobserved. Discuss each front-door condition for the effect of signing up.

Show solution

Step 1. Condition 1: signing up should affect earnings only through attending. Plausible, unless signing up itself changes behaviour (e.g. it triggers other services or job-search requirements).

Step 2. Condition 2: no unblocked confounding between signing up and attending. Questionable: motivated people both sign up and attend.

Step 3. Condition 3: given sign-up status, attendance is unconfounded with earnings. Questionable for the same reason.

Answer: among sign-ups, attendance is nearly mechanical (most attend), which makes conditions 2–3 more credible; studies of this design find estimates close to experimental benchmarks for some groups and not others. Plausibility must be argued, not assumed.

Exercise 13 · Mobile money and savings

A mobile-money app (XX, adopted or not) can raise household savings YY only through account usage MM (deposits per month). Adoption and savings share unobserved financial literacy. Regressions: usage on adoption gives 0.6 deposits; savings on usage and adoption gives $50 per deposit on usage. Estimate the effect of adoption on savings.

Show solution

Step 1. Effect of adoption on usage: a^=0.6\hat a = 0.6.

Step 2. Effect of usage on savings, adjusting for adoption: b^=50\hat b = 50.

Answer: 0.6×50=300.6 \times 50 = 30 dollars per household. The naive regression of savings on adoption would also pick up literacy.

Exercise 14 · What if the app has a direct effect?

Suppose the app also raises savings by $10 directly (through reminders that work even without deposits). What does the front-door estimate from Exercise 13 converge to, and what is the true effect?

Show solution

Step 1. By Exercise 10, a^b^→ab=30\hat a\hat b \to ab = 30.

Step 2. True total effect: 30+10=4030 + 10 = 40.

Answer: the front-door estimate understates the effect by $10 (25%). In the simulation below, the front-door estimate is about 30 and the truth 40.

Exercise 15 · Nurse staffing and mortality

A hospital network asks whether higher nurse staffing (XX) lowers in-hospital mortality (YY). Wards with sicker patients get more nurses, and severity is poorly measured. The analyst proposes using monitoring frequency (MM, vital-sign checks per day) as a front-door variable. List what must be true and one likely failure for each condition.

Show solution

Step 1. Condition 1: staffing affects mortality only through monitoring. Likely failure: nurses also deliver medication on time and prevent falls; those channels bypass MM.

Step 2. Condition 2: nothing unmeasured affects both staffing and monitoring. Likely failure: severity raises staffing and monitoring protocols directly.

Step 3. Condition 3: given staffing, monitoring is unconfounded with mortality. Likely failure: sicker patients are monitored more and die more.

Answer: monitoring fails all three; the front door is not credible here. A better design might use staffing shocks (nurse absences, Phase 5 instruments).

Verify in Python

import itertools
import numpy as np

# Exercise 11: the SCM behind the table (U = genotype, unobserved)
pU = .5; pX = {1: .8, 0: .2}; pM = {1: .9, 0: .1}; pY = {(0, 0): .1, (1, 0): .2, (0, 1): .4, (1, 1): .5}   # key (m, u)
truth = {x: sum((pM[x] if m else 1 - pM[x]) * sum((pU if u else 1 - pU) * pY[m, u] for u in (0, 1)) for m in (0, 1)) for x in (0, 1)}
J = {(u, x, m): (pU if u else 1 - pU) * (pX[u] if x else 1 - pX[u]) * (pM[x] if m else 1 - pM[x])
     for u, x, m in itertools.product((0, 1), repeat=3)}
Px = {x: sum(v for k, v in J.items() if k[1] == x) for x in (0, 1)}
Pm_x = {(m, x): sum(v for k, v in J.items() if k[1] == x and k[2] == m) / Px[x] for m in (0, 1) for x in (0, 1)}
Py_mx = {(m, x): sum(v * pY[m, k[0]] for k, v in J.items() if k[1] == x and k[2] == m) / (Px[x] * Pm_x[m, x]) for m in (0, 1) for x in (0, 1)}
print("observed P(Y=1|M,X):", {k: round(v, 3) for k, v in Py_mx.items()})
naive = {x: sum(Pm_x[m, x] * Py_mx[m, x] for m in (0, 1)) for x in (0, 1)}
front = {x: sum(Pm_x[m, x] * sum(Py_mx[m, xp] * Px[xp] for xp in (0, 1)) for m in (0, 1)) for x in (0, 1)}
print(f"naive {naive[1] - naive[0]:.3f}  front-door {front[1] - front[0]:.3f}  truth {truth[1] - truth[0]:.3f}")

# Exercises 13-14: linear front door with and without a direct effect
rng = np.random.default_rng(54); n = 500_000
L = rng.normal(size=n)                                 # financial literacy (unobserved)
X = (L + rng.normal(size=n) > 0).astype(float)
M = 0.6 * X + rng.normal(size=n)
for d in (0, 10):
    Y = 50 * M + d * X + 40 * L + rng.normal(0, 20, n)
    a = np.polyfit(X, M, 1)[0]
    b = np.linalg.lstsq(np.column_stack([np.ones(n), M, X]), Y, rcond=None)[0][1]
    naive = Y[X == 1].mean() - Y[X == 0].mean()
    print(f"direct effect {d}: naive {naive:.1f}, front-door {a * b:.1f}, truth {30 + d}")

Key takeaways

  • The front door identifies an effect despite unobserved treatment–outcome confounding, if a mediator captures the whole effect, is unconfounded with the treatment, and is unconfounded with the outcome given the treatment.
  • Formula: P(y∣do⁡(x))=∑mP(m∣x)∑x′P(y∣m,x′)P(x′)P(y \mid \operatorname{do}(x)) = \sum_m P(m \mid x)\sum_{x'} P(y \mid m, x')P(x'); in linear models, the product of two regression coefficients.
  • Its assumptions are strong; they are most credible when the mediator is a mechanical step of the treatment.

Simulation Lab: The Front Door

Open full screen →

Smoking, tar and cancer with a hidden genotype: the front-door formula recovers the effect until its assumptions are broken.

GenotypeSmokingTarCancernaive P(Y|X=1) − P(Y|X=0)0.260front-door formula0.080true effect 0.080
naive bias
0.180
front-door bias
0.000

Smoking (X), tar (M), cancer (Y) and an unobserved genotype (U). All probabilities are exact. The front-door formula uses only X, M and Y; it matches the truth as long as there is no direct X → Y arrow and U does not affect M. Turn those on to watch it fail.

Day 53Day 55