Chapter 18: Formalizing Causal Structure — The Three-Level Ladder and do-calculus
You can never derive causality from data. Unless you're willing to admit that some structures are assumptions, not discoveries.
The end of Chapter 17 left us with an unpleasant fact: probability theory, however refined, cannot tell "
This isn't a problem of computing power, and it isn't a problem of data volume. It's a structural limit of mathematics itself: observation describes what the world looks like at rest, not what the world looks like after someone has pulled a lever.
But we keep pulling levers. Doctors prescribe drugs. Policymakers adjust tax rates. Engineers tweak parameters. Every intervention asks a question probability theory cannot answer: "If I change
Answering that question requires a new kind of inference rule. The job of this chapter is to formalize the act of "changing" itself.
18.0 The Causal Wire-Cutting Game: Observing Is Not Intervening
In the probability game, you can only watch how the chips move. In the causal game, you finally get to cut wires.
Picture a causal circuit board. Each variable is a node, and each directed edge is a wire:
That's what
"Seeing
The Formal Skeleton of This Game
- State space: a directed acyclic graph
, plus a set of structural equations . - Legal moves: observe some nodes; or perform an intervention
, cutting all incoming edges of and fixing its value. - Transition rules: observation updates the distribution; intervention replaces the structural equations, yielding the mutilated graph (the graph after the wire cuts).
- Win condition: identify
or a counterfactual quantity, from the observable distribution and the causal graph. - Failure mode: treating
as — misreading correlation as causation.
What's fun about this game is that it turns "causality" from a metaphysical debate into a very concrete action: which wire do you cut? Which do you keep? Once the cuts are made, how does the signal travel?
A back-door path is a wire that sneaks around the back. A confounder is a hand hiding behind the board, pulling on two nodes at once. d-separation asks whether, once certain wires are blocked, information can still get from one side to the other.
The first lesson of causal inference is brutal: seeing is not changing. Your watching the sprinkler run, and your turning it on yourself, are not the same world. The most common arrogance in statistics is passing off observation as intervention. The scissors of a causal graph exist precisely to cut that arrogance away.
18.0.5 Playing the Game in Code
The board is small enough to enumerate exactly — no sampling noise. The program below runs the two computations side by side: conditioning on "ice cream is high" and intervening
#!/usr/bin/env python3
"""
causal_wire_cutting.py -- the Causal Wire-Cutting Game of Chapter 18.
Book reference: The Reasoning Kingdom, Volume 2, Chapter 18, Section 18.0
"The Causal Wire-Cutting Game: Observing Is Not Intervening."
Each variable is a node, each edge a wire. Observing watches the lights;
intervening picks up scissors, cuts every wire into a node, and pins the
node to a value. This program runs a small causal circuit board:
season (Z) ----> ice cream sales (X)
|
+----------> drownings (Y)
* P(Y | X=x) -- conditioning: watch the board, no scissors.
* P(Y | do(X=x)) -- intervention: cut Z -> X, pin X, let the rest run.
The two numbers come out different. That difference IS the game -- and
it is why "seeing is not changing."
Everything below is exact enumeration over a small finite board: no
randomness, no sampling noise.
Run: python3 causal_wire_cutting.py
"""
from itertools import product
# Worlds: (season, ux, uy). Noise ux/uy in 1..10 decides X and Y through
# the structural equations. Summer pushes both variables up -- that shared
# push is the confounder (the hand behind the board).
SEASONS = ("summer", "winter")
NOISE = range(1, 11)
def x_value(season, ux):
"""Structural equation of X: ice cream sales."""
if season == "summer":
return "high" if ux <= 9 else "low"
return "high" if ux <= 2 else "low"
def y_value(season, uy):
"""Structural equation of Y: drownings."""
if season == "summer":
return "high" if uy <= 8 else "low"
return "high" if uy <= 1 else "low"
def worlds():
return product(SEASONS, NOISE, NOISE)
def prob_condition():
"""P(Y=high | X=high): watch the board, count the worlds."""
both = total = 0
for season, ux, uy in worlds():
if x_value(season, ux) == "high":
total += 1
if y_value(season, uy) == "high":
both += 1
return both / total
def prob_intervene():
"""P(Y=high | do(X=high)): cut Z -> X, pin X=high, count the worlds.
The scissors remove X's structural equation; X is decided by the hand.
Y keeps its own equation, so only the seasonal push into Y remains.
"""
high = total = 0
for season, _, uy in worlds():
total += 1
if y_value(season, uy) == "high":
high += 1
return high / total
def demo():
print("=" * 70)
print(" THE CAUSAL WIRE-CUTTING GAME -- seeing is not changing")
print(" The Reasoning Kingdom, Volume 2, Chapter 18 (Sec. 18.0)")
print("=" * 70)
print("\nCircuit: season -> ice cream -> (nothing)")
print(" season -> drownings")
print(" the season pushes both ice cream sales and drownings up at")
print(" once: a confounder, the hand behind the board.")
p_cond = prob_condition()
p_do = prob_intervene()
print(f"\nP(drownings=high | ice cream=high) = {p_cond:.4f}")
print(f"P(drownings=high | do(ice cream=high)) = {p_do:.4f}")
print("\nThe same 'ice cream is high' observation means different things:")
print(" conditioning: the board is untouched; a high ice cream reading")
print(" suggests summer, so drownings look likely too.")
print(" intervention: scissors cut season -> ice cream, the hand pins")
print(" X=high. Summer is no longer implied, and the drowning rate")
print(" drops back to its unconditional level.")
print(f"\nDifference: {p_cond - p_do:.4f} -- pure confounding, no data")
print(" collection can remove it; only a wire cut can.")
print("\nThe point of the game: correlation is what the board shows you;")
print(" causation is what you are allowed to do to the board. The most")
print(" common arrogance in statistics is passing off observation as")
print(" intervention. The scissors exist to cut that arrogance away.")
print("=" * 70)
if __name__ == "__main__":
demo()18.1 The Three-Level Ladder
Judea Pearl described the layers of causal inference with a metaphor he calls the Ladder of Causation. The ladder has three rungs, from low to high, and each rung requires a capability the rung below it does not have.
Level 1: Association
This is probability theory's home turf. The questions look like:
"Seeing
, what is ?"
In math:
Level 2: Intervention
The questions change shape:
"If I set
to some value, what would be?"
The difference from Level 1 is fundamental. "Seeing
When you observe passively,
This level needs more than data. It needs action — or, when action isn't possible, some tool that lets you simulate the action mathematically.
Level 3: Counterfactual
The questions get harder still:
"If
hadn't been that value, what would have been?"
This is now a question about one individual in another possible world. "This patient took the drug and recovered — if he hadn't taken the drug, would he still have recovered?" No amount of observation or experimentation can answer that directly, because that parallel world in which he didn't take the drug is one we can never enter.
These three levels correspond to real boundaries of capability. Pure observational data can only answer Level 1 questions. A randomized controlled trial (RCT — an experiment that randomly assigns people to a treatment group or a control group) can answer Level 2, but the price is actually carrying out the intervention. Counterfactual inference needs a complete causal model plus extra assumptions about "individual mechanisms" — beyond anything an experiment can reach. Most statisticians have spent the better part of their careers working on Level 1 while believing they were answering Level 2 questions. That confusion has produced a great many faulty conclusions in the scientific literature.
"Mistakenly believed" is far too kind. This isn't a cognitive error; it's a tool error. When the only hammer you hold is correlation, every problem looks like a correlation nail. The problem isn't statisticians' intelligence — it's that standard training has never drawn the line between Level 1 and Level 2 cleanly.
18.2 Graphs: The Geometry of Causality
The first step is to give "causal structure" a precise mathematical representation.
The directed acyclic graph (DAG) is the most natural tool. Nodes represent variables, and directed edges represent direct causal influence:
A simple example. Consider three variables: season (
Season affects the sprinkler (it runs more in summer), season also directly affects the lawn (rain), and the sprinkler also directly affects the lawn.
In this graph,
Probability theory sees the combined result of both routes and can't separate them. The graph draws the structure out explicitly.
This is the most common beginner mistake. A causal graph represents domain knowledge, not a product of statistical inference. You can't derive this graph from
The arrows' directions are brought in by you, not given by the data — this sentence will make a lot of data scientists uncomfortable, because they're used to "letting the data speak." But data can't say this. Admitting it takes courage, and many papers dodge this step. The price of dodging is hiding the assumption inside the method and pretending it's a conclusion.
18.3 Structural Causal Models
A graph is just a skeleton. To turn it into a machine that can do inference, you need to attach content to every edge. That's the structural causal model (SCM).
An SCM consists of three parts:
Exogenous variables
Endogenous variables
Structural equations: for each endogenous variable
where
This equation is not a statistical regression equation — it's a mechanism, describing "what value this variable takes, given its parents and its noise." The mechanism is stable and local: changing the equation of some other variable doesn't affect this one. That local stability is the core feature that separates causal models from statistical models.
Back to the sprinkler example. The structural equations might be:
18.4 The do Operator: Formalizing Intervention
Now we can define "intervention" precisely.
The operational definition of the intervention
The effect on the graph is easy to see: delete every edge pointing into
This "operated-on" graph is called the interventional graph, written
The do Operator vs. Conditioning
Why do
Conditioning
Intervention
A concrete example:
: among the people who chose to take the drug, what is the recovery rate? (Probably too high — milder patients are more likely to choose the drug.) : if I forcibly assign a random set of people to take the drug (a randomized controlled trial), what is the recovery rate? (The true drug effect.)
The do operator is the mathematical expression of a randomized controlled trial. When an RCT isn't feasible, do-calculus provides the rules for estimating an interventional effect from observational data.
The post-intervention probability distribution is written
Compare it with the conditional probability:
The first is "the distribution of
The two can differ enormously. In the sprinkler example,
The core operation of a randomized controlled trial — randomly assigning subjects to a treatment group and a control group — is mathematically exactly
What the do operator looks like in a matrix and in code
The
Write the unit structural equation
import numpy as np
A = np.array([[0, 0.9, 0.8], # structure: ad_spend -> clicks -> revenue
[0, 0, 0.7],
[0, 0, 0]])
E = np.random.randn(3, 16) # one embedding per variable
U = np.zeros_like(E)
# step 1: cut all incoming edges of X (fill in column X with zeros)
def do_cut(A, var):
A_do = A.copy()
A_do[:, var] = 0
return A_do
# step 2: propagate the effect along the remaining edges
def propagate(A_do, E, U):
return A_do.T @ E + U
# do(ad_spend = 3.0): the value enters as a constant, then effects flow
A_do = do_cut(A, 0)
E_next = propagate(A_do, E, U)The correspondence with Pearl's definition:
| Pearl's do operator | Matrix/code implementation |
|---|---|
| Replace | Zero out the column for |
| Delete all edges pointing into | Set column |
| Propagate the effect through descendants | One matrix multiplication via propagate |
| Cyclic graphs are illegal |
That's all there is to it — the most profound operator in causal inference, at the implementation level, is "zero out a column, multiply once." You don't need any extra framework or type system.
18.5 The Back-Door Criterion: The Geometry of Confounding
The core question of do-calculus is: under what conditions can you estimate a causal effect from observational data — that is, when can
Answering that requires understanding the geometry of "confounding."
In a causal graph,
The back-door criterion gives an exact condition: a variable set
contains no descendants of ; blocks every back-door path from to .
If such a
This formula is called the adjustment formula. It means: for each value of
In the sprinkler example,
This quantity is fully determined by observational data — no need to actually touch the sprinkler.
18.5.5 Hands-on: Front-Door Adjustment — When the Back Door Is Blocked
The back-door criterion requires an observable confounder
That's when the front-door criterion can save you — as long as there is a mediator variable
blocks all causal paths from to ; - There is no back door from
to (no unobservable confounding between and ); - The back door from
to is blocked by (after adjusting for , there is no confounding from to ).
The classic example: smoking
, , - The hidden variable
affects both and (a back-door path), but does not affect (no hidden confounding between and — the amount smoked directly determines the tar; genes don't directly change the tar) - Back-door criterion: you'd need to observe
, but is unobservable the back-door criterion fails - Front-door criterion: identify the effect through
(the tar)
The front-door adjustment formula:
Unpacked in plain language:
- The first term
: when someone smokes , how much tar results? This is 's causal effect on (no back door, directly estimable). - The second term
: given tar , the weighted average of lung-cancer probability over the smoking population — here you adjust for to block the back door from to . - Multiply, then sum over
: combining 's effect on with 's effect on gives the total causal effect of on .
A numerical example (fictional data, simplified):
| Smoking | Tar | Lung cancer | Count |
|---|---|---|---|
| 1 | high | 1 | 300 |
| 1 | high | 0 | 100 |
| 1 | low | 1 | 50 |
| 1 | low | 0 | 150 |
| 0 | high | 1 | 30 |
| 0 | high | 0 | 70 |
| 0 | low | 1 | 20 |
| 0 | low | 0 | 280 |
Compute
; Given
: Given
:
If everyone were forced to smoke, the lung-cancer probability would be 43.9%. The plain conditional probability
Front-door adjustment is an underrated gem. Most textbooks teach only the back-door criterion, because the back door is more intuitive. But the back door requires observing the confounder — which is often just not possible. The front-door criterion does not require observing the confounder at all; it uses a mediator you can observe. In practice that makes it far more usable than the back door, and far more counterintuitive — you bypass an unseen confounder by going through a mediator. Sometimes a detour is the right way.
18.6 The Three Rules of do-calculus
The back-door criterion covers a lot of real cases, but not all. In some causal graphs, no set of observable variables can completely block the back-door paths — for instance, when unobservable confounders are present.
To handle the more general cases, Pearl introduced do-calculus: three inference rules about the
Let
Rule 1 (Insertion and Deletion of Observations):
holds if and only if
In words: if in the interventional graph
Rule 2 (Interchange Between Action and Observation):
holds if and only if
In words: under certain conditions, intervening on
Rule 3 (Elimination of Interventions):
holds if and only if
In words: under certain conditions,
Pearl and Shpitser proved this: for any causal graph, if
The form of these three rules closely resembles the inference rules of Chapter 14: what goes on top of the line is a condition; what goes below it is the inference you may draw. The difference is that the "language" here is not just propositions — it's probability expressions carrying the
Back to the wire-cutting game: the three rules of do-calculus are the move tables you consult after the cuts. When can you drop an observation? When can you trade an action for an observation? When can an intervention be eliminated entirely? The answers lie not on the surface of the formulas, but in the graph after the cutting. Causal inference is stronger than probabilistic inference because it admits "actions" into the syntax; it is more dangerous for the same reason — every action depends on your having drawn that graph correctly.
18.7 d-Separation: The Independence Language of Graphs
Each of the three rules of do-calculus relies on one core judgment: whether two sets of variables are conditionally independent given a third set, in some graph. How do you read conditional independence directly off a graph's structure? That's exactly the job of d-separation (directional separation).
Given a directed acyclic graph
Whether a path is "blocked" depends on the types of nodes along the path:
- Chain
: the path is blocked when is in ( passes the information on; once you control , the flow stops). - Fork
: the path is blocked when is in ( is a common cause; once you control , the correlation disappears). - Collider
: the path is blocked when is not in (a collider stops information by default; but controlling it, or any of its descendants, actually opens the path — that's where "collider bias" comes from).
The behavior of colliders is counterintuitive, and it's worth stopping to think it through. Suppose "height" (
18.8 Counterfactuals: Another World for a Single Individual
The top rung of the ladder, the counterfactual, needs a precise definition inside the structural causal model.
Consider one particular individual who, in a particular situation, experienced
In an SCM, this question has a three-step answer:
Step 1: Abduction. Using the observed
Step 2: Action. In the structural equations, replace the equation for
Step 3: Prediction. Under the modified model and the posterior distribution of
These three steps together give an operational definition of counterfactual inference — not philosophical speculation, but a computable procedure, provided you have a sufficiently complete SCM.
The "average treatment effect" (ATE) familiar from epidemiology is a Level 2 concept:
18.9 Causality and Inference: A Bigger Picture
Review the road this chapter has traveled.
Back in Chapter 14, inference rules were about propositions: from a batch of assumptions
Now this chapter does something new: it adds a new verb to the language of inference — intervention. The
This structure runs exactly parallel to the structure of a formal system:
| Formal system | Causal inference |
|---|---|
| Propositional variables | Variables |
| Inference rules | The three rules of do-calculus |
| Axioms | The graph (local independence assumptions) |
| Provable ( | Identifiable |
| Incompleteness theorem | Non-identifiability theorem |
The non-identifiability theorem plays the role of the incompleteness theorem: there are causal effects that, even given complete observational data and a complete graph, can never be computed from observation alone — you must actually run the experiment. That is not a flaw in the method; it is a structural boundary.
Open Questions
Where do causal graphs come from? The whole chapter assumes you already have a correct causal graph. But in practice, a graph is the product of subjective knowledge and domain assumptions. If the graph is wrong, the answers do-calculus gives are wrong too — the reliability of the system rests on the correctness of the graph, and the graph's correctness cannot be verified from data. This is the deepest dilemma of causal inference: the more precise the tool, the heavier the assumptions it carries.
Can causal graphs be discovered automatically from data? Causal discovery algorithms — the PC algorithm, the FCI algorithm, LiNGAM — try to infer aspects of causal structure from observational data. But in general, observable data can only pin down a "Markov equivalence class" — a set of graphs that yield the same conditional-independence relations, with arrow directions indistinguishable within the class. Picking one graph out of the class still requires domain knowledge, or additional assumptions about the error distributions.
How expensive is inference on a causal graph? Even with the graph in hand, identifying and computing causal effects is computationally expensive in general. Deciding whether a causal effect is identifiable can be done in polynomial time; but in complex graphs with hidden variables, computing the actual expression for an identifiable effect becomes dramatically more expensive. The full picture of this problem is the topic of Chapter 19: the price of reasoning is not only a logical limit, but a computational one.
Exercises
★ Warm-up
For each of the following questions, determine which rung of the ladder of causation it belongs to (association / intervention / counterfactual), and explain why.
- "How much higher is the lung-cancer rate among smokers than among non-smokers?"
- "If a smoking ban were strictly enforced, how much would the lung-cancer rate fall?"
- "If this lung-cancer patient had never smoked back then, would he have cancer now?"
- "Among people diagnosed with high blood pressure, what fraction are on blood-pressure medication?"
- "If this high-blood-pressure patient is prescribed medication, how much will his risk of a cardiovascular event drop over the next 10 years?"
★★ Derivation
Consider the causal graph:
- List every path from
to . Which are causal paths (following the arrows), and which are back-door paths? - Using the back-door criterion, write out the adjustment formula for
. - If
is an unobservable hidden variable, can the adjustment formula still be used? Is identifiable in that case?
★★★ Challenge
In the causal graph
You want to separately estimate:
- the direct effect of
on (the part not going through ) - the indirect effect of
on (the part going through )
Which rung of the ladder do the direct and indirect effects belong to? Try writing the definitions of these two quantities in the language of the
