Actuarial Notes

Smoothing Spline

Study guide: Exam MAS-I

A Smoothing Spline is the function g of a predictor x that minimizes the residual sum of squares plus a penalty on the roughness of g. For a tuning parameter \lambda \ge 0, the smoothing spline minimizes

\sum_{i=1}^{n} \big(y_i - g(x_i)\big)^2 + \lambda \int g''(t)^2\, dt

  • y_i is the response and x_i is the predictor of observation i, for i = 1, \ldots, n.
  • g''(t) is the second derivative of g, and \int g''(t)^2\,dt measures how much the slope of g changes over its range.

The penalty is 0 for a straight line and large for a wiggly function. At \lambda = 0 the penalty has no effect, and g passes through every training observation. As \lambda \to \infty, g becomes the least squares line. The minimizer is a natural cubic spline with a knot at every unique value of x_1, \ldots, x_n, shrunk toward the least squares line by the penalty. Its fitted curve is therefore continuous, and \lambda rather than the choice of knots controls its smoothness. A natural cubic spline fitted by least squares instead has knots chosen in advance and no penalty. A smoothing spline can also be one of the functions of a generalized additive model.

A smoothing spline is fitted to 40 observations with distinct values of x. What is the fit at \lambda = 0 and as \lambda \to \infty, and does increasing \lambda remove knots?

  • At \lambda = 0 only the residual sum of squares counts, so the fit passes through all 40 observations.
  • As \lambda \to \infty any curvature is penalized without limit, so the fit becomes the least squares line.
  • Increasing \lambda does not remove knots. The smoothing spline has a knot at each of the 40 values of x for every \lambda, and a larger \lambda shrinks the fit toward the line.

Effective degrees of freedom

The vector of fitted values at x_1, \ldots, x_n is a matrix times the vector of responses,

\hat{\mathbf{g}}_\lambda = \mathbf{S}_\lambda \mathbf{y}

  • \mathbf{y} is the vector of responses y_1, \ldots, y_n.
  • \mathbf{S}_\lambda is an n \times n matrix that depends on \lambda.

The effective degrees of freedom of the smoothing spline is the sum of the diagonal elements of \mathbf{S}_\lambda:

df_\lambda = \sum_{i=1}^{n} \{\mathbf{S}_\lambda\}_{ii}

As \lambda increases from 0 to \infty, df_\lambda decreases from n to 2. The flexibility of a method is the range of shapes it can fit, and a smoothing spline with more effective degrees of freedom is more flexible, with lower bias and higher variance.

Choosing the tuning parameter by cross-validation

The tuning parameter \lambda is chosen by leave-one-out cross-validation. For a smoothing spline, the leave-one-out cross-validated residual sum of squares can be computed from the one fit to all the data:

\text{RSS}_{cv}(\lambda) = \sum_{i=1}^{n} \left[\frac{y_i - \hat{g}_\lambda(x_i)}{1 - \{\mathbf{S}_\lambda\}_{ii}}\right]^2

  • \hat{g}_\lambda(x_i) is the fitted value at x_i from the smoothing spline fitted to all n observations.

The value of \lambda with the smallest \text{RSS}_{cv}(\lambda) is chosen.

A smoothing spline of claim frequency on vehicle age, fitted at \lambda = 1, gives the values below. At \lambda = 0.2, \text_ = 3.78. What are df_\lambda and \text_ at \lambda = 1, and which \lambda is chosen?

x_i 1 2 3 4 5 6
y_i 8.1 7.2 7.5 6.1 6.4 5.2
\hat{g}_\lambda(x_i) 8.011 7.519 7.063 6.537 6.002 5.367
\{\mathbf{S}_\lambda\}_{ii} 0.757 0.379 0.379 0.379 0.379 0.757
  • The effective degrees of freedom is 2(0.757) + 4(0.379) = 3.03.
  • Each residual is divided by 1 - \{\mathbf{S}_\lambda\}_{ii}, which is 0.243 at the ends and 0.621 elsewhere, and squared:
\begin{aligned}
\text{RSS}_{cv} &= \left(\tfrac{0.089}{0.243}\right)^2 + \left(\tfrac{-0.319}{0.621}\right)^2 + \left(\tfrac{0.437}{0.621}\right)^2 \\
&\quad + \left(\tfrac{-0.437}{0.621}\right)^2 + \left(\tfrac{0.398}{0.621}\right)^2 + \left(\tfrac{-0.167}{0.243}\right)^2 \\
&= 2.27
\end{aligned}
  • 2.27 < 3.78, so \lambda = 1 is chosen.

Practice questions

Actuarial Notes