[Returnanalytics-commits] r3652 - in pkg/Dowd: R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed May 27 17:43:37 CEST 2015


Author: dacharya
Date: 2015-05-27 17:43:36 +0200 (Wed, 27 May 2015)
New Revision: 3652

Added:
   pkg/Dowd/R/LopezBacktest.R
   pkg/Dowd/man/LopezBacktest.Rd
Log:
LopezBacktest: source and documentation.

Added: pkg/Dowd/R/LopezBacktest.R
===================================================================
--- pkg/Dowd/R/LopezBacktest.R	                        (rev 0)
+++ pkg/Dowd/R/LopezBacktest.R	2015-05-27 15:43:36 UTC (rev 3652)
@@ -0,0 +1,37 @@
+#' First (binomial) Lopez forecast evaluation backtest score measure
+#'
+#' Derives the first Lopez (i.e. binomial) forecast evaluation score
+#' for a VaR risk measurement model.
+#' 
+#' @param Ra Vector of portfolio of profit loss distribution
+#' @param Rb Vector of corresponding VaR forecasts
+#' @param cl VaR confidence level
+#' @return Something
+#' 
+#' @references Dowd, K. Measuring Market Risk, Wiley, 2007.
+#' 
+#' Lopez, J. A. Methods for Evaluating Value-at-Risk Estimates. Federal Reserve
+#' Bank of New York Economic Policy Review, 1998, p. 121.
+#' 
+#' Lopez, J. A. Regulatory Evaluations of Value-at-Risk Models. Journal of Risk
+#' 1999, 37-64.
+#' 
+#' @author Dinesh Acharya
+#' @examples
+#' 			# To be added
+#'
+#' @export
+LopezBacktest <- function(Ra, Rb, cl){
+  
+  profit.loss <- as.vector(Ra)
+  VaR <- as.vector(Rb)
+  
+  n <- length(profit.loss)
+  p <- 1-cl
+  excess.loss <- profit.loss-VaR # Derives excess loss
+  excess.loss <- excess.loss[excess.loss>0] # Gets rid of non-positive excess
+  x <- length(excess.loss) # Score for each positive excess loss observation
+  y <- (2/n)*sum(x-n*p)^2 # Score measure
+  return(y)
+  
+}
\ No newline at end of file

Added: pkg/Dowd/man/LopezBacktest.Rd
===================================================================
--- pkg/Dowd/man/LopezBacktest.Rd	                        (rev 0)
+++ pkg/Dowd/man/LopezBacktest.Rd	2015-05-27 15:43:36 UTC (rev 3652)
@@ -0,0 +1,38 @@
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/LopezBacktest.R
+\name{LopezBacktest}
+\alias{LopezBacktest}
+\title{First (binomial) Lopez forecast evaluation backtest score measure}
+\usage{
+LopezBacktest(Ra, Rb, cl)
+}
+\arguments{
+\item{Ra}{Vector of portfolio of profit loss distribution}
+
+\item{Rb}{Vector of corresponding VaR forecasts}
+
+\item{cl}{VaR confidence level}
+}
+\value{
+Something
+}
+\description{
+Derives the first Lopez (i.e. binomial) forecast evaluation score
+for a VaR risk measurement model.
+}
+\examples{
+# To be added
+}
+\author{
+Dinesh Acharya
+}
+\references{
+Dowd, K. Measuring Market Risk, Wiley, 2007.
+
+Lopez, J. A. Methods for Evaluating Value-at-Risk Estimates. Federal Reserve
+Bank of New York Economic Policy Review, 1998, p. 121.
+
+Lopez, J. A. Regulatory Evaluations of Value-at-Risk Models. Journal of Risk
+1999, 37-64.
+}
+



More information about the Returnanalytics-commits mailing list