[Returnanalytics-commits] r3764 - in pkg/Dowd: R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Jun 30 10:47:19 CEST 2015
Author: dacharya
Date: 2015-06-30 10:47:19 +0200 (Tue, 30 Jun 2015)
New Revision: 3764
Added:
pkg/Dowd/R/KernelESTriangleKernel.R
pkg/Dowd/man/KernelESTriangleKernel.Rd
Log:
KernelESTriangleKernel function added.
Added: pkg/Dowd/R/KernelESTriangleKernel.R
===================================================================
--- pkg/Dowd/R/KernelESTriangleKernel.R (rev 0)
+++ pkg/Dowd/R/KernelESTriangleKernel.R 2015-06-30 08:47:19 UTC (rev 3764)
@@ -0,0 +1,29 @@
+#' Calculates ES using triangle 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 triangle kernel approach
+#' Ra <- rnorm(30)
+#' KernelESTriangleKernel(Ra, .95)
+#'
+#' @export
+KernelESTriangleKernel <- 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] <- KernelVaRTriangleKernel(PandL, cl + i * delta.cl)
+ }
+ ES <- mean(VaR)
+ return(ES)
+
+}
Added: pkg/Dowd/man/KernelESTriangleKernel.Rd
===================================================================
--- pkg/Dowd/man/KernelESTriangleKernel.Rd (rev 0)
+++ pkg/Dowd/man/KernelESTriangleKernel.Rd 2015-06-30 08:47:19 UTC (rev 3764)
@@ -0,0 +1,31 @@
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/KernelESTriangleKernel.R
+\name{KernelESTriangleKernel}
+\alias{KernelESTriangleKernel}
+\title{Calculates ES using triangle kernel approach}
+\usage{
+KernelESTriangleKernel(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 triangle kernel approach
+ Ra <- rnorm(30)
+ KernelESTriangleKernel(Ra, .95)
+}
+\author{
+Dinesh Acharya
+}
+\references{
+Dowd, K. Measuring Market Risk, Wiley, 2007.
+}
+
More information about the Returnanalytics-commits
mailing list