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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Sep 5 02:09:22 CEST 2013


Author: pulkit
Date: 2013-09-05 02:09:22 +0200 (Thu, 05 Sep 2013)
New Revision: 2992

Modified:
   pkg/PerformanceAnalytics/sandbox/pulkit/R/ProbSharpeRatio.R
Log:
Improved error handling in Probabilistic Sharpe Ratio

Modified: pkg/PerformanceAnalytics/sandbox/pulkit/R/ProbSharpeRatio.R
===================================================================
--- pkg/PerformanceAnalytics/sandbox/pulkit/R/ProbSharpeRatio.R	2013-09-04 23:09:17 UTC (rev 2991)
+++ pkg/PerformanceAnalytics/sandbox/pulkit/R/ProbSharpeRatio.R	2013-09-05 00:09:22 UTC (rev 2992)
@@ -97,12 +97,23 @@
         Rf = checkData(Rf)
     }
     #If the Reference Sharpe Ratio is greater than the Observred Sharpe Ratio 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 = pnorm(((sr - refSR)*(n-1)^(0.5))/(1-sr*sk+sr^2*(kr-1)/4)^(0.5))
+    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),"%):")
     }
     return(result)



More information about the Returnanalytics-commits mailing list