[Robast-commits] r663 - branches/robast-0.9/pkg/RobExtremes/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri May 24 18:27:02 CEST 2013


Author: ruckdeschel
Date: 2013-05-24 18:27:02 +0200 (Fri, 24 May 2013)
New Revision: 663

Modified:
   branches/robast-0.9/pkg/RobExtremes/R/GEVFamily.R
Log:
fixed error in ES in GEVFamily.R discovered by Gerald and found yet other faults in EL

Modified: branches/robast-0.9/pkg/RobExtremes/R/GEVFamily.R
===================================================================
--- branches/robast-0.9/pkg/RobExtremes/R/GEVFamily.R	2013-05-24 15:48:39 UTC (rev 662)
+++ branches/robast-0.9/pkg/RobExtremes/R/GEVFamily.R	2013-05-24 16:27:02 UTC (rev 663)
@@ -173,7 +173,7 @@
                         D }, list(p0 = p))
        btes <- substitute({ if(theta[2]>=1L) es <- NA else {
                             pg <- pgamma(-log(p0),1-theta[2], lower.tail = TRUE)
-                            es <- theta[1] * (gamma(1-theta[2]) * pg/ p0 - 1 )/
+                            es <- theta[1] * (gamma(1-theta[2]) * pg/ (1-p0) - 1 )/
                                    theta[2]  + loc0 }
                             names(es) <- "expected shortfall"
                             es }, list(loc0 = loc, p0 = p))
@@ -182,9 +182,9 @@
                             pg <- pgamma(-log(p0), 1-theta[2], lower.tail = TRUE)
                             dd <- ddigamma(-log(p0),1-theta[2])
                             g0 <- gamma(1-theta[2])
-                            D1 <- (g0*pg/p0-1)/theta[2]
+                            D1 <- (g0*pg/(1-p0)-1)/theta[2]
                             D21 <- theta[1]*D1/theta[2]
-                            D22 <- theta[1]*dd/p0/theta[2]
+                            D22 <- theta[1]*dd/(1-p0)/theta[2]
                             D2 <- -D21+D22}
                             D <- t(c(D1, D2))
                             rownames(D) <- "expected shortfall"
@@ -193,14 +193,14 @@
     }
     if(!is.null(N)){
        btel <- substitute({ if(theta[2]>=1L) el <- NA else{
-                            el <- N0*(loc0+theta[1]*gamma(1-theta[2])/theta[2])}
+                            el <- N0*(loc0+theta[1]*(gamma(1-theta[2])-1)/theta[2])}
                             names(el) <- "expected loss"
                             el }, list(loc0 = loc,N0 = N))
        bDel <- substitute({ if(theta[2]>=1L){ D1 <- D2 <- NA}else{
                             scale <- theta[1]; shape <- theta[2]
-                            D1 <- N0*gamma(1-shape)/shape
+                            D1 <- N0*(gamma(1-shape)-1)/shape
                             D2 <- -N0*theta[1]*digamma(1-theta[2])/theta[2]-
-                                   D1*scale/(1-shape)}
+                                   D1*scale/shape}
                             D <- t(c(D1, D2))
                             rownames(D) <- "expected loss"
                             colnames(D) <- NULL



More information about the Robast-commits mailing list