[Returnanalytics-commits] r2993 - pkg/PerformanceAnalytics/sandbox/pulkit/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Sep 5 02:11:34 CEST 2013


Author: pulkit
Date: 2013-09-05 02:11:33 +0200 (Thu, 05 Sep 2013)
New Revision: 2993

Modified:
   pkg/PerformanceAnalytics/sandbox/pulkit/R/MinTRL.R
Log:
Improved error handling in Minimum Track Record Length

Modified: pkg/PerformanceAnalytics/sandbox/pulkit/R/MinTRL.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/pulkit/R/MinTRL.R	2013-09-05 00:09:22 UTC (rev 2992)
+++ pkg/PerformanceAnalytics/sandbox/pulkit/R/MinTRL.R	2013-09-05 00:11:33 UTC (rev 2993)
@@ -98,12 +98,19 @@
     if(!is.null(dim(Rf))){
         Rf = checkData(Rf)
     }
-    #If the refSR is greater than SR an error is displayed
-    if(length(which(refSR>sr))!=0){
-        stop("The Reference Sharpe Ratio should be less than the Observed Sharpe Ratio")
+    index = which(refSR>sr)
+    if(length(index)!=0){
+        if(length(index)==columns){
+            stop("The reference Sharpe Ratio greater than the Observed Sharpe ratio for all the cases")
+        }
+        sr = sr[-index]
+        refSR = refSR[-index]
+        sk = sk[-index]
+        kr = kr[-index]
+        warning(paste("The Reference Sharpe Ratio greater than the Observed Sharpe Ratio for case",columnnames[index],"\n"))    
     }
-
     result = 1 + (1 - sk*sr + ((kr-1)/4)*sr^2)*(qnorm(p)/(sr-refSR))^2
+    columnnames = columnnames[-index]
     if(!is.null(dim(result))){ 
       colnames(result) = paste(columnnames,"(SR >",refSR,")") 
       rownames(result) = paste("Probabilistic Sharpe Ratio(p=",round(p*100,1),"%):")



More information about the Returnanalytics-commits mailing list