Causal Inference, Part 1: Potential Outcomes, Confounding and Propensity Scores
After this lesson, you will be able to:
- Articulate the fundamental problem of causal inference — that you only ever observe one of two potential outcomes per unit — and use the Rubin potential-outcomes framework to define ATE, ATT, and CATE precisely
- Recognize the three pillars of identification (unconfoundedness, overlap/positivity, SUTVA) and explain how a confounder, a collider, and a mediator each play a different role in a DAG
- Choose between a randomized trial, regression adjustment and propensity-score methods (matching, IPW, stratification), and justify the choice from the data, not the vibes
- Simulate a confounded dataset where a naive comparison is biased, then recover the true effect with regression adjustment and inverse probability weighting
Before you start
In plain words: a causal question asks what would have happened if we had done something different. We can never see both versions for one person, because Ana either took the drug or did not. So every method in this lesson finds other people to stand in for the missing version, and then checks that those people are comparable. Most of the work is in that check.
The thing we want to know the effect of: a coupon, a drug, a new button. In this lesson it is either given (1) or not given (0).
What we measure afterwards: renewed or not, days to recover, purchase made.
What would have happened to the same person under the other choice. It is never observed.
The outcome a person would have under one particular choice. Each person has two, Y(1) and Y(0), and we see only one.
Average treatment effect: the average of Y(1) minus Y(0) over everyone, which is the effect of treating the whole population.
A common cause of both the treatment and the outcome, such as age for smoking and cancer. Ignoring it makes the comparison unfair.
A variable that both the treatment and the outcome cause. Adjusting for it creates a false link between them.
Every kind of person has some chance of being treated and some chance of not being treated. Without it there is nobody to compare.
The probability that a person with given characteristics receives the treatment.
An experiment where a coin flip decides who is treated, so the two groups are comparable by construction.
#War Story: The Spurious Coupon
retention ~ coupon will happily measure their correlation; a causal estimate of "what would happen if we sent everyone a coupon?" requires accounting for the confounder. That is the entire subject of this lesson.#The Fundamental Problem of Causal Inference
#The Rubin Potential Outcomes Framework
i and a binary treatment T ∈ {0, 1}, we postulate two potential outcomes:Y_i(1)— what would happen to unitiif treatedY_i(0)— what would happen to unitiif not treated
The observed outcome is then:
Y_i(1) - Y_i(0) is therefore never observable for any single unit. But aggregates of it are estimable, under assumptions.#The Three Estimands You Will See in the Wild
| Estimand | Population averaged over | Typical use |
|---|---|---|
| ATE | Everyone | Roll-out / policy decisions |
| ATT | Those who were treated | Program evaluation |
| ATU | Those who were untreated | Counterfactual policy |
| CATE / ITE | Subgroups defined by X | Personalization, targeting |
A pharma company runs a trial of a new diabetes drug. The trial enrolled only patients with HbA1c > 9% (severe). The trial estimates an ATE of -1.4 percentage points reduction. Marketing wants to claim that the drug 'reduces HbA1c by 1.4 points on average for diabetic patients.' What is the most important caveat?
#The Three Identifying Assumptions
Any causal estimate from observational data rests on three assumptions. Drop one and your estimate is statistics-flavored fiction.
#1. Unconfoundedness (Ignorability)
(Y(0), Y(1)) ⊥ T | X — given the observed covariates X, the potential outcomes are independent of the treatment assignment. Said differently: once you condition on X, the treatment looks "as if random."T and Y is missing from X, your estimate is confounded no matter how fancy your estimator.#2. Overlap (Positivity)
0 < P(T = 1 | X = x) < 1 for every x in the population. For every covariate profile, there must be at least some chance of being treated and at least some chance of not being treated. Otherwise, you have no comparable controls (or no comparable treated) for that profile, and the counterfactual is genuinely unidentified.is_premium_customer perfectly predicts who gets the coupon (P(T=1 | premium) = 1), there is no way to learn what would happen to a premium customer who didn't get one. The data carries no evidence.#3. SUTVA (Stable Unit Treatment Value Assumption)
Interference is the big one and is violated all over the place: network effects (vaccinating Ana protects Ben), marketplace spillovers (a discount to one seller cannibalizes another), peer effects in classrooms. Whenever SUTVA is implausible, you need cluster randomization, marketplace experiments, or specialized estimators.
A social network runs an experiment where 50% of users randomly see a new 'reactions' button. After 4 weeks, treated users post 12% more. The team plans to ship it. What is the most defensible critique?
#DAGs, Confounders, Colliders, and Mediators
age (W)
/ \
v v
smoking (T) ---> cancer (Y)
age causes both smoking (older cohorts smoked more) and cancer (older bodies, more cancer). age is a confounder — it shares an arrow into both T and Y. To estimate the causal effect of smoking on cancer, you must adjust for age, otherwise the smoking coefficient will absorb age's contribution.But there is a trap. Consider:
smoking (T) ---> hospital admission (S) <--- car accident (Y)
hospital admission is a collider — both T and Y point into it. Conditioning on (filtering by, or adjusting for) a collider opens a spurious path between T and Y. If you condition on S, you will find a spurious correlation between smoking and car accidents that does not exist in the population at large. This is collider bias, also called Berkson's bias.#From the Graph to a Formula: Backdoor Adjustment and Collider Bias
The two rules above (adjust for confounders, never for colliders) are results, not conventions. The next two derivations prove them in the smallest cases: first that adjusting for the confounder W in the age, smoking, cancer graph gives the effect of an intervention, then that conditioning on a collider manufactures a correlation.
Researchers want to estimate the causal effect of smoking on lung cancer. They have data on smoking status, lung cancer diagnosis, age, sex, occupation, AND a 'lung function test' (FEV1) measured 10 years after smoking initiation. Which variables should they adjust for?
#Approach 1: Randomized Controlled Trials (RCT)
T ⊥ (Y(0), Y(1)) by construction (no confounders, observed or unobserved), and the simple difference of group means is an unbiased estimator of ATE:RCTs are the gold standard. A/B testing at tech companies is just RCT-at-scale, and the entire field of online experimentation is downstream of this. The catch: many treatments cannot be randomized (you cannot randomly assign smoking, or income, or which school a child attends). That is where the rest of this lesson lives.
Why does a plain difference of group means estimate a quantity defined with outcomes we never see? Open the derivation to see the two ingredients: the observed outcome is one of the potential outcomes, and the coin flip makes the groups comparable.
#Approach 2: Regression Adjustment (G-Computation)
Y ~ T + X and read off the coefficient on T. If the model form is correct and you have included all confounders, that coefficient is the ATE.mu(t, x) is misspecified (wrong functional form, missing interactions), the estimate is biased. Linear regression assumes a constant treatment effect across X; if effects are heterogeneous, that constant is a weighted average that may not equal the ATE.Why is averaging fitted outcome gaps over X the ATE? Open the derivation. It spends unconfoundedness and overlap from the section above, plus consistency (the observed outcome is the potential outcome of the treatment received, which SUTVA makes meaningful), and shows exactly where each is used.
#Approach 3: Propensity Score Methods
e(x) = P(T = 1 | X = x) — the probability of receiving treatment given the covariates. Rosenbaum & Rubin proved in 1983 that, under unconfoundedness, conditioning on the scalar e(x) is sufficient to remove confounding. You do not need to condition on the full X vector. This collapses a high-dimensional adjustment problem into a one-dimensional one.Why is the one-number score enough? The derivation shows that e(X) already balances the covariates, so once you condition on it nothing about X can still link treatment to the outcomes.
#3a. Matching
e(x), and compute the average difference in outcomes across matched pairs. Clean conceptually; brittle when overlap is poor; loses data for unmatched units.#3b. Inverse Probability Weighting (IPW)
Re-weight each unit by the inverse of its probability of receiving the treatment it actually received. The weighted sample then mimics a randomized experiment:
e(x) = 0.01 gets weight 100, and one outlier can swing the estimate badly. The fix is propensity trimming, clipping, or stabilized weights.Why does reweighting by 1 over the propensity give the ATE? Open the derivation to see the weight cancel the treatment probability exactly.
#3c. Stratification
Bin units into 5 (or so) strata by propensity score, compute the treated-minus-control difference inside each stratum, and average across strata weighted by stratum size. Crude but robust; the standard default in older epidemiology papers.
You estimate propensity scores for an ad-lift study. In the treated group (saw the ad), 30% of users have e(x) > 0.95. In the control group (did not see the ad), 25% have e(x) < 0.05. What is the right move?
#Key Takeaways
- The fundamental problem of causal inference is missing data. You observe at most one of
Y(1)andY(0)per unit; every estimator is a recipe for imputing the missing potential outcome using comparable other units, under assumptions you cannot test from the data alone - Three assumptions buy you identification. Unconfoundedness (no hidden common causes), overlap (every covariate profile has some treated and some untreated units), and SUTVA (no interference, one version of treatment). Lose one and the estimate is no longer causal
- Propensity scores collapse the adjustment problem to one dimension. IPW, matching, and stratification all work because Rosenbaum & Rubin showed that conditioning on
e(x)is sufficient under unconfoundedness; the catch is that you need overlap and the propensity model has to be roughly right - The most common production mistake is adjusting for the wrong variable. Colliders and post-treatment variables (mediators) flip causal estimates more often than missing confounders do. Draw the DAG first; for every candidate adjuster, verify it was measured before treatment and is not caused by treatment
#Quick Check
Which of these does NOT belong in a list of valid pre-treatment confounders to adjust for in an observational study of 'did the loyalty program raise spend?'