Interactive demo · Applied Statistical Learning in R and Python · Chapter 7

Backfitting an additive model for wage, one sweep at a time

The model (7.16) is wage = β0 + f1(year) + f2(age) + f3(education) + ε. Backfitting updates one term at a time: it smooths the partial residual, wage minus the intercept and the other terms, against that term's own variable, centres the result, and moves on. Press One sweep to update the three terms once, or Run to convergence; the faint dashed curves are the converged solution. Each term can be a smoothing spline with the chosen degrees of freedom, a straight line, or left out.

year

age

education

Try these

Smoothing splines are exact (a knot at every distinct value: 7 years, 61 ages), with λ set so that the smoother of that variable alone has trace df + 1, the convention of R's gam::s(): the df do not count the constant, which belongs to β0. A straight line is the weighted least-squares line in that variable; education is fitted by the mean partial residual of each level. Every term is centred to mean zero over the 3000 men.

In the lecture notes