Let
be a set of observations, modeled by the relation
where the
are independent, zero mean random variables. The cubic smoothing spline estimate
of the function
is defined to be the unique minimizer, in the Sobolev space
on a compact interval, of[1][2]
![{\displaystyle \sum _{i=1}^{n}\{Y_{i}-{\hat {f}}(x_{i})\}^{2}+\lambda \int {\hat {f}}^{\prime \prime }(x)^{2}\,dx.}](//wikimedia.org/api/rest_v1/media/math/render/svg/25c2e94e2f6b8cf49ef78f9823d556c259b6d652)
Remarks:
is a smoothing parameter, controlling the trade-off between fidelity to the data and roughness of the function estimate. This is often estimated by generalized cross-validation,[3] or by restricted marginal likelihood (REML)[citation needed] which exploits the link between spline smoothing and Bayesian estimation (the smoothing penalty can be viewed as being induced by a prior on the
).[4]
- The integral is often evaluated over the whole real line although it is also possible to restrict the range to that of
.
- As
(no smoothing), the smoothing spline converges to the interpolating spline.
- As
(infinite smoothing), the roughness penalty becomes paramount and the estimate converges to a linear least squares estimate.
- The roughness penalty based on the second derivative is the most common in modern statistics literature, although the method can easily be adapted to penalties based on other derivatives.
- In early literature, with equally-spaced ordered
, second or third-order differences were used in the penalty, rather than derivatives.[5]
- The penalized sum of squares smoothing objective can be replaced by a penalized likelihood objective in which the sum of squares terms is replaced by another log-likelihood based measure of fidelity to the data.[1] The sum of squares term corresponds to penalized likelihood with a Gaussian assumption on the
.
It is useful to think of fitting a smoothing spline in two steps:
- First, derive the values
.
- From these values, derive
for all x.
Now, treat the second step first.
Given the vector
of fitted values, the sum-of-squares part of the spline criterion is fixed. It remains only to minimize
, and the minimizer is a natural cubic spline that interpolates the points
. This interpolating spline is a linear operator, and can be written in the form
![{\displaystyle {\hat {f}}(x)=\sum _{i=1}^{n}{\hat {f}}(x_{i})f_{i}(x)}](//wikimedia.org/api/rest_v1/media/math/render/svg/555b72650cafd34faa138b94d20eb372a4bf3739)
where
are a set of spline basis functions. As a result, the roughness penalty has the form
![{\displaystyle \int {\hat {f}}''(x)^{2}dx={\hat {m}}^{T}A{\hat {m}}.}](//wikimedia.org/api/rest_v1/media/math/render/svg/ff0f225d905a93ecb1e2290b6bd305719000a0af)
where the elements of A are
. The basis functions, and hence the matrix A, depend on the configuration of the predictor variables
, but not on the responses
or
.
A is an n×n matrix given by
.
Δ is an (n-2)×n matrix of second differences with elements:
,
, ![{\displaystyle \Delta _{i,i+2}=1/h_{i+1}}](//wikimedia.org/api/rest_v1/media/math/render/svg/63cd8f2dd235cb4b13e583e4307365d7ef900c96)
W is an (n-2)×(n-2) symmetric tri-diagonal matrix with elements:
,
and
, the distances between successive knots (or x values).
Now back to the first step. The penalized sum-of-squares can be written as
![{\displaystyle \{Y-{\hat {m}}\}^{T}\{Y-{\hat {m}}\}+\lambda {\hat {m}}^{T}A{\hat {m}},}](//wikimedia.org/api/rest_v1/media/math/render/svg/90bc1be43cec7805103391f52f581a2c746238c6)
where
.
Minimizing over
by differentiating against
. This results in:
[6] and
![{\displaystyle {\hat {m}}=(I+\lambda A)^{-1}Y.}](//wikimedia.org/api/rest_v1/media/math/render/svg/a1e08cd9463205d21cf7759d71e654f2e28bbabd)
De Boor's approach exploits the same idea, of finding a balance between having a smooth curve and being close to the given data.[7]
![{\displaystyle p\sum _{i=1}^{n}\left({\frac {Y_{i}-{\hat {f}}\left(x_{i}\right)}{\delta _{i}}}\right)^{2}+\left(1-p\right)\int \left({\hat {f}}^{\left(m\right)}\left(x\right)\right)^{2}\,dx}](//wikimedia.org/api/rest_v1/media/math/render/svg/252a21c7f40ea58e237cc1d1e5ff61d55a48e18b)
where
is a parameter called smooth factor and belongs to the interval
, and
are the quantities controlling the extent of smoothing (they represent the weight
of each point
). In practice, since cubic splines are mostly used,
is usually
. The solution for
was proposed by Christian Reinsch in 1967.[8] For
, when
approaches
,
converges to the "natural" spline interpolant to the given data.[7] As
approaches
,
converges to a straight line (the smoothest curve). Since finding a suitable value of
is a task of trial and error, a redundant constant
was introduced for convenience.[8]
is used to numerically determine the value of
so that the function
meets the following condition:
![{\displaystyle \sum _{i=1}^{n}\left({\frac {Y_{i}-{\hat {f}}\left(x_{i}\right)}{\delta _{i}}}\right)^{2}\leq S}](//wikimedia.org/api/rest_v1/media/math/render/svg/1375ddf1fe4fb3492fd144e178d8ae1f049ad8ec)
The algorithm described by de Boor starts with
and increases
until the condition is met.[7] If
is an estimation of the standard deviation for
, the constant
is recommended to be chosen in the interval
. Having
means the solution is the "natural" spline interpolant.[8] Increasing
means we obtain a smoother curve by getting farther from the given data.
There are two main classes of method for generalizing from smoothing with respect to a scalar
to smoothing with respect to a vector
. The first approach simply generalizes the spline smoothing penalty to the multidimensional setting. For example, if trying to estimate
we might use the Thin plate spline penalty and find the
minimizing
![{\displaystyle \sum _{i=1}^{n}\{y_{i}-{\hat {f}}(x_{i},z_{i})\}^{2}+\lambda \int \left[\left({\frac {\partial ^{2}{\hat {f}}}{\partial x^{2}}}\right)^{2}+2\left({\frac {\partial ^{2}{\hat {f}}}{\partial x\partial z}}\right)^{2}+\left({\frac {\partial ^{2}{\hat {f}}}{\partial z^{2}}}\right)^{2}\right]{\textrm {d}}x\,{\textrm {d}}z.}](//wikimedia.org/api/rest_v1/media/math/render/svg/6f5dfa31feeb4f59e953b550e787418763dda3c6)
The thin plate spline approach can be generalized to smoothing with respect to more than two dimensions and to other orders of differentiation in the penalty.[1] As the dimension increases there are some restrictions on the smallest order of differential that can be used,[1] but actually Duchon's original paper,[9] gives slightly more complicated penalties that can avoid this restriction.
The thin plate splines are isotropic, meaning that if we rotate the
co-ordinate system the estimate will not change, but also that we are assuming that the same level of smoothing is appropriate in all directions. This is often considered reasonable when smoothing with respect to spatial location, but in many other cases isotropy is not an appropriate assumption and can lead to sensitivity to apparently arbitrary choices of measurement units. For example, if smoothing with respect to distance and time an isotropic smoother will give different results if distance is measure in metres and time in seconds, to what will occur if we change the units to centimetres and hours.
The second class of generalizations to multi-dimensional smoothing deals directly with this scale invariance issue using tensor product spline constructions.[10][11][12] Such splines have smoothing penalties with multiple smoothing parameters, which is the price that must be paid for not assuming that the same degree of smoothness is appropriate in all directions.
Smoothing splines are related to, but distinct from:
- Regression splines. In this method, the data is fitted to a set of spline basis functions with a reduced set of knots, typically by least squares. No roughness penalty is used. (See also multivariate adaptive regression splines.)
- Penalized splines. This combines the reduced knots of regression splines, with the roughness penalty of smoothing splines.[13][14]
- Thin plate splines and Elastic maps method for manifold learning. This method combines the least squares penalty for approximation error with the bending and stretching penalty of the approximating manifold and uses the coarse discretization of the optimization problem.
Source code for spline smoothing can be found in the examples from Carl de Boor's book A Practical Guide to Splines. The examples are in the Fortran programming language. The updated sources are available also on Carl de Boor's official site .
Green, P. J.; Silverman, B.W. (1994). Nonparametric Regression and Generalized Linear Models: A roughness penalty approach. Chapman and Hall.
Hastie, T. J.; Tibshirani, R. J. (1990). Generalized Additive Models. Chapman and Hall. ISBN 978-0-412-34390-2.
Craven, P.; Wahba, G. (1979). "Smoothing noisy data with spline functions". Numerische Mathematik. 31 (4): 377–403. doi:10.1007/bf01404567.
Whittaker, E.T. (1922). "On a new method of graduation". Proceedings of the Edinburgh Mathematical Society. 41: 63–75.
De Boor, C. (2001). A Practical Guide to Splines (Revised Edition). Springer. pp. 207–214. ISBN 978-0-387-90356-9.
J. Duchon, 1976, Splines minimizing rotation invariant semi-norms in Sobolev spaces. pp 85–100, In: Constructive Theory of Functions of Several Variables, Oberwolfach 1976, W. Schempp and K. Zeller, eds., Lecture Notes in Math., Vol. 571, Springer, Berlin, 1977
Wahba, Grace. Spline Models for Observational Data. SIAM.
Gu, Chong (2013). Smoothing Spline ANOVA Models (2nd ed.). Springer.
Wood, S. N. (2017). Generalized Additive Models: An Introduction with R (2nd ed). Chapman & Hall/CRC. ISBN 978-1-58488-474-3.
Eilers, P.H.C. and Marx B. (1996). "Flexible smoothing with B-splines and penalties". Statistical Science. 11 (2): 89–121.
Ruppert, David; Wand, M. P.; Carroll, R. J. (2003). Semiparametric Regression. Cambridge University Press. ISBN 978-0-521-78050-6.
- Wahba, G. (1990). Spline Models for Observational Data. SIAM, Philadelphia.
- Green, P. J. and Silverman, B. W. (1994). Nonparametric Regression and Generalized Linear Models. CRC Press.
- De Boor, C. (2001). A Practical Guide to Splines (Revised Edition). Springer.