Search

Search papers and lessons

Machine Learning Methods That Economists Should Know About

Susan Athey, Guido Imbens · 2019

Athey and Imbens argue that economists should add machine learning tools to their kit, choosing them by predictive goals or adapting them to causal questions, with cross-fitting for valid inference.

On this page

  • Colour = topic mix
  • Probability
  • Linear algebra
  • Classical models
  • Calculus
  • Discrete math
  • Learning basics
  • ReadReady to readNot yet

TL;DR

Economists have long built models to estimate causal effects and structural parameters, and they judge those models by the properties of their estimators. Machine learning methods are built to predict well out of sample, and they usually come without formal guarantees of that kind. Athey and Imbens argue that economists should learn these tools anyway, and they show how to use them. The key moves are to state whether the goal is prediction or a causal parameter, to choose penalties and tuning parameters by out-of-sample validation, to select covariates with the treatment in mind, and to estimate nuisance parameters with cross-fitting so that a confidence interval for a causal effect remains valid.

Builds on: Lasso Regression, Random Forest, Cross-Validation, Causal Inference · Leads to: the double machine learning and causal forest methods that apply these ideas to treatment effects in later work

Why it mattered

Economic data are increasingly large, with many variables per unit and many units, and in such settings the flexible prediction tools of machine learning often work better than classical regression. The paper is a guide written for economists who want to know which tools to add to a graduate econometrics course. Its authors argue that the methods belong in the core graduate econometrics courses, so that economists can do more sophisticated empirical work and communicate with researchers who use these methods.

The paper is also a statement about culture. It draws on Breiman's contrast between data models, where the analyst assumes a stochastic model generated the data, and algorithmic models, which treat the data mechanism as unknown. Breiman argued that statistics should adopt algorithmic tools more widely, and the authors make the same argument for economics. They are careful to add that the tools have to be adapted, not used off the shelf, when the question is causal.

The problem

Econometrics and machine learning have different goals, and that is the source of the tension the paper addresses. In econometrics, the target is an estimand, such as a treatment effect or an elasticity, and the focus is on the quality of the estimator for that target, usually measured by large-sample efficiency and confidence intervals. In machine learning, the target is usually a prediction for a new unit, judged by its error on data the model has not seen.

Least squares illustrates the difference. If the true model is linear with normal errors, least squares is unbiased, efficient, and has standard errors. But if predicting a new unit is the goal, least squares can be beaten. With three or more regressors, least squares is not admissible: other estimators dominate it, meaning they have at least as low expected squared error for every parameter value, and a lower one for some. Those estimators shrink the coefficients toward zero, which is the opposite of what least squares does.

A second problem is that the flexible methods do not come with the formal results econometricians expect. The authors note that there are no results showing that deep learning is uniformly superior to regression trees or random forests for prediction, and that such results may never arrive. They do not conclude that the methods should be dismissed. They conclude that the goal of the analysis should be stated first, and the method chosen to fit it.

How it works

The paper is a review rather than a single method, so its workflow is a sequence of decisions that an economist makes when using these tools. The sequence follows the paper's own order of argument.

flowchart TD
  A["State the goal: prediction or a causal parameter"] --> B["Choose a model class and a penalty"]
  B --> C["Pick the penalty and tuning by out-of-sample validation"]
  C --> D{"Is the target a causal parameter?"}
  D -->|"no"| E["Use the predictive model and report its out-of-sample fit"]
  D -->|"yes"| F["Select covariates for both outcome and treatment"]
  F --> G["Estimate nuisance functions with cross-fitting"]
  G --> H["Form an orthogonal score and average it for the estimate"]

Here is a tiny instance of step 2 and step 3, traced by hand. A single regressor xx has three observations, x=(−1,0,1)x = (-1, 0, 1), and an outcome y=(−3,0,3)y = (-3, 0, 3), so the true slope is 3 and the fit is exact. Ridge regression adds a penalty λβ2\lambda\beta^2 to the squared errors, which shrinks the slope toward zero.

  1. Least squares. The slope that minimizes the squared errors is β^=∑xiyi/∑xi2=(3+0+3)/2=3\hat\beta = \sum x_i y_i / \sum x_i^2 = (3 + 0 + 3)/2 = 3. Check: the fit is exact, so any penalty will move the slope away from the truth.
  2. Ridge with λ=2\lambda = 2. The penalized slope is β^=∑xiyi/(∑xi2+λ)=6/(2+2)=1.5\hat\beta = \sum x_i y_i / (\sum x_i^2 + \lambda) = 6 / (2 + 2) = 1.5. Check: the penalty halves the slope, which is the shrinkage the paper describes.
  3. Ridge with λ=4\lambda = 4. The slope is 6/(2+4)=1.06 / (2 + 4) = 1.0. Check: a bigger penalty shrinks more. The question is which penalty predicts new units best.
  4. Choose by validation. Set aside one observation, fit on the other two, and predict the held-out point. Repeat for each point, and choose the λ\lambda with the smallest total prediction error. Check: the choice uses only out-of-sample errors, so it never rewards a fit to the data it was made from.

For a causal question, the workflow adds two steps. The covariates are selected to predict both the outcome and the treatment, because a confounder that predicts treatment but barely predicts the outcome still biases the estimate. The nuisance functions, meaning the outcome and treatment models, are then estimated on other folds of the data, which is cross-fitting, so that no unit's own outcome helps predict its own nuisance value.

The math

Step 1 in symbols: the least squares problem. With centred and standardized covariates, the linear predictor is g(x)=β⊤xg(x) = \beta^\top x, and least squares chooses β^\hat\beta to minimize ∑i=1N(Yi−β⊤Xi)2\sum_{i=1}^{N}(Y_i - \beta^\top X_i)^2. The paper notes that with K≥3K \geq 3 regressors this estimator is dominated by estimators that shrink toward zero.

Step 2 in symbols: the penalty. Ridge adds λ∥β∥22\lambda\|\beta\|_2^2 to the same sum, and lasso adds λ∥β∥1\lambda\|\beta\|_1. For a single regressor with ∑xi2\sum x_i^2 and ∑xiyi\sum x_i y_i the sufficient statistics, ridge gives

β^ridge=∑ixiyi∑ixi2+λ,\hat\beta_{\text{ridge}} = \frac{\sum_i x_i y_i}{\sum_i x_i^2 + \lambda},

which matches the tiny example: 6/(2+λ)6 / (2 + \lambda).

Step 3 in symbols: the Bayesian reading. If the errors have variance σ2\sigma^2 and each coefficient has a normal prior with mean zero and variance τ2\tau^2, the posterior mean minimizes the same objective with λ=σ2/τ2\lambda = \sigma^2/\tau^2. The paper's point is that λ\lambda is then a prior choice, and the machine learning approach instead chooses λ\lambda by out-of-sample cross-validation, which is empirical rather than subjective.

Step 4 in symbols: sparsity. The lasso uses q=1q = 1 in the penalty λ∑k∣βk∣q\lambda \sum_k |\beta_k|^q, and ridge uses q=2q = 2. The lasso can set coefficients exactly to zero, and ridge cannot. Best subset selection corresponds to q→0q \to 0, and it is computationally hard for large problems.

Step 5 in symbols: a regression tree split. A tree splits on covariate kk at threshold cc. Before the split the sum of squared errors is Q=∑i(Yi−Yˉ)2Q = \sum_i (Y_i - \bar Y)^2, and after the split it is

Q(k,c)=∑i:Xik≤c(Yi−Yˉk,c,l)2+∑i:Xik>c(Yi−Yˉk,c,r)2,Q(k,c) = \sum_{i: X_{ik} \leq c}\big(Y_i - \bar Y_{k,c,l}\big)^2 + \sum_{i: X_{ik} > c}\big(Y_i - \bar Y_{k,c,r}\big)^2,

where Yˉk,c,l\bar Y_{k,c,l} and Yˉk,c,r\bar Y_{k,c,r} are the means of the two sides. The tree chooses the split that reduces QQ the most. A random forest averages many trees grown on resampled data.

Step 6 in symbols: the average treatment effect. Under unconfoundedness, the treatment WiW_i is independent of the potential outcomes (Yi(0),Yi(1))(Y_i(0), Y_i(1)) given the covariates XiX_i. The average treatment effect is τ=E[Yi(1)−Yi(0)]\tau = \mathbb{E}[Y_i(1) - Y_i(0)], and it can be written in three ways: as the difference of conditional mean functions μ(w,x)=E[Yi∣Wi=w,Xi=x]\mu(w,x) = \mathbb{E}[Y_i \mid W_i = w, X_i = x], as a weighted average using the propensity score e(x)=E[Wi∣Xi=x]e(x) = \mathbb{E}[W_i \mid X_i = x], or through the influence function

ψ(y,w,x)=μ(1,x)−μ(0,x)+we(x)(y−μ(1,x))−1−w1−e(x)(y−μ(0,x)).\psi(y, w, x) = \mu(1,x) - \mu(0,x) + \frac{w}{e(x)}\big(y - \mu(1,x)\big) - \frac{1-w}{1-e(x)}\big(y - \mu(0,x)\big).

The estimate is the sample average of ψ\psi with estimated nuisance functions plugged in.

Step 7 in symbols: why orthogonalization works. The paper shows that the estimator is efficient when the product of the two nuisance errors is small relative to the root-NN rate,

E[(μ^−μ)2]1/2 E[(e^−e)2]1/2=oP(N−1/2).\mathbb{E}\big[(\hat\mu - \mu)^2\big]^{1/2}\,\mathbb{E}\big[(\hat e - e)^2\big]^{1/2} = o_P(N^{-1/2}).

So each nuisance function can converge at a rate near N−1/4N^{-1/4}, which is much slower than the estimate itself, and the estimator still behaves well. Errors in the nuisance functions enter only through this product.

Worked examples

Example
1. Tiny: shrinkage with one regressor

Use x=(−1,0,1)x = (-1, 0, 1) and y=(−3,0,3)y = (-3, 0, 3).

  1. The sum ∑xiyi=3+0+3=6\sum x_i y_i = 3 + 0 + 3 = 6.
  2. The sum ∑xi2=1+0+1=2\sum x_i^2 = 1 + 0 + 1 = 2.
  3. Least squares slope: 6/2=36 / 2 = 3.
  4. Ridge slope with λ=2\lambda = 2: 6/(2+2)=1.56 / (2 + 2) = 1.5.
  5. Interpretation: the penalty halves the slope. A larger λ\lambda shrinks it further, and cross-validation decides how much shrinkage predicts best.
Example
2. Standard: why a predictive model can be a poor propensity model

A researcher has a confounder X1X_1 that predicts treatment strongly, and an outcome that barely depends on it. A lasso selects covariates by predicting the outcome.

  1. The lasso keeps only covariates that predict the outcome well, so X1X_1 is dropped.
  2. Because X1X_1 drives treatment, dropping it leaves the treated and control groups unbalanced on X1X_1.
  3. The bias in the treatment effect is then roughly the imbalance times the effect of X1X_1 on the outcome, which can be large even when X1X_1 predicts the outcome only modestly.
  4. Selecting covariates that predict the outcome or the treatment, as the paper proposes, keeps X1X_1 in the model.
  5. Interpretation: the variables that matter for prediction are not necessarily the ones that matter for a causal estimate.
Example
3. Realistic: cross-fitting a forest-based estimate

A researcher estimates the nuisance functions with a random forest and wants a valid confidence interval for the average effect.

  1. Random forests provide out-of-bag predictions, which for each unit come from trees that did not use that unit. The paper notes that these predictions are straightforward to obtain from random forests, and they keep the nuisance estimates free of each unit's own outcome.
  2. If the researcher uses a different learner, such as boosting, the data are split into folds, the nuisance functions are fitted on all but one fold, and they predict the held-out fold.
  3. The orthogonal score is then computed for every unit using its own cross-fitted predictions.
  4. The average of the scores estimates the effect, and its variance is estimated from the scores.
  5. Interpretation: because no unit's own outcome helped fit the nuisance value used for that unit, overfitting does not inflate the estimated effect.

Try it: with 5 folds and 500 units, how many units are in each held-out fold? Answer: 500/5=100500 / 5 = 100 units per fold, and the nuisance model for each fold is fitted on the remaining 400.

Results

The paper's content is a set of arguments and examples, not experiments of its own, so its quantitative claims are the theoretical rates and the properties it reports for estimators from the literature.

Predictive problems. The paper argues that some substantive problems are naturally prediction problems, where a test-set fit is enough. In other cases the prediction is an input to a second analysis, and convergence rates matter more than inference on the prediction itself.

Causal problems. For average treatment effects under unconfoundedness, the paper reports that doubly robust and balancing methods combine outcome modelling with weighting, and that they are less sensitive to a single misspecified model. Covariate selection that targets both outcome and treatment improves the estimator, as shown by Belloni and colleagues.

Orthogonalization and cross-fitting. The paper argues that these two ideas make estimators based on machine learning nuisance functions efficient under the product-rate condition, and they reduce overfitting that a flexible model would otherwise introduce.

Heterogeneous effects, bandits and matrix completion. The paper covers the estimation of effects that vary across individuals, the use of bandits for experiments run online, and matrix completion for panel data and consumer choice. Each is presented as a method that exploits the structure of an economic problem.

Limits. The paper states several limits itself. There are no formal results that show a particular machine learning method is uniformly best for prediction. Off-the-shelf methods often need tuning and adaptation to the problem's structure. Methods that cannot produce valid confidence intervals should not be dismissed out of hand, but the researcher has to say when that matters. Finally, the loss of predictive power is sometimes accepted in exchange for a causal estimate, as in instrumental variables, so the goal decides what counts as good performance.

Reading guide

  1. Section 1, introduction. The contrast between data models and algorithmic models, and the list of topics. Needs Linear Regression for the classical baseline.
  2. Section 2.1 and 2.2, goals and terminology. The estimand framing and the least squares example. Needs Average Treatment Effect for the estimand idea.
  3. Section 2.3 and 2.4, validation and regularization. Cross-validation, the Bayesian reading of the penalty, and the role of the tuning parameter. Needs Cross-Validation, Penalized Least Squares and Bias-Variance Tradeoff.
  4. Section 2.5 to 2.8, sparsity, computation, ensembles and inference. Needs Lasso Regression and Random Forest.
  5. Section 3, supervised learning for regression. Lasso and elastic nets, regression trees and forests, neural networks and boosting. Needs Regularization and Variable Selection via the Elastic Net, Decision Tree and Gradient Boosting.
  6. Section 4 and 5, classification and unsupervised learning. Needs Logistic Regression and K-Means Clustering.
  7. Section 6, causal inference. The average treatment effect, orthogonalization and cross-fitting, and heterogeneous effects. Needs Unconfoundedness, Propensity Score, Inverse Probability Weighting, Cross-Fitting and Heterogeneous Treatment Effects.
  8. Section 7 and 8, experiments and matrix completion. Needs Multi-Armed Bandit and Matrix Completion Methods for Causal Panel Data Models.
  9. Section 9, text analysis. Needs Text as Data: The Promise and Pitfalls of Automatic Content Analysis for the broader setting.

Check yourself

QuestionRecall: how does the paper say the goal of econometrics differs from the goal of machine learning?Show answer
Econometrics targets an estimand, such as a treatment effect, and focuses on the quality of its estimator, usually through large-sample efficiency and confidence intervals. Machine learning targets prediction for new units and judges methods by their error on unseen data.
QuestionCompute: with x=(−1,0,1)x = (-1, 0, 1) and y=(−3,0,3)y = (-3, 0, 3), what is the ridge slope with λ=4\lambda = 4, and what is the least squares slope?Show answer
The least squares slope is 6/2=36 / 2 = 3. The ridge slope with λ=4\lambda = 4 is 6/(2+4)=1.06 / (2 + 4) = 1.0.
QuestionWhy: why does the paper say that choosing covariates by predicting the outcome alone can produce a biased treatment effect?Show answer
A covariate that strongly predicts treatment but only weakly predicts the outcome can be dropped by a selection method that targets the outcome. Dropping it leaves treated and control groups unbalanced on that covariate, which biases the estimated effect. Selecting covariates that predict either the outcome or the treatment avoids this.
QuestionApplied: a colleague plugs random forest predictions of the propensity score into the average-effect formula and reports a standard error from the sample variance. What should you advise?Show answer
Advise cross-fitting or out-of-bag predictions, so that no unit's own outcome helps predict its own nuisance values, and an orthogonal score so that errors in the nuisance models have only a second-order effect. The standard error should come from the variance of the scores computed this way. The advice follows the paper's point that overfitted nuisance functions can distort the estimate and its standard error.

Sources

Read the full paper

Susan Athey, Guido Imbens, 2019. arXiv:1903.10075