search for: smafast

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

2009 Jun 19
1
(FULL) Need help to optimize a piece of code involving zoo objects
...cond for-loop x.Date <- as.Date("2003-02-01") + seq(1,1100) - 1 temp <- zoo(rnorm(1100, 0, 10)+100, x.Date) start.time <- proc.time() for(j in seq(5,100,by=5)){ ? ? ? ?#PRODUCE FAST MOVING AVERAGE ? ? ? ?#Create equally weighted MA vector (we need only the first value) ? ? ? ?smafast <- zoo(coredata(filter(coredata(temp[,1]), filter=rep(1/j, j), sides=1)), order.by=time(temp)) ? ? ? ?#index of first non-NA value, which is the first SMA needed ? ? ? ?#which(is.na(smafast))[length(which(is.na(smafast)))]+1 ? ? ? ?#Calculate decay factor K ? ? ? ?#number of periods is j ? ? ?...
2009 Jun 19
1
Need help to optimize a piece of code involving zoo objects
...to initiate the second for-loop x.Date <- as.Date("2003-02-01") + seq(1,1100) - 1 temp <- zoo(rnorm(1100, 0, 10)+100, x.Date) start.time <- proc.time() for(j in seq(5,100,by=5)){ #PRODUCE FAST MOVING AVERAGE #Create equally weighted MA vector (we need only the first value) smafast <- zoo(coredata(filter(coredata(temp[,1]), filter=rep(1/j, j), sides=1)), order.by=time(temp)) #index of first non-NA value, which is the first SMA needed #which(is.na(smafast))[length(which(is.na(smafast)))]+1 #Calculate decay factor K #number of periods is j K <- 2/(1+j) #Calculate...