[R-SIG-Finance] rollapply and resulting index
Brian Lee Yung Rowe
brian at muxspace.com
Sun Dec 14 03:49:29 CET 2008
Hi,
I was using rollapply on a zoo time series and the resulting zoo object
had index values that I wasn't expecting. I assumed (for better or
worse) that the index dates would be anchored to the last date in the
index as you would expect from a rolling moving average, but instead the
dates seemed to hover around the median. Is this the expected behavior?
Thanks,
Brian
> z <- zoo(11:15, as.Date(31:35))
> z
1970-02-01 1970-02-02 1970-02-03 1970-02-04 1970-02-05
11 12 13 14 15
> rollapply(z, 2, mean)
1970-02-01 1970-02-02 1970-02-03 1970-02-04
11.5 12.5 13.5 14.5
> rollapply(z, 3, mean)
1970-02-02 1970-02-03 1970-02-04
12 13 14
> rollapply(z, 4, mean)
1970-02-02 1970-02-03
12.5 13.5
> rollapply(z, 5, mean)
1970-02-03
13
More information about the R-SIG-Finance
mailing list