Hi there, when calculating the ALMA moving average, the resulting vector is shorter than the original data by 'n' where n is the length of the moving average..... Checking this against other moving average types, it seems to be that the ALMA resultant vector does not pad the start of the results with an NA.
The text was updated successfully, but these errors were encountered:
Thanks for the report. Looks like this is due to the difference in rollapply.default and rollapply.xts when it comes to prepending the result with NA. I assume xts objects were used when ALMA was originally written, and NA are prepended in that case.
x<- xts(ttrc[,-1], ttrc[,1]
# num [1:5542] 3.2 3.24 3.28 3.29 3.28 ...
# An ‘xts’ object on 1985-01-02/2006-12-29 containing:# Data: num [1:5550, 1] NA NA NA NA NA ...# - attr(*, "dimnames")=List of 2# ..$ : NULL# ..$ : chr "Close"# Indexed by objects of class: [Date] TZ: UTC# xts Attributes: # NULL
The fix might be as easy as setting fill = NA in the call to rollapply.