Skip to content
Prev 15437 / 398500 Next

Questions about piecewise spline fitting

Hi,
What you need is just the bs() or ns() functions in the library splines in
the R-software. You have to specify the knots and can specify the degree.
For instance:

library(splines)
bs(1:20, knots=c(5,11), degree=1) #performs three #straight lines with
break-point at x=5 and 11 for the variable 1:20
lm(y~bs(1:20, knots=c(5,11), degree=1)) #piecewise linear regression

Common "problem" is that the beta parameters for the pseudo-variables
inducted by bs() are not interpretable (i.e. in linear case they don't
represents the slopes in each piece).
best,
vito


----- Original Message -----
From: "Gang Liang" <gumpleon at hotmail.com>
To: <r-help at hypatia.math.ethz.ch>
Sent: Wednesday, December 05, 2001 7:05 AM
Subject: [R] Questions about piecewise spline fitting
a
Why
-.-.-
http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.
_._
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._