Day 50. Structural Causal Models
A structural causal model writes each variable as a function of its direct causes and an exogenous disturbance. It generates the DAG, the joint distribution and, unlike a regression, answers questions about interventions.
- ●Define a structural causal model and draw the DAG it induces, including bidirected edges for dependent disturbances.
- ●Compute means, variances and covariances implied by a linear SCM, using Σ = (I − B)⁻¹ Ω (I − B)⁻ᵀ.
- ●Distinguish structural coefficients from regression coefficients and compute omitted-variable bias.
- ●Explain observational equivalence, where different causal models produce the same data.
Theory
Definition
A structural causal model (SCM) has:
- exogenous variables , determined outside the model, with distribution ;
- endogenous variables ;
- one structural equation per endogenous variable,
The symbol is an assignment: is produced by its causes. Unlike an algebraic equation, it cannot be rearranged to "solve for" a cause.
The induced graph
Draw for each . If the are mutually independent the model is Markovian, the graph is a DAG, and the distribution of factorises over it (Day 47). If some are dependent (an omitted common cause), draw a bidirected edge : the model is semi-Markovian. A bidirected edge is shorthand for with unobserved.
Linear SCMs
Stack the equations: , where is the coefficient of in the equation for and (diagonal if Markovian). Solving,
Because the graph is acyclic, is nilpotent and : entry is the total effect of on , the sum over directed paths of the products of their coefficients.
Structural versus regression coefficients
In , is causal: change by one unit, holding and fixed, and moves by . The regression slope of on alone is
which equals only if the omitted cause is uncorrelated with . The SCM tells you which regression (if any) recovers .
Observational equivalence
Different SCMs can generate the same distribution. With Gaussian variables, and fit any correlation equally well. Data alone cannot decide causal direction there; assumptions (time order, experiments, non-Gaussianity, Day 98) must.
What an SCM adds
An SCM supports three kinds of questions (Pearl's ladder, Day 59): association (from ), intervention (replace an equation, Day 51) and counterfactuals (keep each unit's , Day 59).
Part 1 · Warm-up
Exercise 1 · From equations to graph
Draw the graph for , , , , where and are correlated and the others independent.
Show solution
Step 1. Directed edges from the arguments: , , , , .
Step 2. Correlated disturbances : bidirected edge .
Answer: a semi-Markovian graph; the bidirected edge says an unobserved factor (say, motivation) affects both schooling and wages.
Exercise 2 · Mean and variance
with and with independent. Find , and .
Show solution
Step 1. .
Step 2. .
Step 3. , so .
Exercise 3 · Total effect by paths
In a linear SCM, and . Find the total effect of on .
Show solution
Step 1. Directed paths: with product ; with .
Step 2. Sum: .
Answer: 5.
Exercise 4 · The covariance matrix
For , with and , compute using .
Show solution
Step 1. With order : , so .
Step 2. .
Step 3.
Answer: , , .
Exercise 5 · Assignment, not equation
From , a student writes and concludes that raising raises . What is wrong?
Show solution
Step 1. The structural equation describes how is produced; has its own equation, , which does not involve .
Step 2. Intervening on replaces 's equation and leaves 's untouched (Day 51).
Answer: algebraic rearrangement is valid for the observed values but not for causal claims; does not respond to changes in .
Part 2 · Proofs
Exercise 6 · Markovian SCMs factorise
Prove that if the are independent and the graph is acyclic, then .
Show solution
Step 1. Order the variables topologically. By recursive substitution, each predecessor () is a function of only.
Step 2. is independent of , hence of the predecessors .
Step 3. So given the predecessors, has a distribution that depends only on : .
Step 4. Substitute into the chain rule.
Exercise 7 · Total effects from (I − B)⁻¹
Prove that for an acyclic linear SCM, and that entry for is the sum over directed paths from to of the products of coefficients.
Show solution
Step 1. is nilpotent (, Day 46), so .
Step 2. over intermediate nodes: each non-zero term is a directed path of length , weighted by its coefficients.
Step 3. Summing over adds all directed paths.
Exercise 8 · Omitted-variable bias
Let with independent of . Prove .
Show solution
Step 1. .
Step 2. The last term is 0 by independence.
Step 3. Divide by .
Exercise 9 · Reversing a Gaussian arrow
Let and , , . Construct an SCM with that generates the same joint distribution.
Show solution
Step 1. The original model gives and .
Step 2. Try and with independent.
Step 3. Then and .
Step 4. Both are bivariate normal with mean 0 and the same covariance matrix, so the distributions coincide.
Exercise 10 · When regression is structural
In a Markovian linear SCM, prove that regressing on all its parents recovers the structural coefficients.
Show solution
Step 1. .
Step 2. Each parent is a function of the disturbances of its own ancestors, and is not among them (acyclicity). With independent disturbances, is independent of all parents.
Step 3. So : the OLS moment condition holds at the true coefficients, and the population regression coefficients equal .
Part 3 · Applied
Exercise 11 · Returns to schooling with ability
An SCM for log wages: ability ; years of schooling with ; , all disturbances independent. What does a regression of on alone estimate? What about on and ?
Show solution
Step 1. and .
Step 2. By Exercise 8, the short-regression slope is .
Step 3. With included, the regression is on all parents of , so it recovers (Exercise 10).
Answer: 10.5% per year without ability, 8% with it. The 2.5-point gap is ability bias; in practice is unobserved, which motivates instruments (Phase 5).
Exercise 12 · A binary vaccine model
are independent uniform on . Exposure , vaccination , protection (the vaccine works for 90%), disease . Compute , and .
Show solution
Step 1. requires exposure and no protection: .
Step 2. Given : .
Step 3. Given : .
Answer: 4.6%, 1% and 10%. Because is independent of and here, the observed risk ratio 0.1 equals the causal one.
Exercise 13 · Monetary policy multipliers
A linear macro SCM: interest rate affects investment () and consumption (); investment raises consumption (, via income); output . Compute the total effect of on by paths and by .
Show solution
Step 1. Directed paths : : ; : ; : .
Step 2. Total: .
Step 3. With order , the matrix computation (code below) gives the entry .
Answer: a one-point rise in the policy rate lowers output by 3.1 units; the regression of on alone recovers this only if is set independently of the disturbances.
Exercise 14 · Exercise and fitness
A health survey finds , both standardised and normal. Write two SCMs, one with exercise causing fitness and one with fitness causing exercise, that both fit the data exactly. What evidence could separate them?
Show solution
Step 1. Model 1: , with .
Step 2. Model 2: , with .
Step 3. By Exercise 9 both give the same bivariate normal distribution.
Answer: only extra information can separate them: an experiment (randomise an exercise programme), time order in panel data (exercise this month, fitness next month), or non-Gaussian features (Day 98).
Exercise 15 · Making a bidirected edge explicit
A health economist models hospital quality and patient survival with , and notes that wealthier areas have both better hospitals and healthier patients, but area wealth is not measured. Write a semi-Markovian SCM and show what the regression of on estimates in the linear case , , with unobserved wealth .
Show solution
Step 1. Graph: and (shorthand for with unobserved).
Step 2. and .
Step 3. By Exercise 8 the slope is .
Answer: biased upward when wealth raises both quality and survival (). Days 52–56 ask when such bias can be removed with the variables you do observe.
Verify in Python
import numpy as np
def implied_cov(B, Omega):
"""Covariance of V = B V + eps for an acyclic linear SCM."""
T = np.linalg.inv(np.eye(len(B)) - B)
return T @ Omega @ T.T, T
# Exercise 4
S, _ = implied_cov(np.array([[0, 0], [2, 0.]]), np.diag([1, 3.]))
print("Sigma:\n", S)
# Exercise 11: ability bias (order A, S, logW)
B = np.zeros((3, 3)); B[1, 0] = 2; B[2, 1] = .08; B[2, 0] = .10
S, _ = implied_cov(B, np.diag([1, 4, .25]))
print("short slope:", round(S[1, 2] / S[1, 1], 4))
coef = np.linalg.solve(S[:2, :2], S[:2, 2])
print("long regression (A, S):", coef.round(4))
# Exercise 13: total effects, order R, I, C, Y
B = np.zeros((4, 4)); B[1, 0] = -2; B[2, 0] = -.5; B[2, 1] = .3; B[3, 1] = 1; B[3, 2] = 1
_, T = implied_cov(B, np.eye(4))
print("total effect R -> Y:", T[3, 0].round(3))
# Exercise 12: binary vaccine model by simulation
rng = np.random.default_rng(50); n = 2_000_000
I = rng.random(n) < .1; V = rng.random(n) < .6; E = rng.random(n) < .9
D = I & ~(V & E)
print(f"P(D) {D.mean():.4f} P(D|V=1) {D[V].mean():.4f} P(D|V=0) {D[~V].mean():.4f}")
# Exercise 14: two directions, one distribution
X = rng.normal(size=n); Y = .6 * X + np.sqrt(.64) * rng.normal(size=n)
Y2 = rng.normal(size=n); X2 = .6 * Y2 + np.sqrt(.64) * rng.normal(size=n)
print("cov X->Y model:", np.cov(X, Y).round(3).tolist(), " cov Y->X model:", np.cov(X2, Y2).round(3).tolist())
Key takeaways
- An SCM assigns each variable a mechanism ; independent disturbances give a DAG, dependent ones bidirected edges.
- In linear SCMs, collects total effects and follows from it; regression recovers a structural coefficient only when the regressors block every non-causal path.
- Data can be silent about direction: different SCMs can be observationally equivalent.
Simulation Lab: A Structural Model of Wages
Open full screen →Structural equations for ability, schooling and wages: the short regression slope versus the structural return.
Structural equations: Ability A ~ N(0, 1); Schooling S := 12 + a·A + U_S; log wage := 1.5 + β·S + c·A + U_W. The regression of log wages on schooling alone (orange) has slope β + c·a / Var(S); the structural effect is β (green). Colour shows ability.