[R] How to generate natural cubic spline in R?

Stephan Kolassa Stephan.Kolassa at gmx.de
Tue Mar 31 22:20:50 CEST 2009


Hi David,

David Winsemius schrieb:
> The splinefun documentation indicates that "natural" is one of the types 
> of cubic spline options available.

That sounds good, didn't know that... rcs() has the advantage of coming 
with a book (Harrell's "Regression Modeling Strategies").

> Does rcs actually do fitting? Such would not be my expectation on 
> reading the documentation and I do not see any examples of such 
> functionality in the help pages.

Nope, but you can include rcs() within fitting functions, 
lm(foo~rcs(bar,3)), which makes more sense to me than having a spline 
function fit... Looks like better encapsulation to me.

Best,
Stephan




More information about the R-help mailing list