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

Martin Maechler maechler at stat.math.ethz.ch
Wed Apr 1 10:29:48 CEST 2009


>>>>> "SpG" == spencerg  <spencer.graves at prodsyse.com>
>>>>>     on Tue, 31 Mar 2009 07:35:07 -0700 writes:

    SpG> Hello: 
    SpG> If B-splines will suffice, there are many capabilities in R for 
    SpG> that.  My favorite is the 'fda' package, but 'splines' and other 
    SpG> packages are also good. 


    SpG> The "splinefun" function in the "base" package returns a function 
    SpG> to compute spline interpolations optionally using a natural spline.  
    SpG> However, that is an interpolation spline and therefore does no smoothing. 

    SpG> To find other options for natural splines, I suggest you try the 
    SpG> CRAN packages splines, mboost, pspline, Design, and mgcv.  I found them 
    SpG> using the "RSiteSearch" packages available from R-Forge via 
    SpG> 'install.packages("RSiteSearch", repos="http://r-forge.r-project.org")', 
    SpG> which also identified the "siggenes" package (which is not on CRAN).  I 
    SpG> don't know if any of these actually use natural splines, but this gives 
    SpG> you a reasonably short list to consider. 

Just a quick note with a small correction:

'splines' is *not* a CRAN, but a  "standard R"  aka "base R"
package that has "always" been "with us", and in my eyes contains
(almost IIRC) everything you'd ever want for univariate natural splines.

In particular, note the  'Priority' and 'Author' fields in
> packageDescription("splines")

Martin Maechler, ETH Zurich

    SpG> Hope this helps. 
    SpG> Spencer Graves
    SpG> p.s. 

  [.........]

    SpG> minben wrote:
    >> Suppose I have two var x and y,now I want to fits a natural cubic
    >> spline in x to y,at the same time create new var containing the
    >> smoothed values of y. How can I get it?




More information about the R-help mailing list