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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jun 20 18:03:56 CEST 2012


Author: matthieu_lestel
Date: 2012-06-20 18:03:56 +0200 (Wed, 20 Jun 2012)
New Revision: 2044

Modified:
   pkg/PerformanceAnalytics/R/BernadoLedoitratio.R
   pkg/PerformanceAnalytics/R/DownsideDeviation.R
   pkg/PerformanceAnalytics/R/DownsideFrequency.R
   pkg/PerformanceAnalytics/R/UpsideFrequency.R
   pkg/PerformanceAnalytics/R/UpsideRisk.R
Log:
end of tests for UpsideRisk and correction of a little bug in all examples

Modified: pkg/PerformanceAnalytics/R/BernadoLedoitratio.R
===================================================================
--- pkg/PerformanceAnalytics/R/BernadoLedoitratio.R	2012-06-20 15:42:55 UTC (rev 2043)
+++ pkg/PerformanceAnalytics/R/BernadoLedoitratio.R	2012-06-20 16:03:56 UTC (rev 2044)
@@ -21,7 +21,7 @@
 #' @keywords ts multivariate distribution models
 #' @examples
 #' data(portfolio_bacon)
-#' print(BernadoLedoitratio(portfolio_return)) #expected 1.78
+#' print(BernadoLedoitratio(portfolio_bacon)) #expected 1.78
 #'
 #' data(managers)
 #' print(BernadoLedoitratio(managers['1996']))

Modified: pkg/PerformanceAnalytics/R/DownsideDeviation.R
===================================================================
--- pkg/PerformanceAnalytics/R/DownsideDeviation.R	2012-06-20 15:42:55 UTC (rev 2043)
+++ pkg/PerformanceAnalytics/R/DownsideDeviation.R	2012-06-20 16:03:56 UTC (rev 2044)
@@ -86,11 +86,10 @@
 #'
 #' #with data used in Bacon 2008
 #'
-#' portfolio_return <- c(0.3,2.6,1.1,-1.0,1.5,2.5,1.6,6.7,-1.4,4.0,-0.5,8.1,4.0,-3.7,
-#' -6.1,1.7,-4.9,-2.2,7.0,5.8,-6.5,2.4,-0.5,-0.9)
+#' data(portfolio_bacon)
 #' MAR = 0.5
-#' DownsideDeviation(portfolio_return, MAR) #expected 2.55
-#' DownsidePotential(portfolio_return, MAR) #expected 1.37
+#' DownsideDeviation(portfolio_bacon, MAR) #expected 2.55
+#' DownsidePotential(portfolio_bacon, MAR) #expected 1.37
 #' 
 #' #with data of managers
 #'

Modified: pkg/PerformanceAnalytics/R/DownsideFrequency.R
===================================================================
--- pkg/PerformanceAnalytics/R/DownsideFrequency.R	2012-06-20 15:42:55 UTC (rev 2043)
+++ pkg/PerformanceAnalytics/R/DownsideFrequency.R	2012-06-20 16:03:56 UTC (rev 2044)
@@ -24,7 +24,7 @@
 #' @examples
 #' data(portfolio_bacon)
 #' MAR = 0.5
-#' print(DownsideFrequency(portfolio_return, MAR)) #expected 0.458
+#' print(DownsideFrequency(portfolio_bacon, MAR)) #expected 0.458
 #'
 #' data(managers)
 #' print(DownsideFrequency(managers['1996']))

Modified: pkg/PerformanceAnalytics/R/UpsideFrequency.R
===================================================================
--- pkg/PerformanceAnalytics/R/UpsideFrequency.R	2012-06-20 15:42:55 UTC (rev 2043)
+++ pkg/PerformanceAnalytics/R/UpsideFrequency.R	2012-06-20 16:03:56 UTC (rev 2044)
@@ -24,7 +24,7 @@
 #' @examples
 #' data(portfolio_bacon)
 #' MAR = 0.5
-#' print(UpsideFrequency(portfolio_return, MAR)) #expected 0.542
+#' print(UpsideFrequency(portfolio_bacon, MAR)) #expected 0.542
 #'
 #' data(managers)
 #' print(UpsideFrequency(managers['1996']))

Modified: pkg/PerformanceAnalytics/R/UpsideRisk.R
===================================================================
--- pkg/PerformanceAnalytics/R/UpsideRisk.R	2012-06-20 15:42:55 UTC (rev 2043)
+++ pkg/PerformanceAnalytics/R/UpsideRisk.R	2012-06-20 16:03:56 UTC (rev 2044)
@@ -40,13 +40,17 @@
 #' @keywords ts multivariate distribution models
 #' @examples
 #'
-#' portfolio_return <- c(0.3,2.6,1.1,-1.0,1.5,2.5,1.6,6.7,-1.4,4.0,-0.5,8.1,4.0
-#' ,-3.7,-6.1,1.7,-4.9,-2.2,7.0,5.8,-6.5,2.4,-0.5,-0.9)
+#' data(portfolio_bacon)
 #' MAR = 0.5
-#' print(UpsideRisk(portfolio_return, MAR, stat="risk")) #expected 2.937
-#' print(UpsideRisk(portfolio_return, MAR, stat="variance")) #expected 8.628
-#' print(UpsideRisk(portfolio_return, MAR, stat="potential")) #expected 1.771
+#' print(UpsideRisk(portfolio_bacon, MAR, stat="risk")) #expected 2.937
+#' print(UpsideRisk(portfolio_bacon, MAR, stat="variance")) #expected 8.628
+#' print(UpsideRisk(portfolio_bacon, MAR, stat="potential")) #expected 1.771
 #'
+#' MAR = 0
+#' data(managers)
+#' print(UpsideRisk(managers['1996'], MAR, stat="risk"))
+#' print(UpsideRisk(managers['1996',1], MAR, stat="risk")) #expected 1.820
+#'
 #' @export 
 
 #TODO tests for multi columns data
@@ -92,7 +96,6 @@
         result = apply(R, MARGIN = 2, UpsideRisk, MAR = MAR, method = method, stat = stat, ...)
         result<-t(result)
         colnames(result) = colnames(R)
-	print(MAR)
         rownames(result) = paste("Upside Risk (MAR = ",MAR,"%)", sep="")
         return(result)
     }



More information about the Returnanalytics-commits mailing list