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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Jul 27 17:13:25 CEST 2012


Author: peter_carl
Date: 2012-07-27 17:13:25 +0200 (Fri, 27 Jul 2012)
New Revision: 2210

Modified:
   pkg/PerformanceAnalytics/R/PortfolioRisk.R
Log:
- fixed corner case in ES.historical where no observations are larger than VaR
- in that case, set ES = VaR and warn the user


Modified: pkg/PerformanceAnalytics/R/PortfolioRisk.R
===================================================================
--- pkg/PerformanceAnalytics/R/PortfolioRisk.R	2012-07-26 23:37:28 UTC (rev 2209)
+++ pkg/PerformanceAnalytics/R/PortfolioRisk.R	2012-07-27 15:13:25 UTC (rev 2210)
@@ -513,6 +513,11 @@
 	q = quantile(r,probs=alpha)
 	exceedr = r[r<q]
 	hES = (-mean(exceedr))
+        if(is.nan(hES)){
+          warning(paste(colnames(R[,column]),"No values less than VaR observed.  Setting ES equal to VaR."))
+          hES=q
+        }
+          
         hES=array(hES)
         if (column==1) {
             #create data.frame



More information about the Returnanalytics-commits mailing list