Leeds, Mark (IED)
2006-Dec-11 21:20 UTC
[R] I think this modified ewma function works if anyone is interested
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}}