Math for Causal Inference

Day 31. The Rubin Causal Model & Potential Outcomes

Units, treatments and potential outcomes; the science table; and why the assignment mechanism decides what the data can tell you.

Video coming soon
Learning outcomes
  • ●Write a science table and compute unit-level and average treatment effects.
  • ●Derive the observed-outcome identity Y = Y(0) + T·(Y(1) − Y(0)).
  • ●Prove that complete randomisation makes the difference in means unbiased for the finite-population ATE.
  • ●Distinguish well-defined from ill-defined treatments, and finite- from super-population estimands.
2-HOUR SESSION PLAN
Theory 25′Warm-up (1–5) 20′Proofs (6–10) 35′Applied (11–15) 25′Python & Lab 15′
Colab notebook (.ipynb) Jump to the simulator

Theory

Potential outcomes

Phase 1 and 2 gave you the tools; Phase 3 gives them a causal meaning. The Rubin causal model (Neyman 1923, Rubin 1974) starts from three ingredients:

  • Units i=1,…,ni = 1, \dots, n: workers, households, patients, villages.
  • A treatment Ti∈{0,1}T_i \in \{0, 1\}: training or not, a cash transfer or not.
  • Potential outcomes Yi(1)Y_i(1) and Yi(0)Y_i(0): what unit ii's outcome would be under each treatment, both defined before treatment is assigned.

The unit-level causal effect is τi=Yi(1)−Yi(0)\tau_i = Y_i(1) - Y_i(0). Collected in one table, the potential outcomes and covariates of all units form the science table: everything there is to know about the causal question.

The observed outcome

We only ever see the outcome under the treatment actually received:

Yi=TiYi(1)+(1−Ti)Yi(0)=Yi(0)+Tiτi.Y_i = T_iY_i(1) + (1 - T_i)Y_i(0) = Y_i(0) + T_i\tau_i.

For every unit, one potential outcome is observed and the other is missing: the fundamental problem of causal inference (Holland 1986). Causal inference is therefore a missing-data problem (Day 14).

Estimands

For a fixed set of nn units, the finite-population ATE is

τfp=1n∑i=1n(Yi(1)−Yi(0))=Yˉ(1)−Yˉ(0).\tau_{fp} = \frac1n\sum_{i=1}^n\big(Y_i(1) - Y_i(0)\big) = \bar Y(1) - \bar Y(0).

If the units are a random sample from a larger population, the super-population ATE is E[Y(1)−Y(0)]E[Y(1) - Y(0)]. Day 33 adds ATT, ATC and CATE.

The assignment mechanism

The assignment mechanism is the rule that decides who gets treated: P(T1,…,Tn∣science table)P(T_1, \dots, T_n \mid \text{science table}). It is the crux of every design:

  • In a randomised experiment the researcher controls it and it does not depend on potential outcomes.
  • In an observational study people (or officials) choose, often based on what they expect to gain.

With complete randomisation, exactly n1n_1 of nn units are treated and each of the (nn1)\binom{n}{n_1} assignments is equally likely. Then the difference in means τ^=Yˉ1−Yˉ0\hat\tau = \bar Y_1 - \bar Y_0 is unbiased for τfp\tau_{fp} (Exercise 8).

What counts as a treatment

"No causation without manipulation" (Holland): Y(1)Y(1) must be well defined. "The effect of a job-training voucher" is; "the effect of being obese" is not, because there are many ways to change weight (diet, exercise, surgery) with different consequences. Day 32 formalises this as SUTVA.

Part 1 · Warm-up

Four unemployed workers' annual earnings (in $1,000) with and without a training programme:

WorkerY(0)Y(0)Y(1)Y(1)
A1014
B1212
C813
D1515

Exercise 1 · Unit and average effects

Compute each worker's effect and the finite-population ATE.

Show solution

Step 1. Unit effects τi=Yi(1)−Yi(0)\tau_i = Y_i(1) - Y_i(0): A =4= 4, B =0= 0, C =5= 5, D =0= 0.

Step 2. ATE =(4+0+5+0)/4=2.25= (4 + 0 + 5 + 0)/4 = 2.25.

Answer: training raises earnings by $2,250 on average, but only two of the four workers gain at all.

Exercise 2 · What the data show

Workers A and C are trained (T=(1,0,1,0)T = (1, 0, 1, 0)). Write the observed outcomes and compute the difference in means.

Show solution

Step 1. Observed outcomes: A and C show Y(1)Y(1), B and D show Y(0)Y(0): Y=(14,12,13,15)Y = (14, 12, 13, 15).

Step 2. Treated mean (14+13)/2=13.5(14 + 13)/2 = 13.5; control mean (12+15)/2=13.5(12 + 15)/2 = 13.5.

Answer: the difference is 0, although the ATE is 2.25. One assignment can give a misleading answer.

Exercise 3 · The observed-outcome identity

Check Y=Y(0)+TτY = Y(0) + T\tau for workers A and B.

Show solution

Step 1. A: 10+1×4=1410 + 1 \times 4 = 14 ✓ (observed Y(1)Y(1)).

Step 2. B: 12+0×0=1212 + 0 \times 0 = 12 ✓ (observed Y(0)Y(0)).

Exercise 4 · The missing half

For the assignment in Exercise 2, which entries of the science table are observed and which are missing?

Show solution

Step 1. Observed: YA(1),YB(0),YC(1),YD(0)Y_A(1), Y_B(0), Y_C(1), Y_D(0).

Step 2. Missing: YA(0),YB(1),YC(0),YD(1)Y_A(0), Y_B(1), Y_C(0), Y_D(1).

Answer: exactly half the table is missing, and every unit-level effect needs one missing value.

Exercise 5 · Counting assignments

How many assignments treat exactly 2 of the 4 workers?

Show solution

Step 1. Choose 2 of 4: (42)=4!2! 2!=6\binom42 = \frac{4!}{2!\,2!} = 6.

Answer: 6 equally likely assignments under complete randomisation.

Part 2 · Proofs

Exercise 6 · The observed-outcome identity

Prove TiYi(1)+(1−Ti)Yi(0)=Yi(0)+TiτiT_iY_i(1) + (1 - T_i)Y_i(0) = Y_i(0) + T_i\tau_i.

Show solution

Step 1. Expand the left side: TiYi(1)+Yi(0)−TiYi(0)T_iY_i(1) + Y_i(0) - T_iY_i(0).

Step 2. Group the terms with TiT_i: Yi(0)+Ti(Yi(1)−Yi(0))=Yi(0)+TiτiY_i(0) + T_i\big(Y_i(1) - Y_i(0)\big) = Y_i(0) + T_i\tau_i. ■\blacksquare

Exercise 7 · ATE as a difference of means

Prove τfp=Yˉ(1)−Yˉ(0)\tau_{fp} = \bar Y(1) - \bar Y(0).

Show solution

Step 1. τfp=1n∑i(Yi(1)−Yi(0))\tau_{fp} = \frac1n\sum_i(Y_i(1) - Y_i(0)).

Step 2. Split the sum (linearity): 1n∑iYi(1)−1n∑iYi(0)=Yˉ(1)−Yˉ(0)\frac1n\sum_iY_i(1) - \frac1n\sum_iY_i(0) = \bar Y(1) - \bar Y(0). ■\blacksquare

So we never need individual effects to learn the ATE, only the two means.

Exercise 8 · Complete randomisation is unbiased

Under complete randomisation with n1n_1 treated, prove E[Yˉ1−Yˉ0]=τfpE[\bar Y_1 - \bar Y_0] = \tau_{fp}, where the expectation is over assignments and the science table is fixed.

Show solution

Step 1. Write the treated mean with indicators: Yˉ1=1n1∑iTiYi(1)\bar Y_1 = \frac{1}{n_1}\sum_iT_iY_i(1) (for treated units the observed outcome is Yi(1)Y_i(1)).

Step 2. Only TiT_i is random, and by symmetry E[Ti]=P(Ti=1)=n1/nE[T_i] = P(T_i = 1) = n_1/n.

Step 3. So E[Yˉ1]=1n1∑in1nYi(1)=Yˉ(1)E[\bar Y_1] = \frac{1}{n_1}\sum_i\frac{n_1}{n}Y_i(1) = \bar Y(1).

Step 4. Likewise Yˉ0=1n0∑i(1−Ti)Yi(0)\bar Y_0 = \frac{1}{n_0}\sum_i(1 - T_i)Y_i(0) and E[Yˉ0]=Yˉ(0)E[\bar Y_0] = \bar Y(0).

Step 5. Linearity and Exercise 7: E[Yˉ1−Yˉ0]=Yˉ(1)−Yˉ(0)=τfpE[\bar Y_1 - \bar Y_0] = \bar Y(1) - \bar Y(0) = \tau_{fp}. ■\blacksquare

Exercise 9 · Unit effects are not identified

Construct a second science table for workers A–D that produces exactly the same observed data as Exercise 2 but has a different ATE.

Show solution

Step 1. Keep the observed entries fixed: YA(1)=14Y_A(1) = 14, YB(0)=12Y_B(0) = 12, YC(1)=13Y_C(1) = 13, YD(0)=15Y_D(0) = 15.

Step 2. Change the missing entries, e.g. YA(0)=14Y_A(0) = 14, YB(1)=20Y_B(1) = 20, YC(0)=13Y_C(0) = 13, YD(1)=15Y_D(1) = 15.

Step 3. New effects: 0, 8, 0, 0, so ATE =2= 2 instead of 2.25.

Answer: both tables fit the data perfectly. Without assumptions on the assignment mechanism, the data cannot distinguish them.

Exercise 10 · Post-treatment variables have potential values too

A training programme may change whether a worker moves city, MM. Explain why MM has potential values M(1),M(0)M(1), M(0), and why comparing trained and untrained workers who did not move is not a causal comparison.

Show solution

Step 1. Moving happens after assignment and can be affected by it, so each worker has Mi(1)M_i(1) and Mi(0)M_i(0).

Step 2. "Trained non-movers" are workers with Mi(1)=0M_i(1) = 0; "untrained non-movers" have Mi(0)=0M_i(0) = 0. These are generally different sets of people.

Answer: the comparison mixes the effect of training with differences between two selected groups. Only pre-treatment covariates (fixed before assignment) can be conditioned on safely; this is the "bad control" problem of Day 53.

Part 3 · Applied

Exercise 11 · Every possible experiment

For the training science table, compute the difference in means for all 6 assignments with 2 trained workers, and verify that their average equals the ATE.

Show solution

Step 1. For each pair treated, compare the treated workers' Y(1)Y(1) with the others' Y(0)Y(0):

TrainedTreated meanControl meanτ^\hat\tau
A, B(14+12)/2=13(14 + 12)/2 = 13(8+15)/2=11.5(8 + 15)/2 = 11.51.5
A, C13.513.50
A, D14.5104.5
B, C12.512.50
B, D13.594.5
C, D14113

Step 2. Average: (1.5+0+4.5+0+4.5+3)/6=13.5/6=2.25(1.5 + 0 + 4.5 + 0 + 4.5 + 3)/6 = 13.5/6 = 2.25.

Answer: exactly the ATE, as Exercise 8 promised, even though individual experiments range from 0 to 4.5. Unbiasedness is a property of the design, not of one realised experiment.

Exercise 12 · Workers who choose

Now suppose workers know their gains and enrol only if they gain (A and C). Compute the difference in means and compare with the ATT.

Show solution

Step 1. Same observed data as Exercise 2: difference in means =0= 0.

Step 2. ATT == average effect among enrollees A and C =(4+5)/2=4.5= (4 + 5)/2 = 4.5.

Step 3. Why the gap: enrollees would have earned less without training (Y(0)Y(0): 10 and 8) than non-enrollees (12 and 15), so the comparison is contaminated by selection bias =YˉA,C(0)−YˉB,D(0)=9−13.5=−4.5= \bar Y_{A,C}(0) - \bar Y_{B,D}(0) = 9 - 13.5 = -4.5.

Answer: naive 0 = ATT 4.5 + selection bias (−4.5). Self-selection can hide a large effect completely (Day 34).

Exercise 13 · Is the treatment well defined?

A ministry asks: "What is the effect of obesity on annual health-care costs?" Explain why this is ill-posed in the potential-outcomes framework, and reformulate it as a well-defined question.

Show solution

Step 1. Yi(not obese)Y_i(\text{not obese}) is ambiguous: losing weight through exercise, diet, medication or surgery would change costs differently.

Step 2. So "the" counterfactual is not unique: SUTVA's "no hidden versions" fails (Day 32).

Step 3. A well-defined version names a manipulable intervention, e.g. "the effect on costs of offering a 12-month subsidised gym membership" or "of a sugar-sweetened-beverage tax".

Answer: causal questions need a specific intervention; the reformulation also matches what a policymaker can actually do.

Exercise 14 · Finite or super population?

An evaluation studies all 120 municipalities of a province, randomising a governance reform. Another samples 2,000 households at random from a country and randomises a cash transfer. Which estimand is natural in each case?

Show solution

Step 1. The 120 municipalities are the population of interest; uncertainty comes only from which ones were assigned the reform: the finite-population ATE is natural.

Step 2. The 2,000 households stand in for millions; uncertainty comes from sampling and assignment: the super-population ATE is natural.

Answer: finite-population for the municipalities, super-population for the households. Day 36 shows the two lead to slightly different variance formulas.

Exercise 15 · Who does a vaccine help?

Six people are classified by their potential infection outcomes: 1 "doomed" (Y(0)=Y(1)=1Y(0) = Y(1) = 1), 2 "helped" (Y(0)=1Y(0) = 1, Y(1)=0Y(1) = 0), 3 "immune" (Y(0)=Y(1)=0Y(0) = Y(1) = 0). Compute the infection rate with and without the vaccine and the ATE. Could a trial reveal the number helped?

Show solution

Step 1. Without the vaccine, infected = doomed + helped = 3 of 6: Yˉ(0)=0.5\bar Y(0) = 0.5.

Step 2. With the vaccine, infected = doomed = 1 of 6: Yˉ(1)≈0.167\bar Y(1) \approx 0.167.

Step 3. ATE =0.167−0.5≈−0.333= 0.167 - 0.5 \approx -0.333: the vaccine cuts the infection rate by a third of the population.

Step 4. A trial identifies the two rates, hence the ATE. But a fourth type, "hurt" (Y(0)=0Y(0) = 0, Y(1)=1Y(1) = 1), would also be possible: 3 helped and 1 hurt give the same rates as 2 helped and 0 hurt.

Answer: ATE = −1/3. The share helped equals −ATE only if nobody is hurt (a monotonicity assumption); the data alone cannot tell.

Verify in Python

import itertools
import numpy as np

y0 = np.array([10, 12, 8, 15.]); y1 = np.array([14, 12, 13, 15.])
print("unit effects:", y1 - y0, " ATE:", (y1 - y0).mean())

ests = []
for treated in itertools.combinations(range(4), 2):
    T = np.zeros(4, bool); T[list(treated)] = True
    Y = np.where(T, y1, y0)                         # observed outcomes
    ests.append(Y[T].mean() - Y[~T].mean())
    print("treated", [("ABCD")[i] for i in treated], "estimate", ests[-1])
print("average over all assignments:", np.mean(ests), "(= ATE)")
print("variance across assignments:", round(np.var(ests), 4))

# Self-selection (Exercise 12)
T = (y1 - y0) > 0; Y = np.where(T, y1, y0)
print("self-selected comparison:", Y[T].mean() - Y[~T].mean(), " ATT:", (y1 - y0)[T].mean())

Key takeaways

  • A causal effect compares two potential outcomes of the same unit; only one is ever observed.
  • The assignment mechanism decides whether observed comparisons recover causal effects.
  • Complete randomisation makes the difference in means unbiased for the ATE, averaging over all possible assignments.

Simulation Lab: The Science Table

Open full screen →

Twelve workers with both potential outcomes: hide the missing half, randomise, and watch estimates centre on the ATE.

workerTY(0)Y(1)effectobserved Y
A1?14?14
B013??13
C1?8?8
D011??11
E1?9?9
F016??16
G010??10
H08??8
I1?13?13
J1?13?13
K1?11?11
L011??11
true ATE
1.17
hidden in practice
true ATT
1.50
treated workers only
difference in means
-0.17
what the data show
-4-20246difference in means across experimentsRun experiments to build the distribution of estimates
0 experiments; average estimate — versus ATE 1.167.

Twelve workers' earnings without (Y0) and with (Y1) training, in $1,000. In real data only one column per worker is visible; the other is '?'. Random assignment gives estimates that scatter around the ATE; self-selection (enrol if the gain exceeds 2) does not.

Day 30Day 32