I think this modified version of ewma works for anyone who is
interested. It gets rid of any NAs, smoothes the
resulting series and then puts the NAs back in at their correct spots.
The only catch is that the input has to be a zoo object. 
Sometimes I shock myself.


ewmab<-function(x,lambda = 1, init = x[1]) {

oldindex<-index(x)

temp<-as.vector(!is.na(x))
x<-x[temp]

rval<-filter(lambda*coredata(x),filter=(1-lambda),method="recursive",ini
t=init)
nonmissingzoo<-zoo(matrix(coredata(rval),nc=1),index(x))
rval<-merge(zoo(,oldindex),nonmissingzoo)

rval

}
--------------------------------------------------------

This is not an offer (or solicitation of an offer) to buy/se...{{dropped}}

______________________________________________
R-help@stat.math.ethz.ch 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.

Reply via email to