Title: | Penalized Smoothing Splines |
---|---|
Description: | Smoothing splines with penalties on order m derivatives. |
Authors: | S original by Jim Ramsey <[email protected]>. R port by Brian Ripley <[email protected]>. |
Maintainer: | Brian Ripley <[email protected]> |
License: | Unlimited |
Version: | 1.0-21 |
Built: | 2024-12-11 16:43:37 UTC |
Source: | CRAN |
Uses an object of class "smooth.Pspline"
to evaluate a
polynomial smoothing spline of arbitrary order or one of its
derivatives at new argument values.
## S3 method for class 'smooth.Pspline' predict(object, xarg, nderiv = 0, ...)
## S3 method for class 'smooth.Pspline' predict(object, xarg, nderiv = 0, ...)
object |
a fitted |
xarg |
the argument values at which the spline or its derivative is to be evaluated. |
nderiv |
the order of the derivative required – the default is 0, the function itself. |
... |
further arguments passed to or from other methods. |
The method produces results similar to function the predict
method for smooth.spline
, but the smoothing function is
a natural smoothing spline rather than a B-spline smooth, and the
order of the spline can be chosen freely, where order in this case
means the order of the derivative that is
penalized. smooth.spline
penalizes the second derivative, and
consequently only derivatives or order 0 or 1 are useful, but because
smooth.Pspline
penalizes a derivative of order m,
derivatives up to order m-1 are useful. The general recommendation is
to penalize the derivative two beyond the highest order derivative to
be evaluated.
A list with components xarg
and dy
; the xarg
component is identical to the input xarg
sequence, the
dy
component is the evaluated derivative of order deriv
.
Heckman, N. and Ramsay, J. O. (1996) Spline smoothing with model based penalties. McGill University, unpublished manuscript.
example(smooth.Pspline) ## smoother line is given by xx <- seq(4, 25, length=100) lines(xx, predict(sm.spline(speed, dist, df=5), xx), col = "red") ## add plots of derivatives lines(xx, 10*predict(sm.spline(speed, dist), xx, 1), col = "blue") lines(xx, 100*predict(sm.spline(speed, dist), xx, 2), col = "green")
example(smooth.Pspline) ## smoother line is given by xx <- seq(4, 25, length=100) lines(xx, predict(sm.spline(speed, dist, df=5), xx), col = "red") ## add plots of derivatives lines(xx, 10*predict(sm.spline(speed, dist), xx, 1), col = "blue") lines(xx, 100*predict(sm.spline(speed, dist), xx, 2), col = "green")
Returns an object of class "smooth.Pspline"
which is a natural
polynomial smooth of the input data of order fixed by the user.
smooth.Pspline(x, y, w=rep(1, length(x)), norder=2, df=norder + 2, spar=0, method=1) sm.spline(x, y, w, cv=FALSE, ...)
smooth.Pspline(x, y, w=rep(1, length(x)), norder=2, df=norder + 2, spar=0, method=1) sm.spline(x, y, w, cv=FALSE, ...)
x |
values of the predictor variable. These must be strictly increasing,
and there must be at least
|
y |
one or more sets of response variable values. If there is one
response variable, |
w |
vector of positive weights for smoothing of the same length as |
norder |
the order of the spline. |
df |
a number which specifies the degrees of freedom = trace(S). Here S is
the implicit smoothing matrix. |
spar |
the usual smoothing parameter for smoothing splines, which is the
coefficient of the integrated squared derivative of order |
cv |
logical: should ordinary cross-validation be used (true) or generalized cross-validation. |
method |
the method for controlling the amount of smoothing.
|
... |
additional arguments to be passed to |
The method produces results similar to function smooth.spline
, but
the smoothing function is a natural smoothing spline rather than a B-spline
smooth, and as a consequence will differ slightly for norder = 2
over the
initial and final intervals.
The main extension is the possibility of setting the order of
derivative to be penalized, so that derivatives of any order can be
computed using the companion function predict.smooth.Pspline
. The
algorithm is of order N, meaning that the number of floating point
operations is proportional to the number of values being smoothed.
Note that the argument values must be strictly increasing, a condition
that is not required by smooth.spline
.
Note that the appropriate or minimized value of the smoothing parameter
spar
will depend heavily on the order; the larger the order, the smaller
this parameter will tend to be.
an object of class "smooth.Pspline"
is returned, consisting of the fitted
smoothing spline evaluated at the supplied data, some fitting criteria
and constants. This object contains the information necessary to evaluate
the smoothing spline or one of its derivatives at arbitrary argument
values using predict.smooth.Pspline
. The components of the returned
list are
norder |
the order of the spline |
x |
values of the predictor variable |
ysmth |
a matrix with |
lev |
leverage values, which are the diagonal elements of the smoother matrix S. |
gcv |
generalized cross-validation criterion value |
cv |
ordinary cross-validation criterion value |
df |
a number which supplies the degrees of freedom = trace(S) rather than a smoothing parameter. |
spar |
the final smoothing parameter for smoothing splines. This
is unchanged if |
call |
the call that produced the fit. |
Heckman, N. and Ramsay, J. O. (1996) Spline smoothing with model based penalties. McGill University, unpublished manuscript.
predict.smooth.Pspline
, smooth.spline
data(cars) attach(cars) plot(speed, dist, main = "data(cars) & smoothing splines") cars.spl <- sm.spline(speed, dist) cars.spl lines(cars.spl, col = "blue") lines(sm.spline(speed, dist, df=10), lty=2, col = "red")
data(cars) attach(cars) plot(speed, dist, main = "data(cars) & smoothing splines") cars.spl <- sm.spline(speed, dist) cars.spl lines(cars.spl, col = "blue") lines(sm.spline(speed, dist, df=10), lty=2, col = "red")