[Robast-commits] r724 - in branches/robast-1.0/pkg/RobExtremes: . R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Feb 25 12:13:48 CET 2014


Author: ruckdeschel
Date: 2014-02-25 12:13:48 +0100 (Tue, 25 Feb 2014)
New Revision: 724

Added:
   branches/robast-1.0/pkg/RobExtremes/R/getCVaR.R
   branches/robast-1.0/pkg/RobExtremes/man/getCVaR.Rd
Modified:
   branches/robast-1.0/pkg/RobExtremes/NAMESPACE
Log:
RobExtremes: programmed risk measures VaR, CVaR, and EL for GPD, Weibull, Gamma, ... (ScaleShapeModels)

Modified: branches/robast-1.0/pkg/RobExtremes/NAMESPACE
===================================================================
--- branches/robast-1.0/pkg/RobExtremes/NAMESPACE	2014-02-24 20:55:46 UTC (rev 723)
+++ branches/robast-1.0/pkg/RobExtremes/NAMESPACE	2014-02-25 11:13:48 UTC (rev 724)
@@ -35,6 +35,7 @@
 			  "moveICBackFromRefParam")			  
 
 export("EULERMASCHERONICONSTANT","APERYCONSTANT")
+export("getCVaR", "getVaR", "getEL")
 export("Gumbel", "Pareto", "GPareto", "GEV")
 export("GParetoFamily", "GumbelLocationFamily", "WeibullFamily", "GEVFamily",
        "ParetoFamily", "GEVFamilyMuUnknown")

Added: branches/robast-1.0/pkg/RobExtremes/R/getCVaR.R
===================================================================
--- branches/robast-1.0/pkg/RobExtremes/R/getCVaR.R	                        (rev 0)
+++ branches/robast-1.0/pkg/RobExtremes/R/getCVaR.R	2014-02-25 11:13:48 UTC (rev 724)
@@ -0,0 +1,30 @@
+.getTau <- function(data, model, level, rob=TRUE, of.interest, what){
+  if(rob){
+     est <- roptest(data,model, risk=RMXRRisk())
+     L2FamC <- CallL2Fam(pIC(est))
+  }else{
+     est <- MLEstimator(data,model)
+     IC <- optIC(model,risk=asCov())
+     L2FamC <- CallL2Fam(IC)
+     L2FamC$scale <- estimate(est)["scale"]
+     L2FamC$shape <- estimate(est)["shape"]
+  }
+  eval(what)
+  L2FamC$of.interest <- of.interest # "quantile"
+  L2Fam <- eval(L2FamC)
+  res <- param(L2Fam)@trafo(estimate(est))
+  VaR <- res[[1]]
+  varVaR <- (res[[2]]) %*% asvar(est) %*% t(res[[2]])
+  return(c(VaR=VaR,sqrt(varVaR/length(data))))
+}
+
+getVaR <- function(data, model, level, rob=TRUE)
+             .getTau(data, model, level, rob, of.interest="quantile", substitute(L2FamC$p <- level))
+
+getCVaR <- function(data, model, level, rob=TRUE)
+             .getTau(data, model, level, rob, of.interest="expected shortfall", substitute(L2FamC$p <- level))
+
+getEL <- function(data, model, N0, rob=TRUE)
+             .getTau(data, model, N0, rob, of.interest="expected loss", substitute(L2FamC$N <- N0))
+
+

Added: branches/robast-1.0/pkg/RobExtremes/man/getCVaR.Rd
===================================================================
--- branches/robast-1.0/pkg/RobExtremes/man/getCVaR.Rd	                        (rev 0)
+++ branches/robast-1.0/pkg/RobExtremes/man/getCVaR.Rd	2014-02-25 11:13:48 UTC (rev 724)
@@ -0,0 +1,45 @@
+\name{getCVaR}
+\alias{getVaR}
+\alias{getVaR}
+\alias{getEL}
+
+\title{Risk Measures for Scale-Shape Families}
+\description{
+  Functions to compute Value-at-Risk (VaR), Conditional Value-at-Risk (CVaR)
+  and Expected Loss (EL) at data from scale-shape families.
+}
+\usage{
+getVaR(data, model, level, rob=TRUE)
+getCVaR(data, model, level, rob=TRUE)
+getEL(data, model, N0, rob=TRUE)
+}
+\arguments{
+  \item{data}{data at which to compute the risk measure. }
+  \item{model}{an object of class \code{"L2ScaleShapeFamily"}.
+               The parametric family at which to evaluate the risk measure. }
+  \item{level}{real: probability needed for VaR and CVaR. }
+  \item{N0}{real: expected frequency for expected loss }
+  \item{rob}{logical; if \code{TRUE} (default) the RMXE-parametric estimator is
+             used; otherwise the MLE.}
+ }
+\references{
+P. Ruckdeschel, N. Horbenko (2013): Optimally-Robust Estimators in Generalized
+Pareto Models. Statistics 47(4), 762--791.
+N. Horbenko, P. Ruckdeschel, T. Bae (2011): Robust Estimation of Operational Risk.
+Journal of Operational Risk 6(2), 3--30.
+}
+\author{Peter Ruckdeschel \email{Peter.Ruckdeschel at itwm.fraunhofer.de}}
+\seealso{\code{\link{GParetoFamily}}, \code{\link{GEVFamily}}, \code{\link{WeibullFamily}}, \code{\link{GammaFamily}}}
+\examples{
+  set.seed(123)
+  GPD <- GPartoFamily(loc=20480, scale=7e4, shape=0.3)
+  data <- r(GPD)(500)
+  getVaR(data,GPD,0.99)
+  getVaR(data,GPD,0.99, rob=FALSE)
+  getCVaR(data,GPD,0.99)
+  getCVaR(data,GPD,0.99, rob=FALSE)
+  getEL(data,GPD,5)
+  getEL(data,GPD,5, rob=FALSE)
+}
+\concept{estimator}
+\keyword{risk measure}



More information about the Robast-commits mailing list