search for: smaslow

Displaying 2 results from an estimated 2 matches for "smaslow".

2009 Jun 19
1
(FULL) Need help to optimize a piece of code involving zoo objects
...ch(is.na(smafast))[length(which(is.na(smafast)))]+2):length(smafast)) { ? ? ? ? ? ? ? ?smafast[k] <- coredata(smafast[k-1])+K*(coredata(temp[k,1])-coredata(smafast[k-1])) ? ? ? ?} ? ? ? ?#PRODUCE SLOW MOVING AVERAGE ? ? ? ?#Create equally weighted MA vector (we need only the first value) ? ? ? ?smaslow <- zoo(coredata(filter(coredata(temp[,1]), filter=rep(1/(j*4), (j*4)), sides=1)), order.by=time(temp)) ? ? ? ?K <- 2/(1+j*4) #Calculate EMA ? ? ? ?for (k in (which(is.na(smaslow))[length(which(is.na(smaslow)))]+2):length(smaslow)) { ? ? ? ? ? ? ? ?smaslow[k] <- coredata(smaslow[k-1])+K*(co...
2009 Jun 19
1
Need help to optimize a piece of code involving zoo objects
...second non-NA value) for (k in (which(is.na(smafast))[length(which(is.na(smafast)))]+2):length(smafast)) { smafast[k] <- coredata(smafast[k-1])+K*(coredata(temp[k,1])-coredata(smafast[k-1])) } #PRODUCE SLOW MOVING AVERAGE #Create equally weighted MA vector (we need only the first value) smaslow <- zoo(coredata(filter(coredata(temp[,1]), filter=rep(1/(j*4), (j*4)), sides=1)), order.by=time(temp)) K <- 2/(1+j*4) #Calculate EMA for (k in (which(is.na(smaslow))[length(which(is.na(smaslow)))]+2):length(smaslow)) { smaslow[k] <- coredata(smaslow[k-1])+K*(coredata(temp[k,1])-coredat...