[R] obtaining coefficients from a pspline fit

Nirmal Govind nirmalg at psu.edu
Sat Mar 29 02:13:44 CET 2003

Hi.. I'm relatively new to both nonparametric modeling and R.. I'm trying to fit
a regression spline or a piecewise polynomial using R and have teh following

1. How do I fit a regression spline/piecewise polynomial to the data for some
specified degree of the polynomial?

2. How do I obtain the coefficients of the model?

I tried the following (based on an example in the help):

> data(cars)
>  attach(cars)
>  plot(speed, dist, main = "data(cars)  &  smoothing splines")
>  cars.spl <- sm.spline(speed, dist)
> cars.spl
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 

> coef(cars.spl)

As seen above, it doesn't give me the coefficients though it seems to have
fitted a piecewise linear model.. I just get "NULL".. is there some other
function that will do this?

Please cc me on the reply as I'm not subscribed to the list yet..


More information about the R-help mailing list