Causal Inference & Experiments
P5.ml-methods.04 · Audience: Guest, IT/ML learner, Language professional · Prerequisites: Regression & GLMs
Where next?
Later in ML Methods
Go up a level
P5.ml-methods.04 · Audience: Guest, IT/ML learner, Language professional · Prerequisites: Regression & GLMs
Later in ML Methods
Go up a level
Adding more control variables to an analysis feels like caution, but it can manufacture the very bias it is meant to remove: condition on a common effect of two independent causes and those causes suddenly look correlated. What to adjust for is therefore a causal question, not a statistical reflex, and it is settled by drawing the graph of what causes what. This module teaches you to read independence off such graphs, to spot confounders — variables that drive both the treatment and the outcome — and the way pooled data can reverse an effect seen in every subgroup, to run the randomised A/B experiments that compare two versions on live users, and to name the untestable assumption behind every observational shortcut. Each pitfall is grounded in a concrete numeric example, because these are the questions interviewers use to separate recognition from understanding.
When the Causal Inference pillar (P8) launches, it will promote this module's topics — DAGs, confounding, experimentation, observational designs — into full tracks of their own and cross-link back here. This module is not moved: its address P5.ml-methods.04 stays stable, and any regrouping is navigation-only.
Framing. The causal graph — not the correlation — decides what to control for: adjust for confounders, never for colliders or mediators. Each step makes that concrete with numbers.
1 — Conditional independence, colliders & d-separation (s7). A DAG encodes independencies via three structures: a chain X → Z → Y and a fork (confounder) X ← Z → Y both give X ⊥ Y ∣ Z (condition on the middle to block); a collider X → Z ← Y is the opposite — X and Y start independent, and conditioning on the collider opens a spurious path.
Worked example — collider bias among the cast. Suppose acting talent and looks are independent in the population, but a film role requires being high on at least one. Condition on being cast:
| Among people who got cast | High looks | Low looks |
|---|---|---|
| High talent | got in on either | got in on talent |
| Low talent | got in on looks | not cast — excluded |
Once you look only at those cast, low talent almost guarantees high looks (else they wouldn't be there) — so talent and looks become negatively correlated even though they were independent. That's collider bias (Berkson's paradox). The lesson: conditioning on a collider creates dependence — the exact opposite of conditioning on a confounder.
Interview-depth causal reasoning for the ML track: conditional independence and d-separation, confounding and Simpson's paradox, trustworthy A/B testing, and identification beyond RCTs — with the untestable assumption behind every method.
Conditional independence X ⊥ Y ∣ Z means that, once Z is known, X carries no extra information about Y: P(X, Y ∣ Z) = P(X ∣ Z) · P(Y ∣ Z). A DAG encodes such independencies through three canonical structures:
Key trap. Conditioning on a collider does the opposite of conditioning on a confounder: it creates dependence rather than removing it — selection / collider bias, also known as Berkson's paradox (e.g. among hospitalised patients two unrelated diseases appear negatively correlated because admission is the collider you conditioned on).
d-separation is the graphical rule that reads all these independencies off a DAG at once: a path is blocked if it contains a chain or fork whose middle node is in Z, or a collider whose node (and all descendants) are not in Z. If every path between X and Y is blocked given Z, then X ⊥ Y ∣ Z.
A confounder is a variable that influences both the treatment and the outcome. It opens a back-door path T ← C → Y, so the naive association between T and Y mixes the causal effect with the confounder's — biasing the estimate. You de-confound by:
Simpson's paradox is confounding made vivid: an association that holds within every subgroup reverses when the subgroups are pooled, because an imbalanced confounder dominates the aggregate (the classic Berkeley admissions and kidney-stone examples). The direction of the "true" effect is not a statistical question — the causal graph decides which table to trust.
The corollary — "don't control everything." Adjusting for more variables is not always safer: you must never adjust for a collider or a mediator. Conditioning on a collider opens a spurious path (Section 1); conditioning on a mediator removes part of the very effect you want to measure. Control the variables the causal graph identifies as back-door blockers (the confounders), and leave the others alone. Simpson's paradox warns that pooling or splitting on the wrong variable can flip your conclusion entirely.
Randomisation is the whole point: assigning treatment at random makes it independent of all confounders (observed and unobserved), so the simple difference in group means is an unbiased estimate of the average causal effect — no adjustment needed.
Getting an A/B test right is mostly about the traps around that clean idea:
When randomisation is impossible or unethical, we identify causal effects from observational data — but only under an untestable identifying assumption. Each classic design trades a different such assumption:
Rigorous references for causal inference and experimentation.
| Type | Resource |
|---|---|
| Book | Pearl, Glymour & Jewell, Causal Inference in Statistics: A Primer |
| Book | Cunningham, Causal Inference: The Mixtape — IV, DiD, RDD, matching |
| Book | Kohavi, Tang & Xu, Trustworthy Online Controlled Experiments |
| In-app | P5.ml-methods.07 — ML in Production, for online experiments and Goodhart effects |
| In-app | P1.statistics-advanced.01 — Advanced Probability (S7-adv), for the conditioning identities |
Ask a question about this content. The mentor explains and grounds its answer in what you are studying; asking is recorded as a learning signal, not a grade.
Off by default. The mentor always gets your file; this only decides whether your own copy stays here. Copies live in this browser only - they do not follow you to another device, and clearing site data removes them.
A scratch console for this page's ideas — ungraded, nothing you run here is recorded.
Scratch console
A scratch console with the scientific stack (pandas, numpy, scikit-learn). Runs on the server — no network, resource-limited and measured.
Output appears here.
Loading your notes...