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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Mar 6 17:01:29 CET 2016


Author: bodanker
Date: 2016-03-06 17:01:29 +0100 (Sun, 06 Mar 2016)
New Revision: 4008

Modified:
   pkg/PerformanceAnalytics/R/ES.R
Log:
Add reasonableness check for non-finite ES

If any of the various ES functions returns NaN, +/-Inf, NA, etc,
the first reasonableness check fails because you cannot compare
non-finite values in an if-statement.

Thanks to cloudcello for the report.


Modified: pkg/PerformanceAnalytics/R/ES.R
===================================================================
--- pkg/PerformanceAnalytics/R/ES.R	2016-03-06 15:16:41 UTC (rev 4007)
+++ pkg/PerformanceAnalytics/R/ES.R	2016-03-06 16:01:29 UTC (rev 4008)
@@ -194,6 +194,11 @@
             columns<-ncol(rES)
             for(column in 1:columns) {
                 tmp=rES[,column]
+                if (!is.finite(tmp)) {
+                    message(c("ES calculation returned non-finite result for column: ", column, " : ", rES[, column]))
+                    # set ES to NA, since risk is unreasonable
+                    rES[, column] <- NA
+                } else
                 if (eval(0 > tmp)) { #eval added previously to get around Sweave bitching
                     message(c("ES calculation produces unreliable result (inverse risk) for column: ",column," : ",rES[,column]))
                     # set ES to NA, since inverse risk is unreasonable
@@ -243,4 +248,4 @@
 #
 # $Id$
 #
-###############################################################################
\ No newline at end of file
+###############################################################################



More information about the Returnanalytics-commits mailing list