predict.smooth.Pspline: Smoothing Spline of Arbitrary Order at New Data

Description Usage Arguments Details Value References See Also Examples

Description

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.

Usage

1
2
## S3 method for class 'smooth.Pspline'
predict(object, xarg, nderiv = 0, ...)

Arguments

object

a fitted smooth.Pspline object.

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.

Details

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.

Value

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.

References

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

See Also

smooth.Pspline

Examples

1
2
3
4
5
6
7
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 output

smth.P> data(cars)

smth.P> attach(cars)

smth.P> plot(speed, dist, main = "data(cars)  &  smoothing splines")

smth.P> cars.spl <- sm.spline(speed, dist)

smth.P> cars.spl
Call:
smooth.Pspline(x = ux, y = tmp[, 1], w = tmp[, 2], method = method)

Smoothing Parameter (Spar): 366.8429 
Equivalent Degrees of Freedom (Df): 2.428851 
GCV Criterion: 29.54554 
CV  Criterion: 39.18787 

smth.P> lines(cars.spl, col = "blue")

smth.P> lines(sm.spline(speed, dist, df=10), lty=2, col = "red")

pspline documentation built on May 2, 2019, 4:01 a.m.