Math for Causal Inference

Day 53. Adjustment Sets & Bad Controls

Not every covariate belongs in the regression. Confounders must be in; outcome predictors help precision; instruments hurt precision and amplify bias; mediators, colliders, M-structures and descendants of the outcome bias the estimate. Among valid sets, some are more precise than others.

Video coming soon
Learning outcomes
  • ●Classify a candidate control as good, neutral (precision-helping or precision-hurting) or bad, from the DAG.
  • ●Quantify the precision effects of outcome predictors and instruments in a linear model.
  • ●Derive the biases from controlling for a confounded mediator, an M-structure collider and an instrument with unobserved confounding.
  • ●Choose a precise admissible set and avoid the "Table 2 fallacy".
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

A catalogue of controls

Let XX be the treatment and YY the outcome. For a candidate control ZZ (and possibly unobserved UU):

StructureVerdictWhy
X←Z→YX \leftarrow Z \to Ygoodblocks a back-door path
X←Z←U→YX \leftarrow Z \leftarrow U \to Ygoodblocks the path through UU (a proxy)
Z→YZ \to Y onlyneutral, helps precisionexplains outcome variance
Z→XZ \to X onlyneutral, hurts precisionremoves treatment variation
Z→XZ \to X, X←U→YX \leftarrow U \to Ybad: bias amplificationremoves clean variation, keeps confounded variation
X→Z→YX \to Z \to Ybad (for the total effect)blocks part of the effect
X→Z←YX \to Z \leftarrow Y, or X→Z←U→YX \to Z \leftarrow U \to Ybadconditioning on a collider
X←U1→Z←U2→YX \leftarrow U_1 \to Z \leftarrow U_2 \to Ybad: M-biaspre-treatment collider
Y→ZY \to Zbadselection on the outcome

"Pre-treatment" is not the same as "safe": the M-structure collider can be measured before treatment.

Precision in a linear model

In Y=τX+γ⊤Z+εY = \tau X + \boldsymbol\gamma^\top\mathbf Z + \varepsilon estimated by OLS, Frisch–Waugh–Lovell gives

Var⁡(τ^)≈σY∣X,Z2n Var⁡(X∣Z).\operatorname{Var}(\hat\tau) \approx \frac{\sigma^2_{Y \mid X, \mathbf Z}}{n\,\operatorname{Var}(X \mid \mathbf Z)}.
  • An outcome predictor shrinks the numerator: more precision.
  • A treatment predictor shrinks the denominator: less precision (the variance inflation factor 1/(1−RX∣Z2)1/(1 - R^2_{X \mid \mathbf Z})).

Choosing among admissible sets

Several sets may satisfy the back-door criterion. In linear models the asymptotically most precise one is the optimal adjustment set: roughly, the parents of YY (and of mediators on the causal path) that are not themselves descendants of XX, excluding XX. Practical rule: prefer confounders close to the outcome over confounders close to the treatment.

The Table 2 fallacy

A regression designed to estimate the effect of XX has coefficients on the controls too. They are generally not causal effects of the controls: XX may be a mediator or collider for them. Report only the coefficient the design was built for.

Part 1 · Warm-up

Exercise 1 · Classify the controls

For the effect of XX on YY, classify ZZ: (a) Z→XZ \to X, Z→YZ \to Y; (b) X→ZX \to Z, Y→ZY \to Z; (c) Z→YZ \to Y only; (d) Z→XZ \to X only, no confounding; (e) X→Z→YX \to Z \to Y.

Show solution

Step 1. (a) Confounder: good.

Step 2. (b) Collider: bad.

Step 3. (c) Outcome predictor: neutral, improves precision.

Step 4. (d) Instrument-like: neutral for bias, reduces precision.

Step 5. (e) Mediator: bad for the total effect.

Exercise 2 · Precision from an outcome predictor

Y=τX+2Z+εY = \tau X + 2Z + \varepsilon, with Z⊥ ⁣ ⁣ ⁣⊥XZ \perp\!\!\!\perp X, Var⁡(Z)=1\operatorname{Var}(Z) = 1, Var⁡(ε)=1\operatorname{Var}(\varepsilon) = 1. By what factor does including ZZ reduce the standard error of τ^\hat\tau?

Show solution

Step 1. Without ZZ: residual variance 4Var⁡(Z)+1=54\operatorname{Var}(Z) + 1 = 5.

Step 2. With ZZ: residual variance 1.

Step 3. Var⁡(X∣Z)=Var⁡(X)\operatorname{Var}(X \mid Z) = \operatorname{Var}(X) since they are independent, so the denominator is unchanged.

Answer: variance falls by a factor of 5; the SE by 5≈2.24\sqrt5 \approx 2.24.

Exercise 3 · Precision lost to an instrument

X=Z+uX = Z + u with Var⁡(Z)=Var⁡(u)=1\operatorname{Var}(Z) = \operatorname{Var}(u) = 1, and ZZ affects YY only through XX (no confounding). By what factor does controlling for ZZ raise Var⁡(τ^)\operatorname{Var}(\hat\tau)?

Show solution

Step 1. Var⁡(X)=2\operatorname{Var}(X) = 2 and Var⁡(X∣Z)=Var⁡(u)=1\operatorname{Var}(X \mid Z) = \operatorname{Var}(u) = 1.

Step 2. The residual variance of YY is unchanged (Z has no direct effect on YY).

Answer: the variance doubles (RX∣Z2=0.5R^2_{X \mid Z} = 0.5); the SE rises by 2\sqrt2.

Exercise 4 · M-bias

In U1→XU_1 \to X, U1→MU_1 \to M, U2→MU_2 \to M, U2→YU_2 \to Y, X→YX \to Y, with U1,U2U_1, U_2 unobserved, is ∅\varnothing admissible? Is {M}\{M\}?

Show solution

Step 1. The only back-door path is X←U1→M←U2→YX \leftarrow U_1 \to M \leftarrow U_2 \to Y, with a collider at MM.

Step 2. Given ∅\varnothing it is blocked: ∅\varnothing is admissible.

Step 3. Given MM it opens: {M}\{M\} is not admissible, although MM is pre-treatment and correlated with both XX and YY.

Exercise 5 · Controlling for a consequence of the outcome

Why is it a mistake to control for DD when Y→DY \to D (for example, DD = hospital discharge diagnosis, YY = disease severity)?

Show solution

Step 1. X→Y→DX \to Y \to D: DD is a descendant of XX, violating the back-door condition.

Step 2. Conditioning on DD partially conditions on YY itself: among units with the same DD, variation in YY is restricted, which attenuates (or distorts) the estimated effect.

Answer: a descendant of the outcome is a bad control.

Part 2 · Proofs

Exercise 6 · The variance formula

In Y=τX+γ⊤Z+εY = \tau X + \boldsymbol\gamma^\top\mathbf Z + \varepsilon with homoskedastic ε\varepsilon, show Var⁡(τ^∣X,Z)=σ2/∑iX~i2\operatorname{Var}(\hat\tau \mid X, \mathbf Z) = \sigma^2/\sum_i \tilde X_i^2, where X~\tilde X is XX residualised on Z\mathbf Z, and conclude the approximation in the theory.

Show solution

Step 1. FWL: τ^=∑iX~iYi/∑iX~i2\hat\tau = \sum_i \tilde X_i Y_i/\sum_i \tilde X_i^2.

Step 2. Substitute Yi=τXi+γ⊤Zi+εiY_i = \tau X_i + \boldsymbol\gamma^\top\mathbf Z_i + \varepsilon_i; since X~\tilde X is orthogonal to Z\mathbf Z and ∑X~iXi=∑X~i2\sum \tilde X_i X_i = \sum \tilde X_i^2, τ^=τ+∑X~iεi/∑X~i2\hat\tau = \tau + \sum \tilde X_i\varepsilon_i/\sum \tilde X_i^2.

Step 3. Var⁡(τ^∣X,Z)=σ2∑X~i2/(∑X~i2)2=σ2/∑X~i2\operatorname{Var}(\hat\tau \mid X, \mathbf Z) = \sigma^2\sum \tilde X_i^2/(\sum \tilde X_i^2)^2 = \sigma^2/\sum \tilde X_i^2.

Step 4. ∑X~i2≈nVar⁡(X∣Z)\sum \tilde X_i^2 \approx n\operatorname{Var}(X \mid \mathbf Z) for large nn. ■\blacksquare

Exercise 7 · Bias amplification

Let X=aZ+bU+eXX = aZ + bU + e_X and Y=τX+cU+eYY = \tau X + cU + e_Y, with Z,U,eX,eYZ, U, e_X, e_Y independent, Var⁡(Z)=Var⁡(U)=1\operatorname{Var}(Z) = \operatorname{Var}(U) = 1, Var⁡(eX)=s2\operatorname{Var}(e_X) = s^2, and UU unobserved. Show the bias of τ^\hat\tau is cb/(a2+b2+s2)cb/(a^2 + b^2 + s^2) without ZZ and cb/(b2+s2)cb/(b^2 + s^2) with ZZ.

Show solution

Step 1. Without ZZ: the slope is τ+cCov⁡(X,U)/Var⁡(X)=τ+cb/(a2+b2+s2)\tau + c\operatorname{Cov}(X, U)/\operatorname{Var}(X) = \tau + cb/(a^2 + b^2 + s^2) (Day 50, Exercise 8).

Step 2. With ZZ: by FWL, use X~=X−aZ=bU+eX\tilde X = X - aZ = bU + e_X.

Step 3. Slope =Cov⁡(X~,Y)/Var⁡(X~)= \operatorname{Cov}(\tilde X, Y)/\operatorname{Var}(\tilde X), and Cov⁡(X~,Y)=τVar⁡(X~)+cb\operatorname{Cov}(\tilde X, Y) = \tau\operatorname{Var}(\tilde X) + cb.

Step 4. So the bias is cb/(b2+s2)cb/(b^2 + s^2), which is larger: controlling for ZZ removed clean variation (a2a^2) from the denominator. ■\blacksquare

Exercise 8 · Outcome predictors do not change the estimand

Assume Z\mathbf Z is admissible and WW is independent of (X,Z)(X, \mathbf Z) and affects only YY. Prove that Z∪{W}\mathbf Z \cup \{W\} is admissible.

Show solution

Step 1. Condition 1: WW has no parents among the descendants of XX (it is independent of XX with arrows only into YY), so it is not a descendant of XX.

Step 2. Condition 2: every path through WW is ⋯Y←W\cdots Y \leftarrow W with WW as an endpoint-adjacent node; WW has no other neighbours, so no back-door path from XX passes through WW.

Step 3. Conditioning on WW cannot open a path: WW is not a collider or a descendant of one on any XX–YY path.

Step 4. Paths blocked by Z\mathbf Z remain blocked. ■\blacksquare

Exercise 9 · Controlling for a confounded mediator

Let M=aX+U+eMM = aX + U + e_M and Y=dX+bM+cU+eYY = dX + bM + cU + e_Y, with X,U,eM,eYX, U, e_M, e_Y independent, Var⁡(U)=vU\operatorname{Var}(U) = v_U, Var⁡(eM)=vM\operatorname{Var}(e_M) = v_M. Show that the coefficient on XX in the regression of YY on (X,M)(X, M) is d−cakd - cak, with k=vU/(vU+vM)k = v_U/(v_U + v_M).

Show solution

Step 1. Given XX and MM, we know U+eM=M−aXU + e_M = M - aX. By normal (or linear) projection, E[U∣X,M]=k(M−aX)E[U \mid X, M] = k(M - aX).

Step 2. E[Y∣X,M]=dX+bM+cE[U∣X,M]=dX+bM+ck(M−aX)E[Y \mid X, M] = dX + bM + cE[U \mid X, M] = dX + bM + ck(M - aX).

Step 3. Collect terms: (d−cak)X+(b+ck)M(d - cak)X + (b + ck)M.

Answer: the coefficient is the direct effect dd only if c=0c = 0 (no mediator–outcome confounding). Otherwise MM is a collider on X→M←U→YX \to M \leftarrow U \to Y. ■\blacksquare

Exercise 10 · The size of M-bias

In Exercise 4 with linear equations X=αU1+eXX = \alpha U_1 + e_X, M=U1+U2+eMM = U_1 + U_2 + e_M, Y=τX+βU2+eYY = \tau X + \beta U_2 + e_Y (all disturbances independent with variance 1), show that controlling for MM adds bias −αβ/(2α2+3)-\alpha\beta/(2\alpha^2 + 3).

Show solution

Step 1. E[Y∣X,M]=τX+βE[U2∣X,M]E[Y \mid X, M] = \tau X + \beta E[U_2 \mid X, M].

Step 2. Var⁡(X)=α2+1\operatorname{Var}(X) = \alpha^2 + 1, Var⁡(M)=3\operatorname{Var}(M) = 3, Cov⁡(X,M)=α\operatorname{Cov}(X, M) = \alpha; Cov⁡(U2,X)=0\operatorname{Cov}(U_2, X) = 0, Cov⁡(U2,M)=1\operatorname{Cov}(U_2, M) = 1.

Step 3. Projection coefficients: (0,1)(α2+1αα3)−1=(−α,  α2+1)3(α2+1)−α2(0, 1)\begin{pmatrix} \alpha^2 + 1 & \alpha \\ \alpha & 3 \end{pmatrix}^{-1} = \dfrac{(-\alpha,\; \alpha^2 + 1)}{3(\alpha^2 + 1) - \alpha^2}.

Step 4. The coefficient on XX in E[U2∣X,M]E[U_2 \mid X, M] is −α/(2α2+3)-\alpha/(2\alpha^2 + 3).

Answer: bias −αβ/(2α2+3)-\alpha\beta/(2\alpha^2 + 3); with α=β=1\alpha = \beta = 1 it is −0.2. Usually modest, but real. ■\blacksquare

Part 3 · Applied

Exercise 11 · Medicaid expansion and mortality

You study the effect of a state's Medicaid expansion XX on county mortality YY. Classify each candidate control: (a) pre-expansion county poverty rate; (b) post-expansion insurance coverage; (c) post-expansion number of hospital closures, affected by both expansion and by local death rates through hospital finances; (d) county rainfall; (e) pre-expansion mortality trend.

Show solution

Step 1. (a) Affects expansion decisions and mortality: confounder, include.

Step 2. (b) Mediator: expansion works through coverage. Exclude for the total effect.

Step 3. (c) Descendant of XX and of YY: collider-like and a descendant of the outcome. Exclude.

Step 4. (d) Unrelated to expansion; weakly predicts mortality at most. Harmless; include only if it explains outcome variance.

Step 5. (e) Strong predictor of mortality and plausibly of expansion: include (good for bias and precision).

Exercise 12 · A cash-transfer RCT

In a randomised cash-transfer trial with 2,000 households, baseline consumption explains 60% of the variance of endline consumption. A field officer also proposes controlling for the household's distance to the payment point, which affected take-up but not consumption. What happens to the standard error of the effect of being offered the transfer with each control?

Show solution

Step 1. Offer is randomised, so both controls leave the estimand unchanged.

Step 2. Baseline consumption: residual variance falls to 40%; SE falls by 0.4≈0.63\sqrt{0.4} \approx 0.63, i.e. 37% smaller.

Step 3. Distance: it predicts take-up, not the random offer itself, and not consumption; it neither helps nor hurts the offer coefficient (beyond a tiny degrees-of-freedom cost).

Answer: control for baseline consumption; distance is irrelevant for the intention-to-treat effect. (If the treatment were take-up rather than the offer, distance would be an instrument and should not be a control.)

Exercise 13 · Bias amplification in returns to schooling

Schooling S=0.8D+1.0A+eSS = 0.8D + 1.0A + e_S, where DD is distance to the nearest college (standardised, negative effect coded positive), AA unobserved ability (variance 1), Var⁡(eS)=1\operatorname{Var}(e_S) = 1; log wage Y=0.08S+0.10A+eYY = 0.08S + 0.10A + e_Y. Compute the ability bias with and without controlling for DD.

Show solution

Step 1. Use Exercise 7 with a=0.8a = 0.8, b=1b = 1, s2=1s^2 = 1, c=0.10c = 0.10.

Step 2. Without DD: 0.10×1/(0.64+1+1)=0.10/2.64≈0.0380.10 \times 1/(0.64 + 1 + 1) = 0.10/2.64 \approx 0.038.

Step 3. With DD: 0.10/(1+1)=0.0500.10/(1 + 1) = 0.050.

Answer: controlling for distance raises the bias from 3.8 to 5.0 points (estimated return 11.8% to 13.0% instead of 8%). Distance belongs in an IV analysis (Phase 5), not in the control list.

Exercise 14 · Choosing the most precise admissible set

In a smoking-cessation study, AA (age) →X\to X (counselling), A→BA \to B (baseline lung function), B→YB \to Y (lung function at one year), X→YX \to Y. Both {A}\{A\} and {B}\{B\} are admissible. In the simulation below, which gives the smaller standard error, and why?

Show solution

Step 1. Back-door path: X←A→B→YX \leftarrow A \to B \to Y, blocked by AA (fork) or by BB (chain).

Step 2. BB is a parent of YY: controlling for it removes the large outcome variance it explains, shrinking the numerator of the variance formula.

Step 3. BB is only a noisy proxy for AA, so Var⁡(X∣B)>Var⁡(X∣A)\operatorname{Var}(X \mid B) > \operatorname{Var}(X \mid A): more treatment variation is kept, enlarging the denominator.

Step 4. AA does the opposite on both counts: it predicts XX strongly and YY only through BB.

Answer: {B}\{B\} is more precise; the simulation shows an SE ratio of about 0.38. Prefer confounders near the outcome.

Exercise 15 · The Table 2 fallacy

A paper estimates the effect of air pollution PP on asthma admissions YY, adjusting for temperature TT and income II (both confounders; temperature also affects pollution). Its table reports coefficients for PP, TT and II. A journalist writes "temperature has no effect on asthma once pollution is accounted for". What is wrong?

Show solution

Step 1. The regression was designed so that {T,I}\{T, I\} is an admissible set for PP.

Step 2. For temperature, pollution is a mediator (T→P→YT \to P \to Y). Conditioning on PP blocks that channel, so the TT coefficient is at most a direct effect, and possibly confounded by variables not needed for PP.

Answer: the TT coefficient is not the total effect of temperature; only the coefficient on PP has the causal interpretation the design supports.

Verify in Python

import numpy as np

rng = np.random.default_rng(53)
def coef_se(y, X):
    X = np.column_stack([np.ones(len(y))] + X)
    b, *_ = np.linalg.lstsq(X, y, rcond=None); r = y - X @ b
    V = r @ r / (len(y) - X.shape[1]) * np.linalg.inv(X.T @ X)
    return b[1], np.sqrt(V[1, 1])

n = 200_000
# Exercise 7 / 13: bias amplification
D = rng.normal(size=n); A = rng.normal(size=n)
S = .8 * D + A + rng.normal(size=n); Y = .08 * S + .10 * A + rng.normal(size=n)
print("schooling: no control %.4f, control for distance %.4f (truth 0.08)" % (coef_se(Y, [S])[0], coef_se(Y, [S, D])[0]))

# Exercise 9: confounded mediator (a=1, b=1, c=1, d=0.5, vU=vM=1 -> coef 0.5 - 0.5 = 0)
X = rng.normal(size=n); U = rng.normal(size=n)
M = X + U + rng.normal(size=n); Y = .5 * X + M + U + rng.normal(size=n)
print("coef on X given M: %.3f (direct effect 0.5, formula 0.0)" % coef_se(Y, [X, M])[0])

# Exercise 10: M-bias with alpha = beta = 1 (tau = 1)
U1, U2 = rng.normal(size=n), rng.normal(size=n)
X = U1 + rng.normal(size=n); M = U1 + U2 + rng.normal(size=n); Y = X + U2 + rng.normal(size=n)
print("M-bias: without M %.3f, with M %.3f (bias -0.2)" % (coef_se(Y, [X])[0], coef_se(Y, [X, M])[0]))

# Exercise 14: precision of two admissible sets, 400 patients, 2000 replications
est = {"A": [], "B": []}
for _ in range(2000):
    m = 400
    A = rng.normal(size=m); X = (1.5 * A + rng.normal(size=m) > 0).astype(float)
    B = A + rng.normal(size=m); Y = 1.0 * X + 2 * B + rng.normal(size=m)
    est["A"].append(coef_se(Y, [X, A])[0]); est["B"].append(coef_se(Y, [X, B])[0])
sa, sb = np.std(est["A"]), np.std(est["B"])
print(f"mean A {np.mean(est['A']):.3f}, B {np.mean(est['B']):.3f}; SD A {sa:.3f}, B {sb:.3f}, ratio {sb / sa:.2f}")

Key takeaways

  • Include confounders (or their proxies); add strong outcome predictors for precision.
  • Leave out instruments, mediators, colliders (including pre-treatment M-colliders) and descendants of the outcome.
  • Among admissible sets, those closer to the outcome are more precise; coefficients on controls are not causal by default.

Simulation Lab: Good & Bad Controls

Open full screen →

Eight structures from confounder to M-bias: bias and standard error of the treatment coefficient with and without the control.

ZUXY

Bad: amplifies the bias from U.

without Z1.208controlling for Z1.390true effect 1.000
bias without / with Z
0.208 / 0.390
SE without / with Z
0.031 / 0.041

Exact population regressions from linear models (unit-variance disturbances), with 95% intervals for a sample of n. U nodes (dashed) are unobserved. Compare the coefficient on X without and with Z against the true total effect.

Day 52Day 54