Introduction to causal inference using Double Machine Learning

Kaixin Wang14 Jan 2025

Problem

A product team ships five new features and wants to know whether using any of them raises overall product usage. Users pick features themselves, so a raw comparison of users and non-users mixes the feature effect with device and account differences. A plain linear regression breaks down when there are many controls, the controls act non-linearly, or the effect differs between subgroups.

Example from the article: a dataset of about 1.3 million rows, one per device, with the number of days the product was used in the last month as the outcome and five feature-usage flags as treatments.

Solution in brief

First find which variables are confounders by drawing a causal graph. Then fit double machine learning (DML): one model predicts the treatment from the confounders, another predicts the outcome, and the effect is the regression of outcome residuals on treatment residuals. EconML's LinearDML does this and returns the effect, p-value and confidence interval.

Questions this case answers
  • How to estimate the causal effect of a self-selected exposure on an outcome from observational data when the controls are many or non-linear
  • How to choose which variables to adjust for before estimating a treatment effect without randomization
  • How to estimate whether using a product feature increases overall product usage when users chose the feature themselves
  • How to pick the confounders to control for before estimating a treatment effect from observational data

Tools and methods

  • Double machine learning (DML) — estimates the average treatment effect after removing what the confounders explain in both treatment and outcome
  • Causal discovery with lingam — builds an adjacency matrix of the variables to see which ones influence both treatment and outcome
  • EconML LinearDML — DML with a linear final step; gives coefficient, p-value and confidence interval
  • Random forest (scikit-learn) — classifier for the treatment, regressor for the outcome
Continue reading — it's free

Google or a one-time email code. No password.