[Returnanalytics-commits] r3762 - in pkg/Dowd: R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Jun 30 10:45:48 CEST 2015
Author: dacharya
Date: 2015-06-30 10:45:48 +0200 (Tue, 30 Jun 2015)
New Revision: 3762
Added:
pkg/Dowd/R/KernelESEpanechinikovKernel.R
pkg/Dowd/man/KernelESEpanechinikovKernel.Rd
Log:
KernelESEpanechinikovKernel function added.
Added: pkg/Dowd/R/KernelESEpanechinikovKernel.R
===================================================================
--- pkg/Dowd/R/KernelESEpanechinikovKernel.R (rev 0)
+++ pkg/Dowd/R/KernelESEpanechinikovKernel.R 2015-06-30 08:45:48 UTC (rev 3762)
@@ -0,0 +1,29 @@
+#' Calculates ES using Epanechinikov kernel approach
+#'
+#' The output consists of a scalar ES for specified confidence level.
+#'
+#' @param Ra Profit and Loss data set
+#' @param cl ES confidence level
+#' @return Scalar ES
+#' @references Dowd, K. Measuring Market Risk, Wiley, 2007.
+#'
+#' @author Dinesh Acharya
+#' @examples
+#'
+#' # ES for specified confidence level using Epanechinikov kernel approach
+#' Ra <- rnorm(30)
+#' KernelESEpanechinikovKernel(Ra, .95)
+#'
+#' @export
+KernelESEpanechinikovKernel <- 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] <- KernelVaREpanechinikovKernel(PandL, cl + i * delta.cl)
+ }
+ ES <- mean(VaR)
+ return(ES)
+
+}
\ No newline at end of file
Added: pkg/Dowd/man/KernelESEpanechinikovKernel.Rd
===================================================================
--- pkg/Dowd/man/KernelESEpanechinikovKernel.Rd (rev 0)
+++ pkg/Dowd/man/KernelESEpanechinikovKernel.Rd 2015-06-30 08:45:48 UTC (rev 3762)
@@ -0,0 +1,31 @@
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/KernelESEpanechinikovKernel.R
+\name{KernelESEpanechinikovKernel}
+\alias{KernelESEpanechinikovKernel}
+\title{Calculates ES using Epanechinikov kernel approach}
+\usage{
+KernelESEpanechinikovKernel(Ra, cl)
+}
+\arguments{
+\item{Ra}{Profit and Loss data set}
+
+\item{cl}{ES confidence level}
+}
+\value{
+Scalar ES
+}
+\description{
+The output consists of a scalar ES for specified confidence level.
+}
+\examples{
+# ES for specified confidence level using Epanechinikov kernel approach
+ Ra <- rnorm(30)
+ KernelESEpanechinikovKernel(Ra, .95)
+}
+\author{
+Dinesh Acharya
+}
+\references{
+Dowd, K. Measuring Market Risk, Wiley, 2007.
+}
+
More information about the Returnanalytics-commits
mailing list