伙计们,通常当您执行以下操作时:
tmp = zoo(rnorm(100), 1:100)
rollapply(tmp, 10, function(x) quantile(x, 0.05), align="right")
rollapply
从 10 个元素可用的那一刻开始计算值是非常正确的。
Unfortunately I need something that uses as much data as possible for the fist 10 observations, essentially a growing window of data till there is enough data to use a sliding window, e.g. 1, 1:2, 1:3, 1:4, etc. till we have at least 10 elements and then slide the window as usual.
Is there a better way to do this than an ugly for loop?