[R] Savitzky-Golay Smoother

Gabor Grothendieck ggrothendieck at gmail.com
Sat Sep 27 01:23:35 CEST 2014


On Fri, Sep 26, 2014 at 3:32 AM, Erick Okuto <erickokuto at gmail.com> wrote:
> Dear Paul and Henrik,
> I have a time series with some missing data points that i need smoothed
> using Savitzky-Golay filter. Related question was asked  here
> http://thr3ads.net/r-help/2012/11/2121748-Savitzky-Golay-filtering-with-missing-data
> but no straight forward answer was posted. However, Henrik (cc'd here) did
> ask related question on smoothing for reflectance here
> http://thr3ads.net/r-help/2004/02/835137-Savitzky-Golay-smoothing-for-reflectance-data
> which i have as well been unable to follow up. I will be glad if you could
> assist me with some insights on the way forward or point to a relevant
> source of help.


Not Savitzky-Golay but if z is a time series then

library(zoo)
na.spline(z)

will fill in NAs with spline curve fits.  See ?na.spline

There are other NA filling routines in zoo too:

> ls(pattern = "^na[.]", "package:zoo")
 [1] "na.aggregate"         "na.aggregate.default" "na.approx"
 [4] "na.approx.default"    "na.fill"              "na.fill.default"
 [7] "na.locf"              "na.locf.default"      "na.spline"
[10] "na.spline.default"    "na.StructTS"          "na.trim"
[13] "na.trim.default"      "na.trim.ts"



-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com



More information about the R-help mailing list