[Returnanalytics-commits] r3296 - pkg/PerformanceAnalytics/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Jan 3 08:09:59 CET 2014


Author: matthieu_lestel
Date: 2014-01-03 08:09:58 +0100 (Fri, 03 Jan 2014)
New Revision: 3296

Modified:
   pkg/PerformanceAnalytics/R/MSquared.R
Log:
correction of a bug in the computation of MSquared

Modified: pkg/PerformanceAnalytics/R/MSquared.R
===================================================================
--- pkg/PerformanceAnalytics/R/MSquared.R	2013-12-23 06:14:36 UTC (rev 3295)
+++ pkg/PerformanceAnalytics/R/MSquared.R	2014-01-03 07:09:58 UTC (rev 3296)
@@ -23,7 +23,7 @@
 #' @examples
 #'
 #' data(portfolio_bacon)
-#' print(MSquared(portfolio_bacon[,1], portfolio_bacon[,2])) #expected 0.1068
+#' print(MSquared(portfolio_bacon[,1], portfolio_bacon[,2])) #expected 0.10062
 #'
 #' data(managers)
 #' print(MSquared(managers['1996',1], managers['1996',8]))
@@ -49,7 +49,7 @@
         Rp = (prod(1 + Ra))^(Period / length(Ra)) - 1
      	sigp = sqrt(var(Ra)*(length(Ra)-1)/length(Ra))*sqrt(Period)
      	sigm = sqrt(var(Rb)*(length(Rb)-1)/length(Rb))*sqrt(Period)
-        result = (Rp - Rf) * sigp / sigm + Rf
+        result = (Rp - Rf) * sigm / sigp + Rf
      }    
      else {
         result = NA



More information about the Returnanalytics-commits mailing list