[R-SIG-Finance] PerformanceAnalytics apply.rolling with NAs

Brian G. Peterson brian at braverock.com
Fri Sep 2 14:08:36 CEST 2011


On Fri, 2011-09-02 at 13:55 +0200, Dean Marks wrote:
> 
> My use case requires that I determine rolling returns for a collection
> of stocks where in some cases data is missing (repressented by NAs),
> for example if a stock did not exist for a period of time. I don't
> mean to frustrate you but if I go into the use case further it might
> unnecessarily complicate things. My work around, in any case, is
> simply to test for these cases prior to calling apply.rolling. 

OK, now we're getting somewhere.

You could apply apply.rolling by column, but this won't  give you
comparable results for the rolling return case.

You could aggregate your returns to some lower-frequency where all the
indices will agree and you only have leading NA's to deal with.

Or, you could see 

?zerofill

since an NA return is equivalent to a zero return (unless your manager
is not reporting to hide losses, but that's a different problem
altogether)

Regards,

  - Brian

-- 
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock



More information about the R-SIG-Finance mailing list