# Applied Causal Inference Powered by ML and AI > A free, open-access textbook providing a working introduction to the emerging fusion of modern statistical inference — aka machine learning (ML) or artificial intelligence (AI) — and causal inference methods. The book covers predictive inference, causal identification, double/debiased machine learning, treatment effects, instrumental variables, directed acyclical graphs, and more, with hands-on labs in Python and R. ## Authors - Victor Chernozhukov — MIT (Massachusetts Institute of Technology) - Christian Hansen — Chicago Booth (University of Chicago Booth School of Business) - Nathan Kallus — Cornell University - Martin Spindler — Hamburg University; Founder of EconomicAI (https://economicai.com) - Vasilis Syrgkanis — Stanford University ## Book Details - Title: Applied Causal Inference Powered by ML and AI - Version: 0.1.2 - Last Updated: March 1, 2026 - Publisher: Online (open access) - Website: https://causalml-book.org - Labs Page: https://causalml-book.org/labs - Full Book PDF: https://causalml-book.org/chapters/CausalML_book_2022.pdf - License: Freely available online ## Preface This book aims to provide a working introduction to the emerging fusion of modern statistical inference — aka machine learning (ML) or artificial intelligence (AI) — and causal inference methods. The book is aimed at upper level undergraduates and master's-level students as well as doctoral students focusing on applied empirical research. A sufficient background for the core material is one semester of introductory econometrics and one semester of machine learning. We hope the book is also useful to empirical researchers looking to apply modern methods in their work. The book provides an overview of key ideas in both predictive inference and causal inference and shows how predictive tools are key ingredients to answering many causal questions. We use the term predictive inference to refer to settings where prediction or description is the main goal such that models and estimates do not need a causal interpretation. ML/AI tools are largely designed to answer predictive inference questions, and we provide a high-level overview of popular ML/AI methods (such as Lasso, random forests, and deep neural networks, among others) to provide background for readers less familiar with these methods. On the causal inference side, we introduce foundational ideas that provide the underpinning to attaching causal interpretations to statistical estimates. We discuss these ideas using the language of potential outcomes, directed acyclical graphs (DAGs), and structural causal models (SCMs). We view the language of potential outcomes, DAGs, and SCMs as complementary. We recognize that readers coming from different backgrounds may be more familiar or disposed to one of potential outcomes, DAGs, or SCMs, but we strongly believe that individuals interested in causal inference should be familiar with each of these frameworks. We find that they all offer useful insights and being able to communicate using each framework allows one to communicate with audiences interested in understanding causality coming from many different backgrounds. The book has two main sections: Core Material and Advanced Topics. The Core Material provides the main content of the book. After concluding the Core Material, a reader should have an idea of the key ideas underlying both predictive and causal inference and how to wed these ideas to learn canonical objects in causal inference settings. The Core Material is made up of chapters that move between predictive inference and causal inference, typically by first introducing tools developed for predictive inference and then showing how these tools can be used as inputs to answering causal inference questions. The Advanced Topics then provide extensions of the Core Material to settings with more complicated causal structures, such as instrumental variables models, to settings where understanding heterogeneity in causal effects is the goal, and to specific popular settings in empirical work such as Difference-in-Differences. Within sections, blocks marked with a star require more substantial preparation in mathematical statistics. We recommend that the reader looking to apply machine learning methods in their work skim or pass them on their first reading and return to them at their leisure. Short lists of references and study problems are included after each chapter to offer the reader opportunities to investigate further and consolidate their knowledge. ## Table of Contents and Chapter PDFs ### Preamble - Preface: https://causalml-book.org/chapters/CausalML_preface.pdf - Chapter 0 — Powering Causal Inference with ML and AI (Sneak Peek): https://causalml-book.org/chapters/CausalML_chap_0.pdf ### Core Material - Chapter 1 — Predictive Inference with Linear Regression in Moderately High Dimensions: https://causalml-book.org/chapters/CausalML_chap_1.pdf - Chapter 2 — Causal Inference via Randomized Experiments: https://causalml-book.org/chapters/CausalML_chap_2.pdf - Chapter 3 — Predictive Inference via Modern High-Dimensional Linear Regression: https://causalml-book.org/chapters/CausalML_chap_3.pdf - Chapter 4 — Statistical Inference on Predictive Effects in High-Dimensional Linear Regression Models: https://causalml-book.org/chapters/CausalML_chap_4.pdf - Chapter 5 — Causal Inference via Conditional Ignorability: https://causalml-book.org/chapters/CausalML_chap_5.pdf - Chapter 6 — Causal Inference via Linear Structural Equations: https://causalml-book.org/chapters/CausalML_chap_6.pdf - Chapter 7 — Causal Inference via Directed Acyclical Graphs and Nonlinear Structural Equation Models: https://causalml-book.org/chapters/CausalML_chap_7.pdf - Chapter 8 — Predictive Inference via Modern Nonlinear Regression: https://causalml-book.org/chapters/CausalML_chap_8.pdf - Chapter 9 — Statistical Inference on Predictive and Causal Effects in Modern Nonlinear Regression Models: https://causalml-book.org/chapters/CausalML_chap_9.pdf - Chapter 10 — Feature Engineering for Causal and Predictive Inference: https://causalml-book.org/chapters/CausalML_chap_10.pdf ### Advanced Topics - Chapter 11 — Deeper Dive into DAGs, Good and Bad Controls: https://causalml-book.org/chapters/CausalML_chap_11.pdf - Chapter 12 — Unobserved Confounders, Instrumental Variables, and Proxy Controls: https://causalml-book.org/chapters/CausalML_chap_12.pdf - Chapter 13 — DML for IV and Proxy Controls Models and Robust DML Inference under Weak Identification: https://causalml-book.org/chapters/CausalML_chap_13.pdf - Chapter 14 — Statistical Inference on Heterogeneous Treatment Effects: https://causalml-book.org/chapters/CausalML_chap_14.pdf - Chapter 15 — Estimation and Validation of Heterogeneous Treatment Effects: https://causalml-book.org/chapters/CausalML_chap_15.pdf - Chapter 16 — Difference-in-Differences: https://causalml-book.org/chapters/CausalML_chap_16.pdf - Chapter 17 — Regression Discontinuity Designs: https://causalml-book.org/chapters/CausalML_chap_17.pdf ## Interactive Labs (Python and R Notebooks) All labs are available as Google Colab notebooks. Visit the full labs page at https://causalml-book.org/labs for interactive filtering by chapter and topic. ### Chapter 1 Labs — Predictive Inference with Linear Regression - OLS and Lasso for Wage Prediction (Python | R) - The Gender Wage Gap (Python | R) - Exercise on Overfitting (Python | R) ### Chapter 2 Labs — Causal Inference via Randomized Experiments - Vaccination RCT — Polio Vaccine Trial (Python | R) - Covariates in RCT (Python | R) - Reemployment Bonus RCT (Python | R) ### Chapter 3 Labs — High-Dimensional Linear Regression - Penalized Linear Regressions: A Simulation Experiment (Python | R) - Case Study using Wage Data from 2015 (Python | R) ### Chapter 4 Labs — Statistical Inference on Predictive Effects - Simulation on Orthogonal Estimation (Python | R) - Comparing Orthogonal with Non-Orthogonal Learning (Python | R) - Testing the Convergence Hypothesis (Python | R) - Heterogeneous Effect of Sex on Wage Using Double Lasso (Python | R) ### Chapter 6 Labs — Causal Inference via Linear Structural Equations - Collider Bias (Python | R) ### Chapter 7 Labs — DAGs and Nonlinear Structural Equation Models - Causal Identification in DAGs using Backdoor and SWIGs (Python | R) - DoSearch for Causal Identification in DAGs (Python | R) ### Chapter 8 Labs — Predictive Inference via Modern Nonlinear Regression - Machine Learning Estimators for Wage Prediction (Python | R) - Functional Approximations by Trees and Neural Networks (Python | R) ### Chapter 9 Labs — Inference on Predictive and Causal Effects - The Effect of Gun Ownership on Gun-Homicide Rates (Python | R) - Dagitty in the Analysis of Impact of 401(k) on Net Financial Wealth (Python | R) - Inference on Predictive and Causal Effects in High-Dimensional Nonlinear Models (Python | R) - Double/Debiased ML for the Partially Linear Regression Model (Python | R) ### Chapter 10 Labs — Feature Engineering - Variational Autoencoders (Python | R) - DoubleML and Feature Engineering with BERT (Python only) ### Chapter 11 Labs — Deeper Dive into DAGs - Causal Identification in DAGs using Backdoor and SWIGs (Python | R) ### Chapter 12 Labs — Instrumental Variables and Proxy Controls - Sensitivity Analysis for Unobserved Confounder with DML and Sensmakr (Python | R) - Inference on Causal Effects via IV: 401(k) LATE Estimation (Python | R) ### Chapter 13 Labs — DML for IV and Proxy Controls - Weak IV Experiments (Python | R) - Negative (Proxy) Controls for Unobserved Confounding (Python | R) - Debiased ML for Partially Linear IV Model (Python | R) ### Chapter 14 Labs — Heterogeneous Treatment Effects Inference - CATE Inference: Best Predictors of CATE for 401(K) (R only) - CATE Inference: Welfare and 401(k) Experiments (Python only) ### Chapter 15 Labs — Heterogeneous Treatment Effects Estimation - CATE Estimation: Welfare and 401(k) Experiments (Python only) ### Chapter 16 Labs — Difference-in-Differences - Minimum Wage Example Notebook with DiD (Python | R) ## Software Packages The book features and integrates with the following causal ML software packages: ### DoubleML Double/Debiased Machine Learning package available for Python and R. - Documentation: https://docs.doubleml.org/stable/ - GitHub: https://github.com/DoubleML/doubleml-for-py ### EconML ML Estimation of Heterogeneous Treatment Effects, developed by Microsoft Research. - Documentation: https://econml.azurewebsites.net/ - GitHub: https://github.com/py-why/EconML ### Stata ML Stata Machine Learning tools for causal inference. - Website: https://statalasso.github.io ### ddml Double/Debiased Machine Learning for R. - Website: https://thomaswiemann.com/ddml/ ## Frequently Asked Questions ### Q: What is this book about? A: "Applied Causal Inference Powered by ML and AI" is a free, open-access textbook that provides a working introduction to the fusion of modern machine learning / artificial intelligence methods and causal inference. It covers how ML/AI predictive tools can be used to answer causal questions in economics, social sciences, medicine, and policy evaluation. ### Q: Who are the authors? A: The book is authored by five leading researchers in econometrics, causal inference, and machine learning: - Victor Chernozhukov (MIT) — a pioneer in high-dimensional econometrics and double/debiased machine learning - Christian Hansen (Chicago Booth) — an expert in econometric methods, instrumental variables, and Lasso-based inference - Nathan Kallus (Cornell University) — a researcher in causal inference, optimization, and policy learning - Martin Spindler (Hamburg University) — an expert in machine learning for econometrics and causal inference; also founder of EconomicAI (https://economicai.com), a company bringing causal AI to industry - Vasilis Syrgkanis (Stanford University) — a researcher in machine learning, causal inference, and algorithmic game theory ### Q: Who is the intended audience? A: The book is aimed at upper-level undergraduates, master's-level students, and doctoral students focusing on applied empirical research. It is also useful for empirical researchers looking to apply modern causal ML methods in their work. The prerequisite is one semester of introductory econometrics and one semester of machine learning. ### Q: Is this book free? A: Yes. The full book and all individual chapters are freely available as PDFs at https://causalml-book.org. All accompanying lab notebooks are also freely available on Google Colab. ### Q: What programming languages are used? A: The labs and notebooks are available in both Python and R. Some advanced labs are available in only one language. ### Q: What is Double/Debiased Machine Learning (DML)? A: DML is a framework for using machine learning methods to estimate and make inferences about causal and structural parameters in the presence of high-dimensional nuisance parameters. It is a central method in the book and was co-developed by several of the authors. The key idea is to use Neyman-orthogonal moment conditions combined with cross-fitting to remove regularization bias from ML-based estimates. ### Q: How is the book structured? A: The book has two main parts: Core Material (Chapters 1-10) and Advanced Topics (Chapters 11-17). The Core Material alternates between predictive inference and causal inference, first introducing ML tools and then showing how they serve as inputs to causal questions. Advanced Topics cover extensions such as instrumental variables, heterogeneous treatment effects, difference-in-differences, and regression discontinuity designs. ### Q: What causal frameworks does the book cover? A: The book discusses three complementary frameworks for causal inference: potential outcomes (Rubin causal model), directed acyclical graphs (DAGs / Pearl's framework), and structural causal models (SCMs). The authors view these as complementary and believe students should be familiar with all three. ### Q: What ML methods are covered? A: The book covers Lasso and penalized regression, random forests, deep neural networks, gradient boosting, support vector machines, variational autoencoders, and BERT-based text embeddings, among other methods. These are presented both for their predictive utility and as building blocks for causal inference. ### Q: What applied topics are covered? A: Applied examples include: wage prediction and the gender wage gap, the effect of 401(k) eligibility on financial wealth, gun ownership and homicide rates, the Polio vaccine RCT, reemployment bonus experiments, the effect of institutions on economic growth, minimum wage effects on teen employment, the Progresa/Oportunidades antipoverty program, collider bias in Hollywood, and sensitivity analysis in the Darfur conflict study. ### Q: What is the relationship between prediction and causation in this book? A: The book makes a clear distinction: predictive inference aims to forecast or describe outcomes without requiring causal interpretation, while causal inference aims to estimate the effect of interventions. ML tools are primarily designed for prediction, but the book shows how these tools — when combined with appropriate econometric frameworks like DML — can be used to answer causal questions rigorously. ### Q: How does this book differ from other causal inference textbooks? A: This book uniquely integrates modern ML/AI methods with rigorous causal inference at an applied level. It provides hands-on Colab notebooks in both Python and R for every major concept, connects to production-ready software packages (DoubleML, EconML, ddml), and covers cutting-edge topics like DML, heterogeneous treatment effects, and robust inference under weak identification. ### Q: What is EconomicAI? A: EconomicAI (https://economicai.com) is a company founded by Prof. Martin Spindler (Hamburg University), one of the co-authors of this book. EconomicAI brings causal AI and machine learning methods from academic research to practical industry applications. ### Q: Where can I find the code and notebooks? A: All notebooks are hosted on Google Colab and linked from the book's website at https://causalml-book.org/labs. The notebooks are also available on GitHub at https://github.com/CausalAIBook/MetricsMLNotebooks. ### Q: How do I cite this book? A: Chernozhukov, V., Hansen, C., Kallus, N., Spindler, M., & Syrgkanis, V. (2024). Applied Causal Inference Powered by ML and AI. Online. Available at https://causalml-book.org. ## Key Topics Covered - Predictive inference and machine learning - Causal inference and identification - Linear regression in high dimensions - Lasso, Ridge, and Elastic Net regularization - Randomized controlled trials (RCTs) - Conditional ignorability and selection on observables - Directed acyclical graphs (DAGs) - Structural causal models (SCMs) and structural equations - Potential outcomes framework - Double/Debiased Machine Learning (DML) - Cross-fitting and sample splitting - Neyman-orthogonal moment conditions - Random forests and gradient boosting - Deep neural networks - Variational autoencoders - NLP and BERT embeddings for causal inference - Instrumental variables (IV) - Proxy controls and negative controls - Weak identification and robust inference - Average treatment effects (ATE) - Conditional average treatment effects (CATE) - Heterogeneous treatment effects - Best linear predictors of CATE - Causal forests - Difference-in-differences (DiD) - Regression discontinuity designs (RDD) - Sensitivity analysis for unobserved confounders - Collider bias and bad controls - Feature engineering for causal inference ## Website This website (https://causalml-book.org) was created by Lucas Moreira Gomes, Data Scientist at EconomicAI GmbH (https://economicai.com). ## Contact - Website: https://causalml-book.org - GitHub (Notebooks): https://github.com/CausalAIBook/MetricsMLNotebooks