Penalized Splines
A curve can fit every observed value and still oscillate wildly between observations. Penalized splines discourage that behavior by charging for curvature, rather than merely counting basis coefficients.
Measuring roughness¶
For a sufficiently regular function, define
Squaring prevents positive and negative curvature from cancelling. Integrating accumulates bending over the interval. A straight line has and pays no penalty, regardless of its intercept or slope.
A smoothing spline minimizes
For distinct ordered inputs and a positive smoothing parameter, the standard unrestricted boundary formulation has a natural cubic spline solution with knots at the observed inputs. A penalized regression spline instead begins with a chosen finite basis, often using fewer knots. Both use the same fit versus roughness idea, but their available function spaces need not coincide.
Why the natural cubic spline is enough¶
Fix the fitted values of any competing function at the observations. Let be the natural cubic spline interpolating those same values and write . Then .
Expanding the penalty gives
Integration by parts on each knot interval makes the cross term zero. Natural boundary conditions remove the outer boundary terms; continuity and remove the remaining knot terms. Consequently .
Replacing by leaves the residual sum of squares unchanged and cannot increase roughness. This is why searching over natural cubic splines loses nothing in the smoothing problem.
Turning curvature into a matrix¶
Write . Since ,
The matrix is symmetric and positive semidefinite. Its entries can be computed interval by interval because the derivatives are polynomials within each knot interval.
The coefficient objective becomes
Differentiation gives
and hence
This inverse exists when no nonzero coefficient direction is invisible both to the data and to the penalty. Equivalently, . In computation, solve the system rather than explicitly forming an inverse.
What a large penalty leaves behind¶
For a full spline basis containing all linear functions, the nullspace of has dimension two. It represents the intercept and slope. Larger suppresses departures from a straight line, not the line itself.
If the data identify both unpenalized directions, the limit as is the least squares straight line. It is not generally the zero function. At small , the fit approaches the unpenalized fit available in the chosen spline basis; that fit interpolates only if the basis and design allow it.
Illustrative simulated data with one fixed cubic basis. Increasing the curvature penalty moves the estimate toward a straight line. The observations and knots are identical in all three panels.
Separating penalized and unpenalized directions¶
Let , where contains the positive eigenvalues, and let span its nullspace. Write
The component is a free linear trend. The component describes curvature and is penalized. Setting turns its penalty into , with transformed design . This makes the connection to ordinary ridge explicit.