Causal inference · Module 4: Machines and causes, in depth

Double machine learning, step by step

How does double machine learning work?

4.1 · 3 min 58 s · published

Two nuisance models do the cleaning: one predicts which fields get the treatment from their background, the other predicts the outcome from the same background, and the leftovers are compared. The method is built so the two models’ errors matter only when multiplied together, and cross-fitting stops any model being judged on data it has memorised.

Key points

  • Any flexible method can be a nuisance model: random forests, boosted trees or neural networks.
  • Orthogonality: if each model is only modestly wrong, their product is small and the answer barely moves.
  • Cross-fitting trains models on some groups of fields and predicts the rest, rotating until every field is covered.
  • Three assumptions remain: no unmeasured confounding, overlap, and a well-defined treatment.

Chapters

  1. 0:00 Recap: time zero
  2. 0:25 Where we left it
  3. 0:51 The cleaning crew
  4. 1:26 Two small errors make a tiny one
  5. 2:09 No marking your own homework
  6. 2:35 What no machinery removes

Key terms

Double machine learning
A method that uses two nuisance models: one predicts the treatment from the background, the other the outcome, and the leftovers, or residuals, are compared. It is built so the models’ errors matter only when multiplied, a property called orthogonality, and uses cross-fitting. It still assumes no unmeasured confounding.
Cross-fitting
Splitting the data into groups, training a model on all but one, predicting the one left out, and rotating until every unit has a prediction from a model that never saw it. A model judged on data it has memorised looks far better than it is, and cross-fitting stops that flattery leaking into the answer.
Overlap
The assumption that every kind of unit had some chance of getting either treatment. If the best fields always got the extra pass of nitrogen, there are no comparable fields without it, and no method can supply the missing comparison.

Transcript

Module 3's last quick check: time zero is the moment everyone's clock starts, when each unit becomes eligible and the treatment decision is made. Starting everyone at the same moment stops you comparing long-term users with newcomers. In the prologue we met double machine learning on a nitrogen question.

One model predicts how much nitrogen each field got from its background; another predicts its protein from the same background; then the leftovers are compared. Today we look under the bonnet: what each part does, and what it quietly assumes. The two prediction models have an unflattering name: nuisance models. They aren't the answer; they're the cleaning. Model 1 learns which kinds of field tend to get the extra nitrogen. Model 2 learns how the background predicts protein.

Any flexible machine-learning method can do the job: random forests, boosted trees, neural networks. Nothing in the final answer depends on reading their insides, only on how well they predict. Machine-learning predictions are never perfect, and their errors tend to lean one way: they pull extreme cases towards the middle. Plug them into an ordinary analysis, and that lean biases the answer.

Double machine learning is built so that the final estimate depends on the two models' errors only when they're multiplied together. If each model is only modestly wrong, their product is small, and the answer barely moves. The property has a forbidding name, orthogonality, but the idea is simple: two small errors multiplied make a tiny one.

The second safeguard is cross-fitting. Split the fields into, say, five groups. Train the models on four, predict the fifth, and rotate until every field has a prediction from models that never saw it. A model judged on data it has memorised looks far better than it is, and that flattery would leak into the answer.

Three assumptions remain, whatever the machinery. First, no unmeasured confounding: every common cause of nitrogen and protein is in the data. Second, overlap: every kind of field had some chance of getting either treatment. If the best fields always got the extra pass, there's nothing to compare them with.

Third, a well-defined treatment: an "extra pass" can't mean a different product, rate and timing on every farm. Free implementations of double machine learning exist in Python and R. The judgement about those three assumptions doesn't come with them. Next: who benefits? Methods that find where an effect is bigger or smaller.

Questions

What assumptions does double machine learning still need?

Three, whatever the machinery. No unmeasured confounding: every common cause of treatment and outcome is in the data. Overlap: every kind of field had some chance of getting either treatment. And a well-defined treatment: an “extra pass” can’t mean a different product, rate and timing on every farm. Free software implements the method; the judgement doesn’t come with it.

What does overlap mean?

Every kind of unit must have had some chance of getting either treatment. If the best fields always got the extra pass of nitrogen, there are no comparable fields without it, so there is nothing to compare them with, and no method can supply the missing comparison.

Sources

  1. Chernozhukov, V., Chetverikov, D., Demirer, M. et al. (2018). Double/debiased machine learning for treatment and structural parameters. The Econometrics Journal, 21(1), C1–C68. doi:10.1111/ectj.12097

All 30 films · Glossary · The Vitagri Academy

Follow the change in farming

Causal evidence is changing how farming is measured and rewarded. Leave your email and we will tell you when new films, courses and findings are published.

Prefer to read online? Vitagri also writes on Substack. See our privacy policy for how we use your email.