Lesson 2 of 2 · Causal Inference
Interventions, the do operator and the adjustment formula
P(Y | X = x) describes what we observe, and P(Y | do(X = x)) describes what happens if we set X = x; an intervention cuts the arrows into X, and if a set Z satisfies the backdoor criterion, the intervention can be computed from observational data with the adjustment formula Σ P(Y|x, z) P(z).
Lesson contents
1 Introduction
Knowing that patients who take a certain drug recover more often does not tell us what would happen if we gave the drug to everyone. The first question is observational and the second is interventional. The do operator introduced by Judea Pearl makes this difference mathematical.
Learning objectives
- Distinguish conditional probability from probability under intervention
- Represent an intervention by cutting arrows in the diagram
- Apply the adjustment formula through the backdoor criterion
- Compute the average treatment effect (ATE) and compare it with the observational difference
2 Why study this topic?
Every practical decision is an intervention: launching a feature, changing a price, adjusting a policy. Reinforcement learning is essentially learning the effects of interventions (actions). Estimating an effect from observational data when experiments are costly or unethical requires the adjustment formula and its conditions.
3 Theoretical explanation
Observation versus intervention
\(P(Y \mid X = x)\): the probability of Y among those who happened to have \(X = x\). \(P(Y \mid do(X = x))\): the probability of Y if we forced everyone to \(X = x\). They differ when there is a confounder, because those who chose x differ from the others.
An intervention is surgery on the diagram
The intervention \(do(X = x)\) deletes all arrows into X and fixes its value, keeping the other mechanisms as they are. In \(Z \to X \to Y\) and \(Z \to Y\), the arrow \(Z \to X\) is deleted.
The backdoor criterion and the adjustment formula
A set Z satisfies the backdoor criterion relative to \((X, Y)\) if it contains no descendants of X and blocks every path between X and Y that starts with an arrow into X. Then:
\[P(Y \mid do(X = x)) = \sum_z P(Y \mid X = x, Z = z)\,P(Z = z)\]
Note that the weight is \(P(z)\), not \(P(z \mid x)\): that is the entire difference from the ordinary conditional probability \(\sum_z P(Y|x, z)P(z|x)\).
Numerical example
\(P(Z=1) = 0.5\), \(P(X=1|Z=0) = 0.2\), \(P(X=1|Z=1) = 0.8\), and \(P(Y=1|X, Z)\): (0,0) 0.1, (0,1) 0.5, (1,0) 0.3, (1,1) 0.7.
| X = 0 | X = 1 | Difference | |
|---|---|---|---|
| Observation \(P(Y=1|X)\) | 0.18 | 0.62 | 0.44 |
| Intervention \(P(Y=1|do(X))\) | 0.3 | 0.5 | 0.2 |
The observational difference \(0.44\) is more than twice the true causal effect \(\mathrm{ATE} = 0.2\), because \(Z = 1\) increases both the probability of X and the probability of Y.
Average causal effect
\[\mathrm{ATE} = \mathbb E[Y \mid do(X = 1)] - \mathbb E[Y \mid do(X = 0)]\]
In a randomized experiment it equals the observational difference directly, and in observational data we need the adjustment formula or methods such as inverse probability of treatment weighting.
4 Mathematical definitions
- The do operator
- A symbol for an external intervention that fixes the value of a variable and cuts its causes.\[P(Y|do(X=x))\]
- Back-door criterion
- A condition on an adjustment set that blocks all backdoor paths between the cause and the effect and contains no descendants of the cause.
- The adjustment formula
- Computing the probability under intervention from observational data by a weighted average over the confounders.\[\sum_z P(Y|x,z)P(z)\]
- Average causal effect
- The difference in the expected outcome between the two interventions.\[\mathrm{ATE}=\mathbb E[Y|do(1)]-\mathbb E[Y|do(0)]\]
- The do operator
- The intervention symbol that fixes a variable's value and cuts its causes in the graph.\[P(Y|do(X=x))\]
- Back-door adjustment
- Computing the effect of an intervention from observational data with a set that blocks every back-door path.\[P(Y|do(x))=\sum_z P(Y|x,z)P(z)\]
- Average causal effect
- The difference in expected outcome between imposing the treatment on everyone and not imposing it.\[\mathbb E[Y|do(1)]-\mathbb E[Y|do(0)]\]
5 The equations
6 Step-by-step worked example
Probability under intervention
Problem: Compute \(P(Y=1 \mid do(X=1))\) in the example.
- \(0.5 \times 0.3 + 0.5 \times 0.7\).
Result: \(0.5\)
Observational probability
Problem: Compute \(P(Y=1 \mid X=1)\) in the same example.
- \(P(Z=1 \mid X=1) = \frac{0.5 \times 0.8}{0.5 \times 0.8 + 0.5 \times 0.2} = 0.8\).
- \(0.2 \times 0.3 + 0.8 \times 0.7\).
Result: \(0.62\)
Causal effect
Problem: Compare the ATE with the observational difference.
- \(\mathrm{ATE} = 0.5 - 0.3\).
- The observational difference is \(0.62 - 0.18\).
Result: ATE = 0.2 and the observational difference = 0.44
7 Practical application in AI
- Policy evaluation: Estimating the effect of a marketing campaign or a price change from historical records using the adjustment formula when no experiment is available.
- Off-policy reinforcement learning: Evaluating a new policy from data collected by another policy is a causal problem solved with importance weights.
- Recommender systems: What the user watches depends on what was shown to them, so estimating the effect of a recommendation requires handling the confounding produced by the system itself.
8 Interactive lab linked to the lesson
A linear causal model showing confounding bias between the naive slope and the adjusted slope, Simpson's paradox on data from a published study, and the difference between the conditional probability P(Y|X) and the intervention P(Y|do(X)) through the adjustment formula.
Open the Causal Inference Lab9 Practice exercises
Review questions for reflection
- What is the only difference between the adjustment formula and the conditional probability?
- Why does an intervention delete only the arrows into X?
- When does the observational difference equal the ATE?
Common mistakes
- Using \(P(z \mid x)\) instead of \(P(z)\) in the adjustment formula.
- Adjusting for a variable that comes after the treatment (one of its descendants).
- Assuming that all confounders are observed without justification.
- Confusing \(P(Y|do(x))\) with \(P(Y|x)\) when interpreting model results.
10 Lesson summary
- Observation answers "what do we see", and intervention answers "what would happen if".
- do(X) cuts the arrows into X.
- The adjustment formula weights by P(z), not P(z|x).
- The ATE equals the observational difference only in the absence of confounding.
11 Short quiz
5 questions · 10 minutes · pass mark 60% — passing it completes the lesson.
