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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Jul 5 22:31:58 CEST 2015


Author: dacharya
Date: 2015-07-05 22:31:58 +0200 (Sun, 05 Jul 2015)
New Revision: 3777

Added:
   pkg/Dowd/R/KernelESBoxKernel.R
   pkg/Dowd/man/KernelESBoxKernel.Rd
Log:
KernelESBoxKernel added.

Added: pkg/Dowd/R/KernelESBoxKernel.R
===================================================================
--- pkg/Dowd/R/KernelESBoxKernel.R	                        (rev 0)
+++ pkg/Dowd/R/KernelESBoxKernel.R	2015-07-05 20:31:58 UTC (rev 3777)
@@ -0,0 +1,29 @@
+#' Calculates ES using box kernel approach
+#' 
+#' The output consists of a scalar ES for specified confidence level.
+#' 
+#' @param Ra Profit and Loss data set
+#' @param cl VaR confidence level
+#' @return Scalar VaR
+#' @references Dowd, K. Measuring Market Risk, Wiley, 2007.
+#'
+#' @author Dinesh Acharya
+#' @examples
+#' 
+#'    # VaR for specified confidence level using box kernel approach
+#'    Ra <- rnorm(30)
+#'    KernelESBoxKernel(Ra, .95)
+#'
+#' @export
+KernelESBoxKernel <- function(Ra, cl){
+  PandL <- as.vector(Ra)
+  n <- 1000
+  delta.cl <- (1 - cl) / n
+  VaR <- double(999)
+  for (i in 1:(n - 1)) {
+    VaR[i] <- KernelVaRBoxKernel(PandL, cl + i * delta.cl)
+  }
+  ES <- mean(VaR)
+  return(ES)
+  
+}

Added: pkg/Dowd/man/KernelESBoxKernel.Rd
===================================================================
--- pkg/Dowd/man/KernelESBoxKernel.Rd	                        (rev 0)
+++ pkg/Dowd/man/KernelESBoxKernel.Rd	2015-07-05 20:31:58 UTC (rev 3777)
@@ -0,0 +1,31 @@
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/KernelESBoxKernel.R
+\name{KernelESBoxKernel}
+\alias{KernelESBoxKernel}
+\title{Calculates ES using box kernel approach}
+\usage{
+KernelESBoxKernel(Ra, cl)
+}
+\arguments{
+\item{Ra}{Profit and Loss data set}
+
+\item{cl}{VaR confidence level}
+}
+\value{
+Scalar VaR
+}
+\description{
+The output consists of a scalar ES for specified confidence level.
+}
+\examples{
+# VaR for specified confidence level using box kernel approach
+   Ra <- rnorm(30)
+   KernelESBoxKernel(Ra, .95)
+}
+\author{
+Dinesh Acharya
+}
+\references{
+Dowd, K. Measuring Market Risk, Wiley, 2007.
+}
+



More information about the Returnanalytics-commits mailing list