Causal inference
Confounders, Mediators, Colliders, and Selection
Distinguish baseline confounding, mediation, collision, post-treatment variables, and selection mechanisms in study design and analysis.
By the end you can
- Classify variables by their causal role relative to treatment and outcome
- Explain how mediator adjustment changes the estimand
- Explain collider and selection bias with path reasoning
- Design variable collection around causal roles rather than predictive value
Example
A discipline counted its own post-treatment controls and found them in 35 of 75 articles
Post-treatment conditioning should be rarest where randomisation is strongest. It is not. Three political scientists coded every article containing a survey, field, laboratory or lab-in-the-field experiment published in the American Political Science Review, the American Journal of Political Science and the Journal of Politics from 2012 to 2014. Seventy-five articles. Every one of them had a randomised treatment.
35 of the 75 — 46.7% — engaged in post-treatment conditioning. 16, or 21.3%, controlled for a post-treatment covariate in a statistical model. 11, or 14.7%, subsetted the data on post-treatment criteria. 8, or 10.7%, did both. Nothing had gone wrong upstream. The randomisation held, the data were clean, the models fit. Then a variable measured after the treatment was added to the right-hand side, or used to decide who stayed in the sample.
What that costs is not a small shading of the estimate in one direction. The authors' own summary of their 2018 paper puts it plainly: “Post-treatment bias can affect our estimates in any direction and can be of any size.” Nothing in any of those 35 outputs said which direction, or how much. A coefficient does not report what question it ended up answering.
- A confounder sits in the past of both. Something already true of a unit before the treatment made the treatment likelier, and made the outcome likelier too. Randomisation is what removes it — which is exactly why the failure in those 75 experimental articles had to lie somewhere else.
- A mediator is something the treatment itself produced, which then moved the outcome. It carries the effect rather than distorting it. Hold it fixed and you remove the part of the effect that travelled through it.
- A collider is a variable that the treatment and some separate cause of the outcome both push on, so it registers the two of them at once. Condition on it and you link causes that had nothing to do with each other.
- Selection is the same trap moved to the edge of the dataset. Who is included at all depends on things tied to both the treatment and the outcome. That is what the 14.7% who subsetted on post-treatment criteria were doing, without a line of adjustment code anywhere in the model.
Comparison
Why identical adjustment code can estimate different targets
The line of code is the same either way. Add the variable to the model, refit, read the coefficient. What differs is nothing the software can see: where that variable sits relative to the treatment and the outcome.
One stratification can carry an answer the whole way across. In US 1991 natality data the unstratified result is the one everyone expects: infants of smokers had higher risks of both low birth weight and infant mortality than infants of nonsmokers. Then the analysis was stratified on birth weight, a variable that lies downstream of smoking rather than beside it. The association flipped sign. Hernández-Díaz and colleagues reported it in the American Journal of Epidemiology in 2006, and their abstract states it in one line: “However, among LBW infants, infant mortality was lower for infants born to smokers (relative rate = 0.79).”
0.79. Same dataset, same exposure, same outcome, and smoking now looks mildly protective among low-birth-weight infants. Nothing was fabricated and no data were dirty. One stratification did it.
Add a common cause and the adjustment closes a path that was carrying association the treatment never produced. The estimate moves toward the effect you wanted. Add something the treatment itself caused and the adjustment closes a path that was carrying the real effect. The estimate moves away from it. Condition on a common effect and you can manufacture an association between two things that had none before you looked.
Three different outcomes, one syntax.
And the diagnostics do not move when the target does. Fit statistics measure how well a model describes the data it was handed. They cannot tell you which question it ended up answering, and they will not warn you that the sign is the wrong way round.
Adjust confounder
Blocks a backdoor path.
- Targets total effect
- Needs pre-treatment timing
- Can improve exchangeability
Adjust mediator
Blocks part of causal pathway.
- Changes effect target
- Needs mediation assumptions
- May create post-treatment bias
Adjust collider
Opens a non-causal path.
- Can induce association
- Often caused by selection
- Usually harmful for total effect
A role is a position in the causal structure, not a property of the column
A confounder is a common cause. It sits upstream of both the treatment and the outcome, and it is why the two move together for reasons that have nothing to do with one producing the other. A mediator lies on the path between them: the treatment causes it, and it causes the outcome. A collider is the opposite shape, a variable that the treatment and another cause of the outcome both flow into. Selection is a collider you conditioned on without meaning to, by deciding who got into the sample.
Notice what those definitions are made of. Not the variable's name, not how strongly it correlates with anything. Only arrows, and which way they point.
Which is why the same column can be a confounder in one study and a mediator in another. Move the measurement earlier or later, ask about a different effect, and the role changes while the data sits unchanged. "Control variable" names a position in a regression command. It does not name anything causal, and a long list of control variables is not a defence.
Every nonparametric identification problem reduces to three structurally distinct biases: overcontrol bias, confounding bias and endogenous selection bias. That is the argument of Elwert and Winship's 2014 review in the Annual Review of Sociology, and it makes the taxonomy more than a set of labels laid over the analysis. It is the complete list of ways the arrows can defeat you. The third one also reaches further than the word "selection" suggests. From their abstract: “Endogenous selection bias can result from direct conditioning on the outcome variable, a post-outcome variable, a post-treatment variable, and even a pre-treatment variable.”
Read the end of that sentence again. Even a pre-treatment variable. "I only adjusted for things measured before treatment" is a better rule than most analysts follow. It is still not a proof of safety. The structure decides, and you have to supply it.
A variable's role is something you have to bring to the data; the data will never tell you which way its arrows point.
Visual
Where every candidate variable actually belongs
This one is a table with a row for each variable you are tempted to include, and columns that decide its fate.
Baseline common causes were measured before treatment and push on both the treatment and the outcome. Those are the ones you want. Treatment descendants are anything the treatment could have changed, measured after it — birth weight in the smoking analysis lives here. Causes of the outcome that the treatment never touched are worth keeping for precision rather than for bias. Selection variables govern who is in the dataset at all; they often appear nowhere as columns, which is what makes them the easiest to forget. Measurement variables record how each of the others was captured, and how badly.
The row with no column has a number on it. UK Biobank invited approximately 9.2 million people. They were aged 40-69 and lived within 25 miles of one of 22 assessment centres in England, Wales and Scotland. 5.5% took part in the baseline assessment. Everything the cohort can ever say about anything passes through that 5.5%, and the number appears in no analysis file. What it did to the cohort is measurable. At ages 70-74, all-cause mortality was 46.2% lower in men and 55.5% lower in women than in the general population of the same age. Total cancer incidence was 11.8% and 18.1% lower respectively. The verdict, from a 2017 abstract in the American Journal of Epidemiology: “UK Biobank is not representative of the sampling population; there is evidence of a “healthy volunteer” selection bias.”
Work across a row twice. Once for the arrows, and once for what you would have to assume for that classification to hold. That second pass is what turns a modelling habit into a decision you can hand to someone who disagrees with you. And the selection row, the one with no column behind it, is the row that most needs the second pass written down.
Baseline common causes
Candidates for confounding control.
Treatment descendants
Potential mediators, adherence variables, or colliders.
Outcome causes
Useful for precision, but not necessarily confounders.
Selection variables
Determine inclusion, observation, or missingness.
Measurement variables
Represent constructs and may introduce common error.
Key idea
Post-treatment adjustment can mix several biases at once
Adjust for something the treatment itself caused and you are no longer measuring the treatment. This is not a recent worry and it is not a heuristic. Rosenbaum proved it in 1984: estimators that adjust for a variable measured after treatment are generally biased. He decomposed that bias into two interpretable components. One is present only in observational studies. The other is common to observational studies and randomised experiments. His summary states it without hedging: “Estimators that adjust for a concomitant variable that has been affected by the treatment are generally biased.”
The second of those two components is the one that ought to unsettle people. It survives randomisation. A clean experiment protects you from confounding and gives you nothing at all here.
Three things can go wrong, they can go wrong together, and none of them announces itself. You block part of the effect, because some of it travelled through that variable. You open a path that was closed: a variable caused by the treatment is usually caused by something else that also drives the outcome, and conditioning on it links those two. And you can end up comparing survivors, if the variable also decides who is still in the study when the outcome is measured.
The coefficient that comes back is then not the total effect, not the direct effect, and not an effect any policy could deliver. It is a number without a name for what it estimates.
And the evidence is often already inside the paper. Of those 75 experimental articles, 12% — 9 of 75 — conditioned on a variable that the article's own analyses showed had been affected by the treatment. The demonstration that the adjustment was invalid was printed in the same document as the adjustment.
Sometimes the post-treatment variable is the thing you genuinely care about — how much of the smoking effect runs through birth weight, say. The answer is still not to drop it into the regression. State which effect you want and how you want it decomposed. Then use methods built for confounding that itself changes over time.
Several distinct biases can arrive through one line of code, and the coefficient reports none of them separately.
Example
Four variables that are routinely filed under the wrong role
Domain labels are not roles. What settles the role is when the variable was measured and what produced it — the same two questions the map asks, applied to the cases where intuition tends to fail.
Selection on its own can hand you a result worth writing up. One simulation started from a reported protective association of smoking and assumed no causal effect at all. Griffith and colleagues published it in Nature Communications in 2020: “Calculating over this parameter space, 40% of all possible combinations lead to an artefactual 2-fold protective or risk association operating through this simple model of bias alone.” Under the null, from selection alone, four in ten parameter settings hand you a doubling or a halving to write up.
- Prior utilization reads like behaviour that follows from care. It usually sits before the treatment and pushes on both it and the outcome. That makes it exactly the kind of variable you want in the model.
- Adherence is measured after treatment starts, and it responds to how the patient is already doing. Adjusting for it quietly swaps the total effect for something much narrower — the case Rosenbaum's 1984 result covers exactly.
- Survey response can be caused both by the experience of treatment and by how severe the outcome was. Restricting the analysis to people who answered is conditioning on a collider. It runs in real data too. Of UK Biobank's 486,967 participants, only 1,410 had COVID-19 testing data after the April 2020 primary-care release. In a UK COVID-19 symptom-tracker app study, ACE-inhibitor users were about twice as likely to self-report COVID-19, yet “when estimating the association only amongst individuals tested for COVID-19 infection the direction of the effect reversed, and ACE-i use appeared mildly protective”.
- Clinician judgment genuinely confounds treatment. That is the awkward part, because it is also the variable least likely to be written down anywhere you could adjust for it.
Steps
Build the role table while the dataset is still being assembled
Classify the candidates before the analysis dataset is finalized, not after. By then the inclusions have already happened, and the table stops being a decision and becomes a justification for one.
That sequencing is not a stylistic preference, and in at least one field it is not optional. ICH E9(R1), the addendum on estimands and sensitivity analysis in clinical trials, was adopted on 20 November 2019. The EMA's CHMP adopted it on 30 January 2020, with effect from 30 July 2020. The FDA issued it as final guidance for industry in the Federal Register of 12 May 2021. It states the requirement in one sentence: “The targets of estimation are to be defined in advance of a clinical trial.” It also requires sponsors to say in advance how each intercurrent event will be handled. An intercurrent event is one that occurs after treatment initiation and affects the interpretation or the existence of the outcome measurement. That is the post-treatment variable problem, written into regulation, and answered before the data exist.
Write one row per variable. Record when it was measured relative to treatment, what you believe causes it, and what you believe it causes. The role follows from those two answers, and the decision follows from the role — adjust for it, leave it out, or handle it with a design built for the purpose. Where a colleague would classify it differently, put their answer in the row as well, and plan to fit that version too.
It is short work, and it does the one thing no model output can. It makes the assumptions visible before they are buried inside a coefficient, and it gives a reviewer something to argue with other than the number.
- 1
Record measurement time
Baseline, during treatment, or after outcome onset.
- 2
Name causal parents
What generates the variable?
- 3
Name causal children
What does the variable influence?
- 4
Relate to estimand
Total, direct, mediated, or per-protocol effect.
- 5
Choose handling
Adjust, stratify, model longitudinally, or avoid conditioning.
A defensible adjustment set is smaller than the feature table
Two kinds of variable earn a place. Pre-treatment common causes go in because leaving them out leaves a biasing path open. Pre-treatment predictors of the outcome go in because they tighten the estimate, and they are safe only so long as they open nothing new.
Everything downstream of the treatment stays out of a total-effect model: mediators, and anything a mediator caused. So do the variables that decide who entered the sample, unless the design was built to handle them.
The instinct this is arguing with is named in the opening line of the crash course on good and bad controls: “Researchers exposed only to this literature may get the impression that adding “more controls” to a regression model is always better.” Pearl and two co-authors answer it with a catalogue rather than a slogan. Eighteen numbered causal diagrams, Models 1-18, and the same candidate control variable Z classified across all of them as a Good Control, a Neutral Control or a Bad Control. The bad ones have names and numbers: M-bias at Model 7, bias amplification at Model 10, overcontrol bias at Models 11-12, selection bias at Models 16-17, case-control bias at Model 18. The same Z changes category when the assumed causal structure changes, and again when the target shifts from the total effect to the direct effect. Their conclusion is the whole lesson in a clause — “in all cases, structural knowledge is indispensable for deciding whether a variable is a good or bad control”.
Where experts disagree about a role, do not settle it privately. Write down both graphs, fit both adjustment sets, and report the two answers together. If they agree, the dispute never mattered. If they disagree, the disagreement is the finding.
The 35 articles counted at the start of this lesson failed at none of the usual places. The treatment was randomised, the data were clean, the models fit, the code ran. They failed at a decision taken before any of that, when a variable that carried the effect was treated as a variable that contaminated it.
Include everything is a reasonable instinct for prediction; borrowed for causal work it is a way of being confidently wrong.
Key takeaways
- Confounder, mediator and collider are not properties of a variable but positions in a causal structure. One candidate control variable Z needs eighteen separate diagrams to classify, because the same column changes category when the structure changes, or when the target shifts from the total to the direct effect.
- Adjusting for a mediator does not clean up the effect of the treatment. Rosenbaum showed in 1984 that estimators adjusting for a variable the treatment has affected are generally biased, and one of his two bias components is present in randomised experiments too.
- Conditioning on a common effect can create an association that was not there beforehand, including through who ends up in the sample at all. Stratifying US 1991 natality data on birth weight left mortality lower for infants born to smokers, relative rate = 0.79.
- Anything measured after treatment needs a stated target and usually a method built for it. In 75 experimental articles from three leading political science journals, 46.7% conditioned on post-treatment variables anyway, and 12% conditioned on a variable their own analyses showed the treatment had moved.
- How well a variable predicts the outcome tells you nothing about whether adjusting for it helps or harms the causal estimate. Elwert and Winship note that endogenous selection bias can be triggered even by a pre-treatment variable.
- A role table written before the dataset is frozen makes every inclusion decision auditable by someone who was not in the room. ICH E9(R1) makes that sequencing a regulatory requirement rather than a preference.