[R] How to generate natural cubic spline in R?
spencerg
spencer.graves at prodsyse.com
Tue Mar 31 16:35:07 CEST 2009
Hello:
If B-splines will suffice, there are many capabilities in R for
that. My favorite is the 'fda' package, but 'splines' and other
packages are also good.
The "splinefun" function in the "base" package returns a function
to compute spline interpolations optionally using a natural spline.
However, that is an interpolation spline and therefore does no smoothing.
To find other options for natural splines, I suggest you try the
CRAN packages splines, mboost, pspline, Design, and mgcv. I found them
using the "RSiteSearch" packages available from R-Forge via
'install.packages("RSiteSearch", repos="http://r-forge.r-project.org")',
which also identified the "siggenes" package (which is not on CRAN). I
don't know if any of these actually use natural splines, but this gives
you a reasonably short list to consider.
Hope this helps.
Spencer Graves
p.s. The following are the commands I used with the "RSiteSearch"
package:
library(RSiteSearch)
natSpl <- RSiteSearch.function('natural spline')
str(natSpl)
summary(natSpl)
natSpl[1:23, c(1, 4, 5, 7)]
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?
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
More information about the R-help
mailing list