1.23 Correlation, causation and confounding
Standard probability and statistics for ML — written August 2026
What this is and why it exists
Models find correlations; decisions need causes. Acting on a correlation as if it were a cause is the most expensive routine mistake in applied data work — and the defence is a small set of concepts (confounder, collider, mediator), one drawing tool (the DAG), and a shortlist of designs that extract causal answers when experiments are impossible. This topic is the difference between "the model found X predicts Y" and "changing X will change Y".
The vocabulary
- Spurious correlation — a real statistical association with no causal link under it.
- Confounder — a common CAUSE of both variables, manufacturing association between them.
- Collider — a common EFFECT of both; conditioning on it CREATES association where none existed.
- Mediator — the middleman on the causal path; adjusting for it hides the very effect under study.
- Simpson's paradox — an association that reverses when data is split by a third variable.
- DAG (directed acyclic graph) — variables as nodes, causal arrows as edges: the assumptions, drawn.
- Natural experiment / IV / difference-in-differences — designs that recover causal effects from observational data: nature randomises; an instrument nudges only through the cause; parallel trends difference out the background.
The mental model
Association flows along every open path in the causal graph; causation is one particular arrow. Ice-cream sales and drownings rise together because summer causes both — a CONFOUNDER, the classic backdoor path, closed by adjusting for season. So "control for everything" — and here is the topic's sharpest lesson: NO. Adjusting for a COLLIDER (a common effect) opens a path that was closed: among hospital patients (conditioning on admission — an effect of both diseases), two independent diseases correlate negatively; select on hired candidates and skills that are independent in the population trade off in your dataset. Adjusting for a MEDIATOR erases the effect you came to measure: studying education's effect on income "controlling for occupation" throws away the main route by which education pays. What to adjust for is decided by the GRAPH, not by the columns available — which is why the DAG, drawn before the regression, is the thinking tool: close backdoors, leave colliders and mediators alone.
Simpson's paradox is the confounder at its most theatrical: a treatment beats its rival within every severity group, yet loses in the pooled table because it was given to the harder cases. Direction of truth: the SPLIT tables, when severity is a confounder — but only the graph says so; splitting by a collider would be the error instead. The paradox is not a curiosity; admission rates, drug studies and dashboard metrics reverse under splits routinely.
When you cannot randomise (st4's luxury), the shortlist: NATURAL EXPERIMENTS — some lottery, cutoff or boundary assigns the cause as-if randomly (birth-month school cutoffs, draft lotteries). INSTRUMENTAL VARIABLES — a variable that nudges the cause and touches the outcome ONLY through it (rainfall shifting prices; the instrument's validity is an argument, not a statistic). DIFFERENCE-IN-DIFFERENCES — treated and untreated groups tracked before and after a change; subtracting each group's own trend differences out shared background, resting on the parallel-trends assumption that the groups were moving alike beforehand. Each buys causality with an assumption you must defend aloud.
What you should now be able to explain or do
Draw the DAG for a claimed effect and classify each third variable as confounder, collider or mediator. Predict which adjustments help and which manufacture bias. Narrate a Simpson's reversal and say which table to trust, and why. Match natural experiment, IV and DiD to scenarios, naming each one's load-bearing assumption.
Check yourself
Confounder, collider, mediator — the adjustment rule for each, in one line.
Confounder (common cause): adjust — it closes the backdoor. Collider (common effect): do NOT adjust — conditioning opens a false path. Mediator (on the causal path): do not adjust when the total effect is the question — it absorbs the effect.
Why do two independent conditions correlate among hospital in-patients?
Admission is a collider — an effect of both. Conditioning on being admitted (the sample IS in-patients) opens the path: within the ward, having one condition makes the other a less necessary explanation for being there.
A drug wins within every age band but loses overall. What happened, and which read is right?
Simpson's paradox via a confounder — the drug went disproportionately to worse cases (older patients). With age confounding treatment, the within-band comparison is the honest one.
What must be true of a valid instrument, and which half is untestable?
It moves the cause, and it touches the outcome through NO other path. The first is checkable in data; the exclusion restriction — no other path — is an argument you must win with subject knowledge.
Difference-in-differences rests on which assumption, and how is it probed?
Parallel trends: absent the change, both groups would have moved alike. Probe by plotting the PRE-period trends — visibly diverging groups disqualify the design.
Go deeper
We haven't checked most of these for screen reader use yet.
Back to Correlation, causation and confounding: work through the checklist