[R-SIG-Finance] Incorrect Formula in table.CAPM?

Brian G. Peterson brian at braverock.com
Fri Sep 17 15:16:53 CEST 2010


On 09/17/2010 07:43 AM, devlinme at mac.com wrote:
> I've been getting up to speed on the Performance Analytics package, and there's one formula I'm having some trouble reconciling with some manual results I have done in spreadsheets.  The table.CAPM function has a tracking error calculation that looks like this:
>
> tracking.error = sqrt(sum(merged.assets[, 1] - merged.assets[,
>                  2])^2/(length(merged.assets[, 1]) - 1)) * sqrt(scale)
>
> This gives different results than the TrackingError function (which just uses the standard deviation function).  I think the formula in table.CAPM should be this:
>
> tracking.error = sqrt(sum((merged.assets[, 1] - merged.assets[,
>                  2])^2)/(length(merged.assets[, 1]) - 1)) * sqrt(scale)
>
> This result flows through to the Information Ratio as well.

I've always been uncomfortable with the code for this table.  In an 
attempt to make it run marginally faster, the calculations are done 
inside the table. function rather than calling the underlying (and more 
closely examined) standalone functions.

This introduces the strong possibility of cut and paste errors, or of 
fixes or improvements from other parts of the code not propagating 
properly into the table (as happened in this case, from a glance at the 
commit logs).

Given my little rant above, I've changed the function to simply call 
TrackingError(), and committed it as R-Forge r1763.

Thank you for the report.  We appreciate the feedback and careful 
commentary.

Regards,

   - Brian

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



More information about the R-SIG-Finance mailing list