Skip to content
Prev 8425 / 15274 Next

PerformanceAnalytics apply.rolling with NAs

On Fri, 2011-09-02 at 13:00 +0200, Dean Marks wrote:
Well, the xts error says it all in this case.  You don't have a time
series to roll *on*.  This is a time series function, so without a time
series, it simply won't work.

There is the newer function rollapply.xts, but I don't recall offhand
whether it has been exported yet, or rollapply (in zoo) which is less
fussy about the 'time series' part, though it does of course assume the
ordered observations from which zoo takes its name.

I suspect your actual use case is more complicated than the minimal
example you've supplied.  In this case, whether the function you choose
to apply is NA-safe is up to that function.  Many functions in R can
handle NA's, many others fail in ugly ways.  Since we don't know what
you're trying to apply over a rolling period, you will need to
understand the NA behavior of the function you wish to call if your data
contains NA's or other anomalies.

Regards,

  - Brian