[R] Optimal parameters for Savitzky-Golay smoothing filter (loop)

Ismail, Riyad Riyad.Ismail at sappi.com
Wed Nov 18 13:32:28 CET 2009


Hi 

I am running a Savitzky-Golay smoothing filter
(http://tolstoy.newcastle.edu.au/R/help/04/02/0385.html) for variables
in my dataset, dim (272:90). I managed to run the code for individual
variables in the dataset and then combine the results into a single
dataset. My novice attempt at this task is shown below
 
csg<-NULL
for (i in 1:ncol(data.all))  {
sg<-sav.gol(data.all[,i],1,forder=2,dorder=0)
csg[i]<-data.frame(sg)
dat<-do.call(cbind,(csg))

                            }

I eventually plan to test whether there is a significant difference
between the original noisy dataset (data.all) and the Savitzky-Golay
datasets(dat 1,dat2, ...). To create the  Savitzky-Golay datasets I plan
to change the size of the filter (j) so how would I create the new
datasets with the changing filter size ? 

csg<-NULL
for (i in 1:ncol(data.all)) for(j in 1:10)  {
sg<-sav.gol(data.all[,i],j,forder=2,dorder=0)
csg[i]<-data.frame(sg)
dat<-do.call(cbind,(csg))

                            }

And Is there anyway that I can combine the results into a single dataset
(data frame) or store them as separate objects in the workspace ?

Regards
Riyad

#####################################################################################
Scanned by MailMarshal - Marshal's comprehensive email content security solution. 
Download a free evaluation of MailMarshal at www.marshal.com
#####################################################################################




More information about the R-help mailing list