Learn R Programming

pspline (version 1.0-13)

smooth.Pspline: Fit a Polynomial Smoothing Spline of Arbitrary Order

Description

Returns an object of class "smooth.Pspline" which is a natural polynomial smooth of the input data of order fixed by the user.

Usage

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, ...)

Arguments

Value

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 arenorderthe order of the splinexvalues of the predictor variableysmtha matrix with length(x) rows, each column of which contains the smoothed response variable values for the corresponding column of y.levleverage values, which are the diagonal elements of the smoother matrix S.gcvgeneralized cross-validation criterion valuecvordinary cross-validation criterion valuedfa number which supplies the degrees of freedom = trace(S) rather than a smoothing parameter.sparthe final smoothing parameter for smoothing splines. This is unchanged if method = 1, but adjusted otherwise.callthe call that produced the fit.

Details

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.

References

Heckman, N. and Ramsay, J. O. (1996) Spline smoothing with model based penalties. McGill University, unpublished manuscript.

See Also

predict.smooth.Pspline, smooth.spline

Examples

Run this code
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")

Run the code above in your browser using DataLab