Skip to content

how to calculate the statistics of a yearly window with a rolling step as 1 day?

4 messages · ecoc, Gabor Grothendieck

#
On Mon, Oct 10, 2011 at 2:55 PM, ecoc <liting231 at gmail.com> wrote:
Fill in the missing days with NAs using zoo FAQ 15 or otherwise and
then use rollapply(z, 365, f, ...whatever...)  such that your function
f first removes any NAs.
1 day later
#
This doesn't work becaues the rollappy is non-overlapping. My rolling step is
1-day and rolling window is 1-year, so there is 364 days overlapping.

--
View this message in context: http://r.789695.n4.nabble.com/how-to-calculate-the-statistics-of-a-yearly-window-with-a-rolling-step-as-1-day-tp3891404p3897922.html
Sent from the R help mailing list archive at Nabble.com.
#
On Wed, Oct 12, 2011 at 9:12 AM, ecoc <liting231 at gmail.com> wrote:
Its not the case that rollapply is non-overlapping.  rollapply by
default calls the function on a stretch of data moving ahead by 1 each
time so it does overlap.  Also you can use by= to cause it to move
ahead by some other number if you wish.  Also by setting by=
appropriately you can get it to not overlap at all if you wish.  Also
depending on what your problem is you may be able to handle variations
in the function itself, e.g. removing NAs.

I suggest you give a small reproducible example showing what you have
and what you want in order to clarify.