The full academy launches January 2027. Join the waitlist for the $179 founding price.
Waldbauer Academy of Economics

Courses › Graduate Econometrics

Graduate · Module 15 of 15

Nonparametrics, machine learning, and causal inference

Kernel and series regression, the bias–variance trade-off and cross-validation, the lasso and post-selection inference, double/debiased machine learning, heterogeneous treatment effects, and open questions.

By Maximus S. Waldbauer · About 6 to 7 hours, including the problem set and quiz.

Every estimator so far has assumed a parametric form somewhere: a linear conditional mean, a logit propensity score, a normal error. This final module asks what can be learned with fewer assumptions, and how the flexible prediction methods of machine learning can be put to work on causal questions without destroying valid inference.

We start with nonparametric regression and the bias–variance trade-off that governs it, move to regularized regression and cross-validation, show why naive inference after model selection fails and how double selection fixes it, develop double/debiased machine learning, and finish with heterogeneous treatment effects and the open questions on the field’s frontier. Throughout, the guiding idea is Module 11’s doubly robust score: build estimators whose answer is insensitive to small mistakes in the flexible parts.

By the end of this module you will be able to

What this module covers

  1. Nonparametric regression
  2. Regularization and cross-validation
  3. Inference after model selection
  4. Double/debiased machine learning
  5. Heterogeneous effects and open questions
  6. Problem set with step-by-step solutions
  7. Module quiz

Lesson 15.1 Free lesson

Nonparametric regression

Module 1’s conditional expectation function m(x) = E[Y | X = x] can have any shape. Nonparametric regression estimates it without assuming one. The simplest idea is a weighted local average. The Nadaraya–Watson (local constant) estimator is

m̂(x) = Σi K((Xi − x)/h) Yi / Σi K((Xi − x)/h)

where K is a kernel (a symmetric weight function such as the normal density or the Epanechnikov kernel) and h is the bandwidth. Local linear regression instead fits a weighted straight line around each x and reports its value at x; it has the same variance but smaller bias near the boundaries of the data and where the design is uneven, which is why Module 12 used it for RD.

Bias, variance and rates

For a twice-differentiable m and a single regressor, the bias of local linear regression is proportional to h2m″(x) (a wide window averages over a curved function), and the variance is proportional to σ2(x)/(nh f(x)) (a narrow window uses few observations, especially where the density f(x) is low). Minimizing mean squared error gives h ∝ n−1/5 and an MSE that falls like n−4/5. The estimator converges more slowly than the √n (MSE ∝ n−1) of parametric models: that is the price of flexibility.

The full module has an interactive graph here that you can move yourself.

Choosing the bandwidth

Leave-one-out cross-validation predicts each observation from all the others and picks the h with the smallest average squared prediction error. It estimates the bandwidth that is best for prediction; for inference at a point (as in RD) other rules and bias corrections are used.

The curse of dimensionality

With d continuous regressors, a window of a given width contains a fraction of the data that shrinks geometrically with d, and the optimal MSE rate becomes n−4/(4+d). With d = 5 that is n−4/9: to halve the MSE you need about 4.8 times as much data, against 2.4 times with d = 1. Fully nonparametric estimation with many regressors is hopeless; practical methods impose structure (additivity, smoothness, sparsity) or use the data to decide where to be flexible.

Series estimators

An alternative approximates m(x) by a flexible linear combination of basis functions (polynomials, splines) whose number grows with n. Series estimators are simple OLS regressions, extend easily to several regressors, and connect directly to the regularized regressions of the next lesson.

Key ideas

  • Kernel regression averages nearby observations; local linear has smaller boundary bias.
  • Bias ∝ h2, variance ∝ 1/(nh); the MSE-optimal h ∝ n−1/5 and the MSE falls like n−4/5.
  • With d regressors the rate is n−4/(4+d): the curse of dimensionality.

Practice questions: Nonparametrics, machine learning, and causal inference

Try these, then open each answer to check your work.

  1. 1.In kernel regression, increasing the bandwidth typically
    1. increases bias and decreases variance
    2. decreases both bias and variance
    3. increases both bias and variance
    4. has no effect on the estimate
    Show answer

    Answer: A. A wider window averages over more curvature (bias) but uses more observations (lower variance).

  2. 2.For local linear regression with one regressor, the MSE-optimal bandwidth shrinks with the sample size at rate
    1. n−1/2
    2. n−1/5
    3. n−1
    4. it does not shrink
    Show answer

    Answer: B. Balancing h4 bias-squared against 1/(nh) variance gives h ∝ n−1/5.

  3. 3.The curse of dimensionality refers to
    1. the bias of OLS when there are many regressors
    2. multicollinearity among many correlated regressors
    3. nonparametric estimators converging more slowly as regressors are added
    4. the failure of cross-validation in high dimensions
    Show answer

    Answer: C. The optimal MSE rate n−4/(4+d) deteriorates quickly with d.

Problems with step-by-step solutions

  1. 4.Write the Nadaraya–Watson estimate at x = 10 with a uniform kernel and h = 2, given observations (8, 5), (9, 7), (11, 6), (12, 10), (15, 20).
    Show step-by-step solution
    1. A uniform kernel with h = 2 gives equal weight to points with |X − 10| ≤ 2: X = 8, 9, 11, 12.
    2. m̂(10) = (5 + 7 + 6 + 10)/4 = 7.
  2. 5.For local linear regression, how do the bias and variance change if the bandwidth is halved?
    Show step-by-step solution
    1. Bias ∝ h2: it falls to one quarter.
    2. Variance ∝ 1/(nh): it doubles.

Get the full module

The complete module adds every lesson, interactive graphs, a full problem set with step-by-step solutions, and a quiz. The academy opens in January 2027: join the waitlist for the founding price (lifetime access for $179).

Join the waitlist Try a full module free

More practice: free practice questions for this course.