claude

Causal Inference Video Lectures

1.14. Causal Inference, Part 1 (MIT OpenCourseWare) slides

  1. 0:00Correlation does not imply causation
  2. 0:46Prediction vs. causation
    PredictiveCorrelation is enough. What causes what doesn't matter.
    CausalMost real questions are "what should we do?" Also holds up better when the data changes.
  3. 1:53Diabetes risk model

    A model predicts who will get diabetes in the next few years. Spotting it early isn't the goal. Preventing it is.

    Model seesPeople who had weight-loss surgery rarely got diabetes.
    We want to knowWould giving someone the surgery prevent diabetes? The model can't answer that.
  4. 3:49Cancer survival model

    A model predicts how long a cancer patient will live. Past patients may have lived long only because they were treated.

    Diagnosis
    →
    Got treated (model never sees this)
    →
    Lived long
    New patient
    →
    Model says: low risk
    →
    × Skip treatment
    Why not just add treatment to the model?Extra
    1. You can, but treatment isn't random. Doctors treat the sickest, so the model can learn "treatment is bad."
    2. Ask the model twice, treated and not treated, for the same patient. The gap decides.
  5. 6:13Guiding treatment choices

    People react differently to the same treatment, and past data follows today's rules.

    Past choices: David A, John B, Juana A
    →
    Model copies them
    →
    Matches them, mistakes and all. Never beats them.

    To do better, you have to ask a different question.

  6. 7:44Does smoking cause lung cancer?

    A trial would mean forcing people to smoke or quit. Not possible, not ethical. So we use real-world data, where people chose for themselves.

    Something else Smoking Lung cancer ?

    Comparing cancer rates of smokers vs. non-smokers mixes both paths.

    Notation
    P(lung cancer | smoker) − P(lung cancer | non-smoker)the naive comparison, misled by confounding
  7. 9:32A new setup
    Usual ML
    Input
    →
    Outcome
    Causal
    Input
    +
    Action
    →
    Outcome
  8. 10:18Not in the scope of this video: working out what causes what

    Some methods try to work out from data which way cause runs. With just two variables, the data fits both directions. Here we assume we already know.

    Example: police and crimeExtra
    Police Crime or Police Crime

    Cities with more police have more crime. Do police bring crime, or does crime bring police? The numbers alone fit both.

  9. 13:14Today's setup: arrows known, strength unknown Patient info Treatment Outcome how strong?

    Treatment never changes patient info.

    Notation
    X → T,  X → Y,  T → YX: patient info (can be huge), T: treatment, Y: outcome
    T ∈ {0, 1}today: two choices
  10. 14:10Cancer example in this setup
    Patient infoEverything known at diagnosis: scans, full medical record.
    TreatmentOne of two plans, picked once at diagnosis. Could also be a dose. Today: two choices.
  11. 15:45One decision, no switching
    Today
    Decide once
    →
    Treat
    →
    Outcome
    Next week
    Decide
    →
    See new info
    →
    Switch plan

    Next week's topic is called dynamic treatment regimes, also known as off-policy reinforcement learning.

  12. 16:49Today's two questions
    1Does the treatment do anything?
    2Who does it help most?
  13. 17:32Old questions, studied for decades
    EconomicsPolitical scienceStatisticsBiostatistics

    These fields often can't run experiments. Two examples:

    The FedWhat if rates go up 1%? No trial. Even a coin flip today wouldn't match two years from now, because the world changes.
    ElectionsDid foreign-backed Twitter posts change the result? You can't replay an election.
  14. 19:22A gap, and what's new

    Intro ML and CS courses skip these questions, which leaves a major hole.

    Old way
    Experts hand-pick 10 to 20 factors
    →
    Classic statistics
    Now
    Full records, images
    →
    Machine learning

    Old methods break with this much data. Today: one way to turn a causal question into an ML problem.

  15. 21:16Two possible worlds per person Person Not treated → Y0 (control outcome) Treated → Y1 (treated outcome)

    Called potential outcomes, from the Rubin-Neyman causal model. Also called the red pill (Y0) and the blue pill (Y1). Books write these in different notations, but they mean the same thing.

    Notation
    Y0(xi),  Y1(xi)control and treated outcome for person i
    Y0  =  Y(0)  =  Y | x, do(T = 0)three notations, same thing
  16. 22:28The effect: for one person, and on average
    Per person (CATE)Conditional Average Treatment Effect, also called the individual treatment effect. Gap between the two worlds for someone like this person.
    Average (ATE)Average Treatment Effect. That gap averaged over everyone.

    Both use expected results, because the same pill can work or fail by luck.

    Notation
    CATE(xi) = 𝔼[Y1 | xi] − 𝔼[Y0 | xi]per-person effect
    ATE = 𝔼[Y1 − Y0] = 𝔼x~p(x)[CATE(x)]average over everyone
  17. 24:33You only ever see one world
    Y0Y1
    Not treatedseen?
    Treated?seen
    factualcounterfactual, must be guessed

    Called the fundamental problem of causal inference. Each person gets one treatment, so you only ever see one of their two results. The other, the counterfactual, is never in the data and has to be guessed. Comparing people who got different treatments only works if they are alike, and the skew in who gets what usually means they aren't. Causal methods are ways to make that guess well.

    Notation
    yi = tiY1(xi) + (1 − ti)Y0(xi)factual: what we see
    yiCF = (1 − ti)Y1(xi) + tiY0(xi)counterfactual: never seen
  18. 25:46Blood pressure by age: the per-person effect ageblood pressure
    Y1 treatedY0 control

    Each arrow is the per-person effect (CATE) at that age. Big for the young and old, tiny for the middle-aged. If treatment were much cheaper, it could still make sense for the middle-aged.

  19. 27:53One rule for everyone: the average effect ageblood pressureATE

    Average each curve over everyone and take the gap: the average effect (ATE). A blanket rule like "all men over 50 get yearly screening" applies to everyone, so the ATE is the number that judges it: how much it changes outcomes across the whole group.

  20. 29:06What real data looks like ageblood pressure
    treatedcontrolwhat if (never seen)

    No curves, just scattered people. Control went mostly to the young, treatment mostly to the old, because of access, money or guidelines. That skew is the patient info → treatment arrow. Dots sit off the curves because of luck.

  21. 31:00Class exercise: blood sugar on drug A or B

    Question: is drug B better than A? Eight people each got one drug. Lower sugar is better. Each row has one seen result, and the other is never seen. The exercise answers the question two ways and compares them.

    1. NaiveAverage sugar of those who got B vs. those who got A. Uses only seen values.
    2. TrueAverage sugar of everyone on B vs. everyone on A. Needs the never-seen values.
    AgeSexExercisesGotOn A (Y0)On B (Y1)
    45FnoA6?
    45FyesB?6.5
    55MnoA7?
    55MyesB?8
    65FnoB?8
    65FyesA7.5?
    75MnoB?9
    75MyesA8?

    The never-seen values are made up for teaching, as if "a magical creature" revealed them. In real data you never have them.

  22. 33:34The naive comparison

    Average the seen sugar of people who got B, and of people who got A.

    Got B7.875
    Got A7.125
    B − A+0.75B looks worse
    Notation
    mean(sugar | got B) − mean(sugar | got A)  =  𝔼[Y | T = 1] − 𝔼[Y | T = 0]naive: compares different people
  23. 36:33The true answer flips it

    Average both full columns, using the never-seen values too.

    Everyone on B7.125
    Everyone on A7.875
    B − A−0.75B is better
    Naive +0.75 True −0.75 ← B better B worse →

    An insurer pays for drug B only if it lowers sugar across all its members, which is the true average effect. The naive gap points the other way.

    Naive
    B looks worse
    →
    × Don't cover B
    True
    B is better
    →
    ✓ Cover B
    Notation
    ATE = 𝔼[Y1] − 𝔼[Y0] = 7.125 − 7.875 = −0.75true: everyone under each drug
    𝔼[Y | T = 1] − 𝔼[Y | T = 0] = 7.875 − 7.125 = +0.75naive: different people in each group
  24. 38:52So how can we do anything?

    In real data the hidden values are missing, and who got what is skewed. In general this can't be solved. It takes strong assumptions. The first is SUTVA.

    What is SUTVA?Extra
    1. Stable Unit Treatment Value Assumption.
    2. One person's treatment doesn't change another person's outcome, and each treatment comes in only one version.
  25. 39:34Assumption 1 for estimating effects from records: no hidden confounders X: patient infoage, gender, weight,diet, resting heart rateT: drug A or BY0: BP after AY1: BP after B

    A confounder is anything that affects both which treatment a person got and how they do. This assumption says every confounder is in the data. Then, among people with the same patient info, who got which treatment is as good as random. Also called ignorability. Example: X is age, gender, weight, diet and resting heart rate. T is blood pressure medication A or B. Y0 and Y1 are blood pressure after A and after B.

    Why no arrow from T to Y0 or Y1?Extra

    A patient with high blood pressure and two medication options, A and B. The doctor gives B.

    Y0: blood pressure after Astays high
    Y1: blood pressure after Bdrops
    T: doctor gaveB
    Y: what you seedrops

    The drug's effect is the gap between Y0 and Y1. The doctor's choice can't change those two what-ifs. It only picks which one comes true, so T → Y, but not T → Y0 or Y1.

    Notation
    (Y0, Y1) ⫫ T | Xpotential outcomes independent of treatment, given X
  26. 41:00What breaks assumption 1: a hidden confounder X: patient infoage, gender, weight,diet, resting heart rateT: drug A or BY0: BP after AY1: BP after Bh: diabetic

    A factor h that is not in the data, here being diabetic, breaks the assumption only if it affects both the treatment choice and the results.

    Affects only the choice: OKDoctors may pick drugs differently by sex. If sex doesn't change how patients do on this disease, the comparison stays fair.
    Affects choice and result: brokenA guideline gives diabetics treatment 0, and diabetes also affects results, but diabetes isn't recorded. Treatment 0's results get mixed up with diabetes.
  27. 42:59How do you know you recorded everything?

    You can't tell from the data. Ask domain experts, like a doctor who treats high blood pressure: what drives your treatment decisions? Then check those factors are in the data. Expect some back and forth.

    MLMissing a variable: slightly worse accuracy.
    CausalMissing a confounder: conclusion can be completely wrong.

    Sensitivity analysis asks how much the conclusion would change if a hidden confounder of a given strength existed.

  28. 45:32Assumption 2 for estimating effects from records: common support (overlap)

    Every kind of patient must have some chance of getting each treatment. If nobody ever got B, there is no way to know what B would do. Violations invalidate every conclusion from the data.

    chance of getting treatment 1, given patient info OK: some chance of each 0 1 Blue hair: always gets treatment 0 so their treatment 1 result can't be learned

    That chance is the propensity score: for one kind of patient, the share who got treatment 1. It must never be 0 (nobody like them got it) or 1 (everybody like them got it).

    Propensity score exampleExtra
    1. 100 women aged 65 with diabetes: 30 got drug B, 70 got A. Their propensity score for B is 0.3. Fine.
    2. 100 people with blue hair: 0 got B. Score 0. Overlap fails for them.
    Notation
    p(T = t | X = x) > 0   for all t, xevery patient type can get every treatment
    ε < p(T = 1 | X = x) < 1 − εpropensity score kept away from 0 and 1
  29. 47:31Where real-world randomness comes from

    Overlap needs some randomness in who gets what. If strict guidelines always gave the same patient the same drug, overlap would fail. Two common sources of randomness:

    No consensusMetformin is the standard first diabetes drug. If it doesn't work, there are several second-line drug classes and no agreed best one. Doctors pick one and switch if it fails, so similar patients end up on different drugs.
    Different trainingEach doctor may follow fixed rules, but east coast and west coast training teach different defaults. Similar patients get different drugs depending on their doctor. Using this in an analysis is subtle but possible.
  30. 48:49Checking the two assumptions, back to the sugar example
    IgnorabilityCan't be checked. It is about factors that are not recorded, and data can't show what it doesn't contain.
    OverlapCan be checked. It only needs patient info and treatment, both recorded. For each kind of patient, look for similar people on each treatment.

    In the sugar table from 31:00, every patient type got only one drug. The 75-year-old man who exercises got A, and nobody with that profile got B, so overlap fails.

    Got AGot B
    45, F, exercises: no✓–
    45, F, exercises: yes–✓
    55, M, exercises: no✓–
    55, M, exercises: yes–✓
    65, F, exercises: no–✓
    65, F, exercises: yes✓–
    75, M, exercises: no–✓
    75, M, exercises: yes✓–

    With limited data it gets fuzzy: is a 74-year-old on B close enough?

  31. 51:50Class question: what if overlap fails?

    Healthy people never get any treatment. Should they be removed from the data? It depends on how the question is set up.

    Treated vs. not
    "No treatment" is itself a treatment
    →
    It can be the control group
    Drug A vs. B
    Set entry rules so everyone included could get either drug
    →
    The answer holds only for that group

    With entry rules, the policy has to shrink too: "the effect is X for this type of patient", not for everyone.

  32. 53:01The adjustment formula: turning the ATE into something data can answer

    The key tool for estimating the ATE from records. Also called the G-formula.

    1. Goal: average over everyone of (result on B − result on A).
    2. Split it up: first by kind of patient, then average within each kind.
    3. For each kind of patient, the what-if result on B equals the average result of similar people who actually got B.uses ignorability
    4. Same for A. Now every piece is an average of results you can see, for people like this one.

    Why it helps: the ATE needs what-if results nobody saw. Ignorability lets you swap each one for something you did see: the results of similar people who got that treatment. So you compare like with like inside each kind of patient, then average across kinds by how common each kind is in the whole population.

    Worked example: young vs. oldExtra

    Same setup as the sugar exercise. Treatment: diabetes drug A or drug B. Outcome: blood sugar afterward, lower is better. Half the population is young, half is old. Older people have higher sugar on either drug. Drug B went mostly to old people.

    Avg sugar, got BAvg sugar, got AB − AShare of population
    Young67−150%
    Old910−150%
    Naive+1.4B patients are mostly old, so B looks worse
    Adjustment formula−150% × (−1) + 50% × (−1)

    Naive math: if 90% of B patients are old and 90% of A patients are young, B averages 8.7 and A averages 7.3.

    Notation
    ATE := 𝔼[Y1 − Y0]goal
    𝔼[Y1] = 𝔼x~p(x)[ 𝔼[Y1 | x] ]law of total expectation
    = 𝔼x~p(x)[ 𝔼[Y1 | x, T = 1] ]ignorability
    ATE = 𝔼x~p(x)[ 𝔼[Y1 | x, T = 1] − 𝔼[Y0 | x, T = 0] ]adjustment formula
  33. 56:13The gaps: some people must be extrapolated

    The formula averages over everyone, so it needs both results for every kind of patient. With limited data, some kinds have nobody similar on the other treatment.

    Similar on ASimilar on BWhat-if
    Common type✓✓average
    Rare type✓noneguess

    Doesn't overlap guarantee similar people? Only with endless data. Real datasets are finite, so gaps remain.

    From here there are many ways to fill the gaps. The next method uses a model.

  34. 59:23The toolbox for filling the gaps
    Covariate adjustment: this lecturePropensity score reweighting: next lectureDoubly robust estimatorsMatching
  35. 59:47Covariate adjustment: let a model fill the gaps

    Also called response surface modeling. Train an ML model that predicts the result from patient info plus treatment. Then ask it what-if questions.

    Train
    Patient info + treatment they got
    →
    Model f
    →
    Their actual result
    Ask
    Same patient, set to B
    →
    Model f
    →
    Predicted result on B
    Ask
    Same patient, set to A
    →
    Model f
    →
    Predicted result on A

    Gap for each patient, averaged over everyone, is the estimated ATE. Variant: keep the real result for the treatment they got and predict only the other one. Both work.

    Why it works: the model learns how results depend on patient info, separately seeing people who got A and people who got B. Asking "what if this patient got B?" returns the average result of similar people on B, which is exactly what the adjustment formula needs. Treatment is just one more input column. This step turns causal inference into an ML problem.

    Real example: does job training raise earnings?Extra

    A 1970s US job training program (NSW) trained 185 people. A real randomized trial measured its effect on their 1978 earnings: +$1,794. Now pretend the trial's control group doesn't exist and compare the trainees with 15,992 people from a national survey (CPS) instead.

    X: age, education, race, married, degree, 1974 and 1975 earningsT: job trainingY: 1978 earnings
    TraineesSurvey people
    Avg age2633
    Avg 1975 earnings$1,532$13,651
    Trial (true answer)+$1,794Naive comparison−$8,498Linear model+$1,068Boosted trees+$973
    trialnaivecovariate adjustment

    The naive gap is far off because survey people earned much more to begin with. The models compare like with like and land near the trial. Gaps are averaged over the 185 trainees, the group the trial measured.

    Five trainees, boosted-trees model, 1978 earnings:

    AgeEduc1975ActualIf trainedIf notGap
    1910$6,057$0$6,460$7,430−$970
    2312$501$671$4,280$5,980−$1,700
    219$0$0$4,000$3,960+$40
    3711$0$9,930$5,990$1,490+$4,500
    2512$0$2,349$5,060$3,400+$1,660

    Gaps vary by person: these are per-person effects. A straight-line model gives everyone the same gap (+$1,068), so it can't show who benefits more.

    Averaged over all 16,177 people instead of the trainees, the boosted model says −$121. Most survey people look nothing like any trainee, so the model is guessing there. That is the overlap problem.

    Data: LaLonde (1986), Dehejia and Wahba sample, CPS controls, via the causaldata package.

    Notation
    f(x, t) ≈ 𝔼[Yt | T = t, x]fit by (regularized) empirical risk minimization
    ATÊ = 1⁄n ∑i [ f(xi, 1) − f(xi, 0) ]average gap over the n people
  36. 1:02:57Per-person effects come for free

    Each patient's gap, predicted B minus predicted A, is their estimated CATE. This fills in the arrows chart from 25:46. Use it to decide per patient: treat if the gap is good enough, for example above a threshold that covers cost.

    Notation
    CATÊ(xi) = f(xi, 1) − f(xi, 0)per-person estimate
  37. 1:03:51Class question: is the model biased, like the pneumonia paper?

    An earlier course reading predicted outcomes for pneumonia patients in the ER from patient info alone. Asthma patients looked lower risk, because they got more intensive care. The model never included treatment and never asked what-if questions, yet was meant to guide choices like sending someone home.

    Paper
    Patient info only
    →
    Risk
    →
    × Asthma looks safe
    This method
    Patient info + treatment
    →
    Result per treatment
    →
    ✓ Treatment accounted for

    Same trap as the cancer example at 3:49.

  38. 1:06:35Class question: is treatment recorded in hospital data?

    In ICU data like MIMIC, a lot. For sepsis, an infection-driven condition, antibiotics, fluids, blood-pressure drugs and ventilators are all recorded. Most ICU questions involve a sequence of treatments that react to the patient, which is next week's topic.

  39. 1:07:41Class question: how do you know the model learned the treatment's effect?

    You don't, and it may not have. Treatment can be one weak input among many strong ones. With limited data and regularization (L1, L2, early stopping), the model can drop treatment entirely and predict from patient info alone.

    Prediction errorStill low. Looks like a good model.
    Effect estimateZero, or badly wrong.

    In causal work treatment is special. The slides call patient info nuisance parameters and treatment the parameter of interest: the point is how the result changes when you change it, not how well you predict. Matters most with many inputs and complex models like deep nets. An active research area.

    Real demo: regularization drops the treatmentExtra

    Same job-training data. A linear model with L1 regularization, three strengths. Trial answer: +$1,794.

    Prediction errorEstimated effect
    Light$6,991+$1,056
    Medium$6,994+$423
    Strong$6,997$0, treatment dropped

    Prediction error barely moves ($6 out of ~$7,000). The effect estimate collapses to zero.

  40. 1:11:46Where overlap shows up in covariate adjustment

    For a patient who got B, the method needs the model's prediction on A. If nobody even remotely similar got A, the model still outputs a number, but it is "garbage".

    Need
    Prediction on A for this patient
    →
    Nobody similar got A
    →
    × Garbage

    With overlap, more data eventually brings similar people on both treatments, so the model can learn the right answer. Real data is finite, though. When a model can extrapolate correctly with thin overlap is barely studied, and an opening for computer scientists.

    This answers the challenge from 45:32: ignorability is used in the adjustment formula's step 3, and overlap shows up here.

  41. 1:15:35Class question: does a wrong model shape still work?

    No. If the true curves bend and the model is a straight line, more data never fixes it. The model family must be flexible enough, and grow more flexible as data grows.

  42. 1:16:48What no overlap looks like ageblood pressuretrue gap: treated higherfitted: treated lower, wrong sign
    treated: data and fitted linecontrol: data and fitted linetrue curves

    Young people only got control and old people only got treatment. A straight line is the best fit to each group, and with no data on the other side nothing reveals it is wrong. Extended to the young, the lines cross: the model's per-person effect for a 25-year-old has the wrong sign.

  43. 1:18:03Next lecture

    If the true what-if results are straight lines, the coefficients of a linear model can be read as causal effects. A very strong assumption.

2.15. Causal Inference, Part 2 (MIT OpenCourseWare, 2020 Zoom recording) slides

  1. 0:21Recap of Part 1 X: patient T: treatment Y: outcome all confounders,high-dimensionale.g. medication,procedure ?

    The data is observational. Doctors already chose who got treated, with no coin flip.

    Y0: control outcomeThe result if the person is not treated.
    Y1: treated outcomeThe result if the person is treated.
    Per person (CATE)Conditional Average Treatment Effect. The gap Y1 − Y0 for someone like this person.
    Average (ATE)Average Treatment Effect. That gap averaged over everyone, treated or not.

    Each outcome is an average. The same treatment can work on one try and fail on the next.

    Notation
    CATE(xi) = 𝔼[Y1 | xi] − 𝔼[Y0 | xi]gap for one person
    ATE = 𝔼x∼p(x)[CATE(x)]p(x) is everyone in the data
  2. 3:25Class exercise: causal questions about COVID-19

    Name causal questions the pandemic needs answered, framed as X, T and Y.

    X: general population T: an action Y: outcome e.g. socialdistancing ?
    Still holdsCovariate adjustment: fit a model, predict both outcomes. It still needs common support.
    New problemNetwork effects. When some people distance and others don't, the effect on society is very different.

    5:19 This breaks SUTVA, the Stable Unit Treatment Value Assumption: each person in the data is independent of the others.

    Medication
    Patient takes a drug
    →
    Only their outcome changes
    Distancing
    Some people distance
    →
    Everyone's outcome changes

    Such questions need a different class of models that relax SUTVA. 6:04 Questions about how to treat COVID patients can only now be answered, because data is starting to come in.

  3. 6:39Simpson's paradox: COVID death rates in Italy and China

    The share of confirmed cases who died, the case fatality rate (CFR), was 4.3% in Italy and 2.3% in China. Is care in China better? Is the virus different?

    0%4%8%12%16%0-910-1920-2930-3940-4950-593.6%2.5%60-698%6.4%70-7914.8%13.2%80+2.3%4.3%All agesage group
    China, Feb 17Italy, Mar 9

    Split by age, Italy is lower in every group. The overall numbers point the other way. This is Simpson's paradox.

    8:32 The reason: the two groups of patients are very different. Italy's cases skew much older.

    0%6%12%18%24%0-910-1920-2930-3940-4922.4%17.4%50-5960-698.8%21.4%70-793.2%18.4%80+age group
    China, Feb 17Italy, Mar 9

    Simplified, for teaching only. Chart from slide 5. Data from von Kügelgen et al. (2020), Tables III and IV.

  4. 9:07The paradox as a causal graph

    X is a patient's age. T is the country: the action is "moving" a patient from China to Italy. Y is whether they died. Question: what does changing the country do to Y?

    Drawn in lecture X: age T: country Y: died or not ? Better: country sets age mix X: age T: country Y: died or not ?

    The country decides the age mix of its patients, not the other way around. The same methods still apply, because both graphs look the same in observational data.

  5. 10:57Recap: covariate adjustment

    Fit any machine learning model f on patient features x plus the treatment T, to predict the outcome y.

    patient featuresregression modeloutcomex₁x₂⋮xdTf(x, T)y
    One patient
    →
    Model's guess with the drug
    −
    Model's guess without it

    The difference is the drug's effect for that patient. This only works if every reason behind who got treated is in the data. Then treated patients show what the drug does, and untreated patients show what happens without it.

    Notation
    CATE(x) = 𝔼[Y1 | T = 1, x] − 𝔼[Y0 | T = 0, x]holds under ignorability
    f(x, t) ≈ 𝔼[Yt | T = t, x]the fitted model
    CATÊ(xi) = f(xi, 1) − f(xi, 0)the estimate
  6. 13:16If the truth is a straight line, the effect is one number

    13:30“A major difference in philosophy between machine learning and statistics.”

    Which model to fit for f matters a lot. This is a major difference between machine learning and statistics, and between prediction and causal inference.

    13:43 Assume the true model is linear, with one feature (age) and no age × drug term:

    Truth
    Blood pressure
    =
    β × age
    +
    γ × drug (0 or 1)

    Noise is added too, and averages to zero.

    Drug
    β × age
    +
    γ
    +
    noise
    No drug
    β × age
    +
    noise
    Gap
    γ

    The age term cancels and the noise averages out. CATE is γ for everyone, so ATE is γ too.

    9011013015020406080age (x)blood pressureY₀: no drugY₁: drugγγγ

    16:41 So if you fit a model of exactly this form, read the effect straight off the fitted drug coefficient. No plugging in needed. This only works because we assumed the truth is linear.

    Chart: the slide 9 model drawn with made-up numbers.

    Notation
    Yt(x) = βx + γ·t + εt,   𝔼[εt] = 0assumed truth
    CATE(x) = 𝔼[(βx + γ + ε1) − (βx + ε0)] = γβx cancels
    ATE = 𝔼p(x)[CATE(x)] = γsame for everyone
  7. 17:42Reading the drug coefficient

    19:09“In machine learning I typically tell my students: don't attempt to interpret your coefficients.”

    If the fitted γ is off, the effect estimates are off too.

    18:03 Class question: what does γ mean for the drug?

    γ > 0The drug raises blood pressure.
    γ < 0The drug lowers blood pressure.

    19:09 This explains a split between two fields:

    Machine learningDon't read much into coefficients. With many features, they overlap.
    StatisticsRead coefficients as effects. Valid when the outcome is a straight line in the treatment.

    For causal inference you need γ right, not the predictions. The slide calls this identification, not prediction.

    20:12 With a new sample of 100 patients, the fitted γ would change. A 95% confidence interval for γ is also one for the average effect.

    -14-12-10-8-6-4-2fitted drug coefficient (true γ = −8)95% interval: -11.1 to -4.9

    Chart: simulation, 300 new samples of 100 patients each.

  8. 21:12If the truth curves, a straight line can flip the answer

    23:35“This should scare you. If you're making the wrong assumptions about the true potential outcomes, you could get very, very wrong conclusions.”

    Add one curved age term to the truth. The drug effect is still exactly γ for everyone. You don't know about the curve, so you fit a straight line anyway.

    Truth
    β × age
    +
    δ × age²
    +
    γ × drug
    Fitted
    fitted β × age
    +
    missing
    +
    fitted γ × drug
    20406080ageblood pressurefit: drug +14fit: no drugtruth: drug −10
    no drug (mostly younger)drug (mostly older)true curves

    Even with endless data, the fitted coefficient is γ plus δ times a term from the age and treatment data. A large δ can turn a drug that lowers blood pressure into one that seems to raise it.

    23:35 This is what makes covariate adjustment dangerous: wrong assumptions about the shape give very wrong conclusions. So you want models that make few assumptions, such as neural networks or random forests, which can fit the curve.

    Chart: the slide 12 model with made-up numbers. Shown with the fit from endless data; the dots are one sample of 80.

    Does a wrong shape always cause this?Extra
    1. No. The error needs two things together: a missed curve, and treated and untreated patients with different ages.
    2. If the drug were given at random, both groups would have the same age mix. The missed curve would hit both equally and cancel.
    3. This is why simple models are safer in randomized trials than in observational data.
    Notation
    Yt(x) = βx + γ·t + δ·x²,   ATE = 𝔼[Y1 − Y0] = γtrue process
    Ŷt(x) = β̂x + γ̂·tfitted model
    γ̂ = γ + δ · (term from x and t only)does not depend on β or γ
  9. 24:19Flexible models that can fit curves

    Many machine learning methods have been used for causal inference:

    Random forestsBayesian additive regression treesGaussian processesNeural networks

    24:34 Gaussian processes, two ways to set them up:

    SeparateOne model for the treated outcome, one for the untreated outcome.
    JointOne model, with treatment as one more input next to the patient features.

    25:18 Neural networks, the design from his group:

    X…Φ……f₀f₁guess without the drugguess with the drugpatientfeaturessharedrepresentationshared layersone head per treatment

    Only the patient features go into the first layers. The shared part learns from treated and untreated patients together. Each treatment then gets its own head. This worked much better than simpler designs on several benchmark datasets.

    Diagram from slide 15. Shalit, Johansson, Sontag, ICML 2017.

  10. 27:06Matching: find each person's twin

    27:37“It actually is precisely identical to covariate adjustment.”

    For each person, find a near-identical "twin" who got the other treatment. The twin's outcome stands in for the outcome we never see. It works for both the per-person and the average effect.

    It looks unrelated to covariate adjustment. He will show it is the same thing, with one particular kind of model.

    Seen
    Obama: law school
    →
    became president
    Twin
    Someone just like him: business school
    →
    president?

    The twin's outcome answers "what if he had gone to business school?" A made-up example: no dataset is that big.

  11. 29:06Matching in a picture

    32:32“It's used all the time in clinical research, despite the fact that biostatisticians have been trying to argue that folks should not use this technique.”

    Two patient features: age, and a score for how many other conditions they have, such as diabetes or high blood pressure. Outcomes are not shown. Each treated patient borrows the outcome of the closest untreated one.

    agecomorbidity scoreno close twinbad guessmatched pair
    treateduntreated

    30:50 Class questions:

    Twin is far away?The guess will be bad. Matching needs lots of data and common support. It does not work well with many features.
    Can one person be matched twice?Yes.
    Used in medicine?All the time in clinical research, though statisticians have argued against it for years.

    Chart redrawn from slide 18, plus the far-away point he describes.

  12. 33:02Matching, step by step
    1. Pick a way to measure the distance between two patients.
    2. For each person, find the closest person who got the other treatment.
    3. Per-person effect: treated outcome minus untreated outcome. One comes from the person, the other from the twin.
    4. Average the per-person effects over everyone to get the average effect.

    35:06 One person can be the closest twin for several others.

    one twin,used twiceothers far away
    Notation
    j(i) = argminj : tj ≠ ti d(xj, xi)closest person with the other treatment
    CATÊ(xi) = (2ti − 1)(yi − yj(i))2t − 1 flips the sign for untreated people
    ATÊ = (1/n) Σi CATÊ(xi)average over everyone
  13. 36:38Matching: what's good and what's not

    Class question: should closer twins count more? Yes, that works. He says there are a few hundred papers on variants like it.

    37:39 Matching is easy to check:

    Claim
    John's closest twin is Anna
    →
    Anna got the other treatment
    →
    so this is John's effect
    Check
    A doctor looks at the pair
    →
    "These two are very different"
    →
    Reject the result
    GoodEasy to explain. Makes no assumption about the shape of the outcome.
    Not goodOnly as good as the distance measure. Features that don't affect the outcome can mislead it.
  14. 39:40Matching is covariate adjustment

    42:19“Think about matching just as another type of covariate adjustment.”

    Use a nearest-neighbor model as the f inside covariate adjustment:

    If treated
    Guess
    =
    outcome of the closest treated person
    If not
    Guess
    =
    outcome of the closest untreated person
    Little dataThe nearest-neighbor model is biased, so the effect estimate can be biased too.
    Lots of dataThe bias goes to zero. Known machine learning results then carry over to matching.

    So compare matching with other covariate adjustment models, such as models built to be easy to read.

    Notation
    Ŷ1(x) = yNN1(x),   Ŷ0(x) = yNN0(x)NNt(x): nearest neighbor among people with treatment t
    1-NN matching is in general inconsistent, with small biasImbens (2004), slide 21
  15. 42:49Propensity scores: make the data look like a trial

    44:19“The key idea of a propensity score method is to turn an observational study into something that looks like a randomized controlled trial.”

    A second, different way to estimate the average effect. In a randomized trial, a coin decides treatment, and the estimate is simple:

    Average outcome, treated
    −
    Average outcome, untreated
    =
    Average effect, unbiased

    With observational data, reweight people until the groups look like they came from a coin flip.

    Notation
    ATÊ = (1/n1) Σti=1 yi − (1/n0) Σti=0 yirandomized trial only; n1, n0 = group sizes
  16. 44:49Reweighting in a picture

    Only features and treatment are shown, no outcomes. Young people mostly went untreated. Older people mostly got treated.

    comorbidity scoreBefore: the mixes differageAfter: rare cases weigh moreage
    treateduntreated

    45:20 Give each dot a weight. A treated person among mostly untreated people counts for more, and the reverse. Then in every region, treated and untreated weigh about the same.

    Chart: made-up data, dot size shows the weight. Slides 23 and 24 show the same idea.

    Notation
    p(x | t=0) ≠ p(x | t=1)before
    p(x | t=0) · w0(x) ≈ p(x | t=1) · w1(x)after weighting
  17. 46:51The propensity score method

    The propensity score is each person's chance of being treated, given their features. Learn it with any model, such as logistic regression. Ignore the outcome: here the label is the treatment.

    1. Predict treatment from features. This gives each person's chance of treatment.
    2. Weight each person by 1 ÷ their chance of getting the treatment they actually got.
    3. Average effect = weighted average of treated outcomes minus weighted average of untreated outcomes.

    47:34 This is the same idea as dataset shift from lecture 10.

    48:36 The chances must be real probabilities, not just a yes/no guess. Deep neural networks are often poorly calibrated, so they need a calibration fix first.

    Notation
    p̂(T = 1 | x)propensity score, from any ML model
    ATÊ = (1/n) Σti=1 yi / p̂(ti=1 | xi) − (1/n) Σti=0 yi / p̂(ti=0 | xi)inverse probability of treatment weighting (IPW)
  18. 50:07Sanity check: a randomized trial

    In a coin-flip trial, everyone's chance of treatment is 0.5. No machine learning needed. Plug it in:

    Chance = 0.5
    →
    Weight = 2
    →
    Each group has about n/2 people

    So 2/n is about 1 ÷ (group size), and the formula becomes the plain trial estimate: treated average minus untreated average.

    52:19 Class question: is the propensity score the bias in who gets treated? Yes. Dividing by it removes that bias.

    Notation
    ATÊ = (1/n) Σti=1 yi/0.5 − (1/n) Σti=0 yi/0.5plug in 0.5
    = (2/n) Σti=1 yi − (2/n) Σti=0 yieach sum has about n/2 terms
  19. 53:22Why the weighting works
    We wantThe treated outcome averaged over everyone.
    We haveThe treated outcome averaged over the treated only. A different mix of people.

    54:54 Same problem as dataset shift: we need an average over a different group than the one we have.

    Mix of the treated
    ×
    share treated ÷ person's chance
    =
    Mix of everyone

    57:29 Estimate the share treated as n1/n, and plug in the propensity score for the chance. That gives the formula. The untreated half works the same way.

    He assumes outcomes have no noise here, to keep the math simple.

    Notation
    ATE = 𝔼x∼p(x)[Y1(x)] − 𝔼x∼p(x)[Y0(x)]want
    𝔼x∼p(x|T=1)[Y1(x)]have, naively
    p(x | T=1) · p(T=1) / p(T=1 | x) = p(x)Bayes rule
    𝔼x∼p(x|T=1)[ p(T=1) / p(T=1 | x) · Y1(x) ] = 𝔼x∼p(x)[Y1(x)]so the weight fixes the mix
    (1/n1) Σti=1 (n1/n) yi / p̂(ti=1 | xi) = (1/n) Σti=1 yi / p̂(ti=1 | xi)from data
  20. 58:00Pros and cons of propensity scores

    58:27“We never had to use a model to predict y.”

    GoodNo outcome model, so the wrong-shape trap from 21:12 can't happen.
    Not goodWeak overlap makes some chances close to 0 or 1. Their weights explode, and the estimate swings a lot.
    051015202500.250.50.751chance of the treatment the person gotweightclipped at 0.05: weight capped at 20chance 0.1 → weight 101.0 → 1

    59:15 A common fix is clipping: keep every chance away from 0 and 1. It is only a rule of thumb, and it can bias the estimate.

    59:33 Doubly robust estimators combine covariate adjustment and propensity scores. If either one is wrong, the estimate is still valid.

    Chart: weight = 1 ÷ chance. The 0.05 clip is an example value.

  21. 1:00:03Summary

    1:00:08“Both of these, I need to stress, are only going to give you valid results under the assumptions.”

    Covariate adjustmentModel the outcome, then predict both worlds.
    Propensity scoresModel the treatment, then reweight.
    1. Right causal graphThe arrows are correct.
    2. No hidden confoundersEvery reason behind who got treated is in the data.
    3. OverlapBoth treatments appear for every kind of patient.

    1:00:36 Without overlap, both break:

    Covariate adjustmentThe model has no data in some regions. You can't check its guesses there, only trust them.
    Propensity scoresSome weights become infinite, and the estimate swings wildly.

    1:01:21 The last slides list two recent ML workshops, two free causal inference books, and papers worth reading for course projects.