Displaying 1 result from an estimated 1 matches for "xmom".
Did you mean:
xmm
2011 Mar 04
2
apply.rolling() to a multi column timeSeries
...071709879 0.05126406
1996-06-28 -0.03586503 -0.196141479 0.01908068
1996-07-31 -0.10941283 0.047619048 -0.04993095
1996-08-30 -0.01720023 0.102363636 -0.06605725
Then, I ran the following,
f <- function(xIn) {prod(1 + xIn)}
tmp.ts <- apply.rolling(x.ts[,, drop = FALSE], FUN=f, width=3)
xMom.ts <- tmp.ts - 1
where,
> xMom.ts[1:8,]
GMT
calcs
1996-01-31 NA
1996-02-29 NA
1996-03-29 0.218076872
1996-04-30 0.006926330
1996-05-31 0.102324581
1996-06-28 -0.002179951
1996-07-31 -0.066514593
1996-08-30 -0.156122673
It seems that apply.rolling()...