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