[R] Questions about piecewise spline fitting

Thomas Lumley tlumley at u.washington.edu
Wed Dec 5 17:51:48 CET 2001

On Tue, 4 Dec 2001, Gang Liang wrote:

> Hi All,
> I want to fit a piecewise spline of degree 1, i.e. a spline consisting of a
> straight line over each piece. I downloaded the R package pspline, then I
> have following questions:
> 1. in the program, the degree of the spline is specified by 2*norder-1. Why
> do they adopt such scheme that we can only fit a spline with odd degree?
> 2. norder cannot be set to 1. Is there any specific reason for doing so?
> Maybe I need to code this by myself. So I'd like to hear your advices.

There is a splines package in the R base distribution. You want to use the
bs() function in the splines package. The pspline package fits smoothing
splines, which are not what you want.

For linear splines it may be easier to code them yourself in any case, as
there are at least two different codings where the parameter estimates and
tests are of interest in themselves. What bs() gives is yet another coding
that is more numerically stable but has less interesting coefficients.


r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list