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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri May 29 23:20:42 CEST 2015


Author: dacharya
Date: 2015-05-29 23:20:41 +0200 (Fri, 29 May 2015)
New Revision: 3658

Added:
   pkg/Dowd/R/BootstrapESConfInterval.R
   pkg/Dowd/R/BootstrapESFigure.R
   pkg/Dowd/R/BootstrapVaR.R
   pkg/Dowd/R/BootstrapVaRConfInterval.R
   pkg/Dowd/R/BootstrapVaRFigure.R
   pkg/Dowd/man/BootstrapESConfInterval.Rd
   pkg/Dowd/man/BootstrapESFigure.Rd
   pkg/Dowd/man/BootstrapVaR.Rd
   pkg/Dowd/man/BootstrapVarConfInterval.Rd
Modified:
   pkg/Dowd/DESCRIPTION
   pkg/Dowd/NAMESPACE
   pkg/Dowd/R/BootstrapES.R
   pkg/Dowd/R/HSES.R
   pkg/Dowd/man/BootstrapES.Rd
   pkg/Dowd/readme.txt
Log:
Source and documentation for BootstrapES, BootstrapESConfInterval, BootstrapESFigure, BootstrapVaR, BootstrapVaRConfInterval, BootstrapVaRFigure,

Modified: pkg/Dowd/DESCRIPTION
===================================================================
--- pkg/Dowd/DESCRIPTION	2015-05-29 03:26:24 UTC (rev 3657)
+++ pkg/Dowd/DESCRIPTION	2015-05-29 21:20:41 UTC (rev 3658)
@@ -1,12 +1,14 @@
 Package: Dowd
 Type: Package
-Title: R-version of Matlab Toolbox offered in Kevin Dowd's book Measuring Market Risk
+Title: R-version of MMR II toolbox offered in Kevin Dowd's book Measuring Market Risk
 Version: 0.1
 Date: 2015-05-24
 Author: Dinesh Acharya <dines.acharya at gmail.com>
 Maintainer: Dinesh Acharya <dines.acharya at gmail.com>
-Description: 
-Depends: R (>= 2.14.0)
-Suggests: PerformanceAnalytics,
-    testthat
+Description: This package is R-version of MMR2 Toolbox that supplements
+          Kevin Dowd's book measuring market risk.
+Depends: R (>= 3.0.0), 
+          bootstrap
+Suggests: PerformanceAnalytics, 
+          testthat
 License: GNU Public License

Modified: pkg/Dowd/NAMESPACE
===================================================================
--- pkg/Dowd/NAMESPACE	2015-05-29 03:26:24 UTC (rev 3657)
+++ pkg/Dowd/NAMESPACE	2015-05-29 21:20:41 UTC (rev 3658)
@@ -4,6 +4,10 @@
 export(BinomialBacktest)
 export(BlancoIhleBacktest)
 export(BootstrapES)
+export(BootstrapESConfInterval)
+export(BootstrapESFigure)
+export(BootstrapVaR)
+export(BootstrapVarConfInterval)
 export(ChristoffersenBacktestForIndependence)
 export(ChristoffersenBacktestForUnconditionalCoverage)
 export(HSES)

Modified: pkg/Dowd/R/BootstrapES.R
===================================================================
--- pkg/Dowd/R/BootstrapES.R	2015-05-29 03:26:24 UTC (rev 3657)
+++ pkg/Dowd/R/BootstrapES.R	2015-05-29 21:20:41 UTC (rev 3658)
@@ -4,8 +4,8 @@
 #' implied by data frequency.
 #'
 #' @param Ra Vector corresponding to profit and loss distribution
-#' @param number.sample Number of samples to be taken in bootstrap procedure
-#' @return cl Number corresponding to Value at Risk confidence level
+#' @param number.resamples Number of samples to be taken in bootstrap procedure
+#' @return cl Number corresponding to Expected Shortfall confidence level
 #' 
 #' @references Dowd, K. Measuring Market Risk, Wiley, 2007.
 #' 
@@ -13,12 +13,12 @@
 #' @author Dinesh Acharya
 #' @examples
 #' 
-#'    # Estimates bootstrapped Es for given parameters
+#'    # Estimates bootstrapped ES for given parameters
 #'    a <- rnorm(100) # generate a random profit/loss vector
-#'    BootstrappedES(a, 50, 0.95)
+#'    BootstrapVaR(a, 50, 0.95)
 #'
 #' @export
-BootstrapES <- function(Ra, number.sample, cl){
+BootstrapES <- function(Ra, number.resamples, cl){
   
   if (nargs() < 3){
     error("Too few arguments")
@@ -37,7 +37,7 @@
   if (length(cl) != 1) {
     error("Confidence level must be a scalar")
   }
-  if (length(number.samples) != 1){
+  if (length(number.resamples) != 1){
     error("Number of resamples must be a scalar");
   }
   
@@ -45,16 +45,17 @@
   if (cl >= 1){
     stop("Confidence level must be less that 1")
   }
+  if (cl <= 0){
+    stop("Confidence level must be at least 0")
+  }
   if (number.resamples <= 0){
     stop("Number of resamples must be at least 0")
   }
   
-  #############################################
-  # suitable alternative to bootstrp in R is still to be explored.
-  #############################################
+  # Load bootstrap package
+  library(bootstrap)
   # ES estimation
-  #
-  # es <- bootstrp(number.resamples, "hses", losses.data, cl)
-  # y <- mean(es)
-  # return (y)
+  es <- bootstrap(losses.data, number.resamples, HSES, cl)$thetastar
+  y <- mean(es)
+  return (y)
 }
\ No newline at end of file

Added: pkg/Dowd/R/BootstrapESConfInterval.R
===================================================================
--- pkg/Dowd/R/BootstrapESConfInterval.R	                        (rev 0)
+++ pkg/Dowd/R/BootstrapESConfInterval.R	2015-05-29 21:20:41 UTC (rev 3658)
@@ -0,0 +1,66 @@
+#' Bootstrapped ES Confidence Interval
+#'
+#' Estimates the 90% confidence interval for bootstrapped ES, for confidence
+#' level and holding period implied by data frequency.
+#'
+#' @param Ra Vector corresponding to profit and loss distribution
+#' @param number.resample Number of samples to be taken in bootstrap procedure
+#' @param cl Number corresponding to Expected Shortfall confidence level
+#' @return 90% Confidence interval for bootstrapped ES
+#' 
+#' @references Dowd, K. Measuring Market Risk, Wiley, 2007.
+#' 
+#' 
+#' @author Dinesh Acharya
+#' @examples
+#' 
+#'    # To be modified with appropriate data.
+#'    # Estimates 90% confidence interval for bootstrapped ES for 95% 
+#'    # confidence interval 
+#'    Ra <- rnorm(1000)
+#'    BootstrapESConfInterval(Ra, 50, 0.95)
+#'
+#' @export
+BootstrapESConfInterval <- function(Ra, number.resamples, cl){
+  
+  # Determine if there are three arguments
+  if (nargs() < 3){
+    stop("Too few arguments")
+  }
+  if (nargs() > 3){
+    stop("Too many arguments")
+  }
+  
+  profit.loss.data <- as.vector(Ra)
+  
+  # Preprocess data
+  unsorted.loss.data <- -profit.loss.data # Derives L/P data from input P/L data
+  losses.data <- sort(unsorted.loss.data) # Puts losses in ascending order
+  n <- length(losses.data)
+  
+  # Check that inputs have correct dimensions
+  if (is.vector(cl) & (length(cl) != 1) ) {
+    error("Confidence level must be a scalar")
+  }
+  if (length(number.resamples) != 1) {
+    error("Number of resamples must be a scalar")
+  }
+  # Check that inputs obey sign and value restrictions
+  if (cl >= 1){
+    stop("Confidence level must be less that 1")
+  }
+  if (cl <= 0){
+    stop("Confidence level must be at least 0")
+  }
+  if (number.resamples <= 0){
+    stop("Number of resamples must be at least 0")
+  }
+  
+  library(bootstrap)
+  
+  # ES estimation
+  es <- bootstrap(losses.data, number.resamples, HSES, cl)[1]
+  y <- quantile(es, c(.05, .95))
+  return(y)
+  
+}
\ No newline at end of file

Added: pkg/Dowd/R/BootstrapESFigure.R
===================================================================
--- pkg/Dowd/R/BootstrapESFigure.R	                        (rev 0)
+++ pkg/Dowd/R/BootstrapESFigure.R	2015-05-29 21:20:41 UTC (rev 3658)
@@ -0,0 +1,72 @@
+#' Plots figure of bootstrapped ES
+#'
+#' Plots figure for the bootstrapped ES, for confidence
+#' level and holding period implied by data frequency.
+#'
+#' @param Ra Vector corresponding to profit and loss distribution
+#' @param number.resample Number of samples to be taken in bootstrap procedure
+#' @param cl Number corresponding to Expected Shortfall confidence level
+#' 
+#' @references Dowd, K. Measuring Market Risk, Wiley, 2007.
+#' 
+#' 
+#' @author Dinesh Acharya
+#' @examples
+#' 
+#'    # To be modified with appropriate data.
+#'    # Estimates 90% confidence interval for bootstrapped ES for 95% 
+#'    # confidence interval 
+#'    Ra <- rnorm(1000)
+#'    BootstrapESFigure(Ra, 500, 0.95)
+#'
+#' @export
+BootstrapESFigure <- function(Ra, number.resamples, cl){
+  
+  # Determine if there are three arguments
+  if (nargs() < 3){
+    stop("Too few arguments")
+  }
+  if (nargs() > 3){
+    stop("Too many arguments")
+  }
+  
+  profit.loss.data <- as.vector(Ra)
+  
+  # Preprocess data
+  unsorted.loss.data <- -profit.loss.data # Derives L/P data from input P/L data
+  losses.data <- sort(unsorted.loss.data) # Puts losses in ascending order
+  n <- length(losses.data)
+  
+  # Check that inputs have correct dimensions
+  if (is.vector(cl) & (length(cl) != 1) ) {
+    error("Confidence level must be a scalar")
+  }
+  if (length(number.resamples) != 1) {
+    error("Number of resamples must be a scalar")
+  }
+  # Check that inputs obey sign and value restrictions
+  if (cl >= 1){
+    stop("Confidence level must be less that 1")
+  }
+  if (cl <= 0){
+    stop("Confidence level must be at least 0")
+  }
+  if (number.resamples <= 0){
+    stop("Number of resamples must be at least 0")
+  }
+  
+  library(bootstrap)
+  
+  # ES Estimation
+  es <- bootstrap(losses.data, number.resamples, HSES, cl)$thetastar
+  mean.es <- mean(es)
+  std.es <- sd(es)
+  min.es <- min(es)
+  max.es <- max(es)
+  ninety.five.perc.conf.interval <- quantile(es, c(.05, .95))
+  
+  # Histogram
+  cl.for.label <- 100*cl
+  hist(es, 30, xlab="ES", ylab="Frequency", main=paste("Bootstrapped Historical Simulation ES at", cl, "% Confidence Level"))
+  
+}
\ No newline at end of file

Added: pkg/Dowd/R/BootstrapVaR.R
===================================================================
--- pkg/Dowd/R/BootstrapVaR.R	                        (rev 0)
+++ pkg/Dowd/R/BootstrapVaR.R	2015-05-29 21:20:41 UTC (rev 3658)
@@ -0,0 +1,61 @@
+#' Bootstrapped VaR for specified confidence level
+#'
+#' Estimates the bootstrapped VaR for confidence level and holding period
+#' implied by data frequency.
+#'
+#' @param Ra Vector corresponding to profit and loss distribution
+#' @param number.sample Number of samples to be taken in bootstrap procedure
+#' @return cl Number corresponding to Value at Risk confidence level
+#' 
+#' @references Dowd, K. Measuring Market Risk, Wiley, 2007.
+#' 
+#' 
+#' @author Dinesh Acharya
+#' @examples
+#' 
+#'    # Estimates bootstrapped VaR for given parameters
+#'    a <- rnorm(100) # generate a random profit/loss vector
+#'    BootstrapES(a, 50, 0.95)
+#'
+#' @export
+BootstrapVaR <- function(Ra, number.sample, cl){
+  
+  if (nargs() < 3){
+    error("Too few arguments")
+  }
+  if (nargs() > 3){
+    error("Too many arguments")
+  }
+  
+  profit.loss.data <- as.vector(Ra)
+  # Preprocess data
+  unsorted.loss.data <- -profit.loss.data
+  losses.data <- sort(unsorted.loss.data)
+  n <- length(losses.data)
+  
+  # Check that inputs have correct dimensions
+  if (length(cl) != 1) {
+    error("Confidence level must be a scalar")
+  }
+  if (length(number.samples) != 1){
+    error("Number of resamples must be a scalar");
+  }
+  
+  # Check that inputs obey sign and value restrictions
+  if (cl >= 1){
+    stop("Confidence level must be less that 1")
+  }
+  if (cl <= 0){
+    stop("Confidence level must be at least 0")
+  }
+  if (number.resamples <= 0){
+    stop("Number of resamples must be at least 0")
+  }
+  
+  # Load bootstrap package
+  library(bootstrap)
+  # ES estimation
+  VaR <- bootstrap(losses.data, number.resamples, HSVaR, cl)$thetastar
+  y <- mean(VaR)
+  return (y)
+}
\ No newline at end of file

Added: pkg/Dowd/R/BootstrapVaRConfInterval.R
===================================================================
--- pkg/Dowd/R/BootstrapVaRConfInterval.R	                        (rev 0)
+++ pkg/Dowd/R/BootstrapVaRConfInterval.R	2015-05-29 21:20:41 UTC (rev 3658)
@@ -0,0 +1,66 @@
+#' Bootstrapped VaR Confidence Interval
+#'
+#' Estimates the 90% confidence interval for bootstrapped VaR, for confidence
+#' level and holding period implied by data frequency.
+#'
+#' @param Ra Vector corresponding to profit and loss distribution
+#' @param number.sample Number of samples to be taken in bootstrap procedure
+#' @param cl Number corresponding to Value at Risk confidence level
+#' @return 90% Confidence interval for bootstrapped VaR
+#' 
+#' @references Dowd, K. Measuring Market Risk, Wiley, 2007.
+#' 
+#' 
+#' @author Dinesh Acharya
+#' @examples
+#' 
+#'    # To be modified with appropriate data.
+#'    # Estimates 90% confidence interval for bootstrapped Var for 95% 
+#'    # confidence interval 
+#'    Ra <- rnorm(1000)
+#'    BootstrapVarConfInterval(Ra, 500, 0.95)
+#'
+#' @export
+BootstrapVarConfInterval <- function(Ra, number.resamples, cl){
+  
+  # Determine if there are three arguments
+  if (nargs() < 3){
+    stop("Too few arguments")
+  }
+  if (nargs() > 3){
+    stop("Too many arguments")
+  }
+  
+  profit.loss.data <- as.vector(Ra)
+  
+  # Preprocess data
+  unsorted.loss.data <- -profit.loss.data # Derives L/P data from input P/L data
+  losses.data <- sort(unsorted.loss.data) # Puts losses in ascending order
+  n <- length(losses.data)
+  
+  # Check that inputs have correct dimensions
+  if (is.vector(cl) & (length(cl) != 1) ) {
+    error("Confidence level must be a scalar")
+  }
+  if (length(number.resamples) != 1) {
+    error("Number of resamples must be a scalar")
+  }
+  # Check that inputs obey sign and value restrictions
+  if (cl >= 1){
+    stop("Confidence level must be less that 1")
+  }
+  if (cl <= 0){
+    stop("Confidence level must be at least 0")
+  }
+  if (number.resamples <= 0){
+    stop("Number of resamples must be at least 0")
+  }
+  
+  library(bootstrap)
+  
+  # VaR estimation
+  VaR <- bootstrap(losses.data, number.resamples, HSVaR, cl)$thetastar
+  y <- quantile(VaR, c(.05, .95))
+  return(y)
+  
+}
\ No newline at end of file

Added: pkg/Dowd/R/BootstrapVaRFigure.R
===================================================================
--- pkg/Dowd/R/BootstrapVaRFigure.R	                        (rev 0)
+++ pkg/Dowd/R/BootstrapVaRFigure.R	2015-05-29 21:20:41 UTC (rev 3658)
@@ -0,0 +1,72 @@
+#' Plots figure of bootstrapped VaR
+#'
+#' Plots figure for the bootstrapped VaR, for confidence
+#' level and holding period implied by data frequency.
+#'
+#' @param Ra Vector corresponding to profit and loss distribution
+#' @param number.sample Number of samples to be taken in bootstrap procedure
+#' @param cl Number corresponding to Value at Risk confidence level
+#' 
+#' @references Dowd, K. Measuring Market Risk, Wiley, 2007.
+#' 
+#' 
+#' @author Dinesh Acharya
+#' @examples
+#' 
+#'    # To be modified with appropriate data.
+#'    # Estimates 90% confidence interval for bootstrapped VaR for 95% 
+#'    # confidence interval 
+#'    Ra <- rnorm(1000)
+#'    BootstrapESFigure(Ra, 500, 0.95)
+#'
+#' @export
+BootstrapESFigure <- function(Ra, number.resamples, cl){
+  
+  # Determine if there are three arguments
+  if (nargs() < 3){
+    stop("Too few arguments")
+  }
+  if (nargs() > 3){
+    stop("Too many arguments")
+  }
+  
+  profit.loss.data <- as.vector(Ra)
+  
+  # Preprocess data
+  unsorted.loss.data <- -profit.loss.data # Derives L/P data from input P/L data
+  losses.data <- sort(unsorted.loss.data) # Puts losses in ascending order
+  n <- length(losses.data)
+  
+  # Check that inputs have correct dimensions
+  if (is.vector(cl) & (length(cl) != 1) ) {
+    error("Confidence level must be a scalar")
+  }
+  if (length(number.resamples) != 1) {
+    error("Number of resamples must be a scalar")
+  }
+  # Check that inputs obey sign and value restrictions
+  if (cl >= 1){
+    stop("Confidence level must be less that 1")
+  }
+  if (cl <= 0){
+    stop("Confidence level must be at least 0")
+  }
+  if (number.resamples <= 0){
+    stop("Number of resamples must be at least 0")
+  }
+  
+  library(bootstrap)
+  
+  # ES Estimation
+  VaR <- bootstrap(losses.data, number.resamples, HSVaR, cl)$thetastar
+  mean.VaR <- mean(VaR)
+  std.VaR <- sd(VaR)
+  min.VaR <- min(VaR)
+  max.VaR <- max(VaR)
+  ninety.five.perc.conf.interval <- quantile(VaR, c(.05, .95))
+  
+  # Histogram
+  cl.for.label <- 100*cl
+  hist(VaR[1], 30, xlab="VaR", ylab="Frequency", main=paste("Bootstrapped Historical Simulation VaR at", cl, "% Confidence Level"))
+  
+}
\ No newline at end of file

Modified: pkg/Dowd/R/HSES.R
===================================================================
--- pkg/Dowd/R/HSES.R	2015-05-29 03:26:24 UTC (rev 3657)
+++ pkg/Dowd/R/HSES.R	2015-05-29 21:20:41 UTC (rev 3658)
@@ -41,7 +41,6 @@
     stop("Too many arguments")
   }
   
-  
   if (nargs() == 2) {
     profit.loss.data <- as.vector(Ra)
     unsorted.loss.data <- -profit.loss.data # Derives L/P data from input P/L
@@ -54,7 +53,6 @@
     stop('Confidence level must be scalar (length-1 vector in R)')
   }
   
-  
   # Check that inputs obey sign and value restrictions
   if (cl >= 1) {
     stop("Confidence level must be less than 1.")
@@ -63,14 +61,15 @@
     stop("Confidence level must be positive")
   }
   
+  # VaR and ES estimation
   index <- n*cl # This putative index value may or may not be an integer
   
   # Each case needs to be considered in turn
   # If index value is an integegr, VaR follows immediately and then we
   # estimate ES
   if (index-round(index)==0){
-    var <- losses.data[index] # Historical Value at Risk
-    k <- which[var <= losses.data] # Finds indices of tail loss data
+    VaR <- losses.data[index] # Historical Value at Risk
+    k <- which(VaR <= losses.data) # Finds indices of tail loss data
     tail.losses <- losses.data[k] # Creates data set of tail loss observations
     es <- mean(tail.losses) # Expected Shortfall
     y <- es    
@@ -82,27 +81,32 @@
   if (index-round(index) != 0){
     # Deal with loss
     upper.index <- ceiling(index)
-    upper.var <- losses.data(upper.index) # Upper VaR
-    upper.k <- which(upper.var<=losses.data) # Finds indices of upper tail loss data
-    upper.tail.losses <- losses.data(upper.k) # Creates data set of upper tail loss obs.
+    upper.VaR <- losses.data[upper.index] # Upper VaR
+    upper.k <- which(upper.VaR<=losses.data) # Finds indices of upper tail loss data
+    upper.tail.losses <- losses.data[upper.k] # Creates data set of upper tail loss obs.
+	upper.es <- mean(upper.tail.losses) # Upper ES
+	# Deal with loss observation just below VaR to derive lower ES
+	lower.index <- ceil(index)
+	lower.VaR <- losses.data[lower.index] # Lower VaR
+	lower.k <- which(lower.VaR <= losses.data) # Finds indices of lower tail loss data 
+	lower.tail.losses <- losses.data[lower.k] # Creates data set of lower tail loss obs.
+	lower.es <- mean(lower.tail.losses)# Lower ES
+	
     lower.es <- mean(lower.tail.losses) # Lower Expected Shortfall (ES)
     # If lower and upper indices are the same, ES is upper ES
     if (upper.index == lower.index){
       y <- upper.es
     }
-    # If lower and upper indices are different, ES is weighted average of 
+    # If lower and upper indices are different, ES is weighted average of
     # upper and lower ESs
     if (upper.index!=lower.index) {
       # Weights attached to upper and lower ESs
-      lower.weight <- (upper.index-index)/(upper.index-lower.index)
-      upper.weight <- (index-lower.index)/(upper.index-lower.index)
+      lower.weight <- (upper.index-index)/(upper.index-lower.index) # weight on upper_var
+      upper.weight <- (index-lower.index)/(upper.index-lower.index) # weight on upper_var
       # Finally, the weighted, ES as a linear interpolation of upper and lower
       # ESs
       y <- lower.weight*lower.es+upper.weight*upper.es
-  
     }
-    return(y)
   }
-  
-}
-
+  return(y)
+}
\ No newline at end of file

Modified: pkg/Dowd/man/BootstrapES.Rd
===================================================================
--- pkg/Dowd/man/BootstrapES.Rd	2015-05-29 03:26:24 UTC (rev 3657)
+++ pkg/Dowd/man/BootstrapES.Rd	2015-05-29 21:20:41 UTC (rev 3658)
@@ -4,24 +4,24 @@
 \alias{BootstrapES}
 \title{Bootstrapped ES for specified confidence level}
 \usage{
-BootstrapES(Ra, number.sample, cl)
+BootstrapES(Ra, number.resamples, cl)
 }
 \arguments{
 \item{Ra}{Vector corresponding to profit and loss distribution}
 
-\item{number.sample}{Number of samples to be taken in bootstrap procedure}
+\item{number.resamples}{Number of samples to be taken in bootstrap procedure}
 }
 \value{
-cl Number corresponding to Value at Risk confidence level
+cl Number corresponding to Expected Shortfall confidence level
 }
 \description{
 Estimates the bootstrapped ES for confidence level and holding period
 implied by data frequency.
 }
 \examples{
-# Estimates bootstrapped Es for given parameters
+# Estimates bootstrapped ES for given parameters
    a <- rnorm(100) # generate a random profit/loss vector
-   BootstrappedES(a, 50, 0.95)
+   BootstrapVaR(a, 50, 0.95)
 }
 \author{
 Dinesh Acharya

Added: pkg/Dowd/man/BootstrapESConfInterval.Rd
===================================================================
--- pkg/Dowd/man/BootstrapESConfInterval.Rd	                        (rev 0)
+++ pkg/Dowd/man/BootstrapESConfInterval.Rd	2015-05-29 21:20:41 UTC (rev 3658)
@@ -0,0 +1,36 @@
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/BootstrapESConfInterval.R
+\name{BootstrapESConfInterval}
+\alias{BootstrapESConfInterval}
+\title{Bootstrapped ES Confidence Interval}
+\usage{
+BootstrapESConfInterval(Ra, number.resamples, cl)
+}
+\arguments{
+\item{Ra}{Vector corresponding to profit and loss distribution}
+
+\item{cl}{Number corresponding to Expected Shortfall confidence level}
+
+\item{number.resample}{Number of samples to be taken in bootstrap procedure}
+}
+\value{
+90% Confidence interval for bootstrapped ES
+}
+\description{
+Estimates the 90% confidence interval for bootstrapped ES, for confidence
+level and holding period implied by data frequency.
+}
+\examples{
+# To be modified with appropriate data.
+   # Estimates 90\% confidence interval for bootstrapped ES for 95\%
+   # confidence interval
+   Ra <- rnorm(1000)
+   BootstrapESConfInterval(Ra, 50, 0.95)
+}
+\author{
+Dinesh Acharya
+}
+\references{
+Dowd, K. Measuring Market Risk, Wiley, 2007.
+}
+

Added: pkg/Dowd/man/BootstrapESFigure.Rd
===================================================================
--- pkg/Dowd/man/BootstrapESFigure.Rd	                        (rev 0)
+++ pkg/Dowd/man/BootstrapESFigure.Rd	2015-05-29 21:20:41 UTC (rev 3658)
@@ -0,0 +1,53 @@
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/BootstrapESFigure.R, R/BootstrapVaRFigure.R
+\name{BootstrapESFigure}
+\alias{BootstrapESFigure}
+\title{Plots figure of bootstrapped ES}
+\usage{
+BootstrapESFigure(Ra, number.resamples, cl)
+
+BootstrapESFigure(Ra, number.resamples, cl)
+}
+\arguments{
+\item{Ra}{Vector corresponding to profit and loss distribution}
+
+\item{cl}{Number corresponding to Expected Shortfall confidence level}
+
+\item{number.resample}{Number of samples to be taken in bootstrap procedure}
+
+\item{Ra}{Vector corresponding to profit and loss distribution}
+
+\item{number.sample}{Number of samples to be taken in bootstrap procedure}
+
+\item{cl}{Number corresponding to Value at Risk confidence level}
+}
+\description{
+Plots figure for the bootstrapped ES, for confidence
+level and holding period implied by data frequency.
+
+Plots figure for the bootstrapped VaR, for confidence
+level and holding period implied by data frequency.
+}
+\examples{
+# To be modified with appropriate data.
+   # Estimates 90\% confidence interval for bootstrapped ES for 95\%
+   # confidence interval
+   Ra <- rnorm(1000)
+   BootstrapESFigure(Ra, 500, 0.95)
+# To be modified with appropriate data.
+   # Estimates 90\% confidence interval for bootstrapped VaR for 95\%
+   # confidence interval
+   Ra <- rnorm(1000)
+   BootstrapESFigure(Ra, 500, 0.95)
+}
+\author{
+Dinesh Acharya
+
+Dinesh Acharya
+}
+\references{
+Dowd, K. Measuring Market Risk, Wiley, 2007.
+
+Dowd, K. Measuring Market Risk, Wiley, 2007.
+}
+

Added: pkg/Dowd/man/BootstrapVaR.Rd
===================================================================
--- pkg/Dowd/man/BootstrapVaR.Rd	                        (rev 0)
+++ pkg/Dowd/man/BootstrapVaR.Rd	2015-05-29 21:20:41 UTC (rev 3658)
@@ -0,0 +1,32 @@
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/BootstrapVaR.R
+\name{BootstrapVaR}
+\alias{BootstrapVaR}
+\title{Bootstrapped VaR for specified confidence level}
+\usage{
+BootstrapVaR(Ra, number.sample, cl)
+}
+\arguments{
+\item{Ra}{Vector corresponding to profit and loss distribution}
+
+\item{number.sample}{Number of samples to be taken in bootstrap procedure}
+}
+\value{
+cl Number corresponding to Value at Risk confidence level
+}
+\description{
+Estimates the bootstrapped VaR for confidence level and holding period
+implied by data frequency.
+}
+\examples{
+# Estimates bootstrapped VaR for given parameters
+   a <- rnorm(100) # generate a random profit/loss vector
+   BootstrapES(a, 50, 0.95)
+}
+\author{
+Dinesh Acharya
+}
+\references{
+Dowd, K. Measuring Market Risk, Wiley, 2007.
+}
+

Added: pkg/Dowd/man/BootstrapVarConfInterval.Rd
===================================================================
--- pkg/Dowd/man/BootstrapVarConfInterval.Rd	                        (rev 0)
+++ pkg/Dowd/man/BootstrapVarConfInterval.Rd	2015-05-29 21:20:41 UTC (rev 3658)
@@ -0,0 +1,36 @@
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/BootstrapVaRConfInterval.R
+\name{BootstrapVarConfInterval}
+\alias{BootstrapVarConfInterval}
+\title{Bootstrapped VaR Confidence Interval}
+\usage{
+BootstrapVarConfInterval(Ra, number.resamples, cl)
+}
+\arguments{
+\item{Ra}{Vector corresponding to profit and loss distribution}
+
+\item{cl}{Number corresponding to Value at Risk confidence level}
+
+\item{number.sample}{Number of samples to be taken in bootstrap procedure}
+}
+\value{
+90% Confidence interval for bootstrapped VaR
+}
+\description{
+Estimates the 90% confidence interval for bootstrapped VaR, for confidence
+level and holding period implied by data frequency.
+}
+\examples{
+# To be modified with appropriate data.
+   # Estimates 90\% confidence interval for bootstrapped Var for 95\%
+   # confidence interval
+   Ra <- rnorm(1000)
+   BootstrapVarConfInterval(Ra, 500, 0.95)
+}
+\author{
+Dinesh Acharya
+}
+\references{
+Dowd, K. Measuring Market Risk, Wiley, 2007.
+}
+

Modified: pkg/Dowd/readme.txt
===================================================================
--- pkg/Dowd/readme.txt	2015-05-29 03:26:24 UTC (rev 3657)
+++ pkg/Dowd/readme.txt	2015-05-29 21:20:41 UTC (rev 3658)
@@ -1,7 +1,5 @@
 #***************************************************************
-# most suitable function similar to bootsrtp in matlab is still to be checked
-# original bootstrp VaR so that still needs to be checked.
-# Other functions depending on bootstrp are still only half complete.
+# Bootstrap is almost complete. It is still to be tested/debugged. Tests still remaining.
 #***************************************************************
 # Jarque-Bera Test:
 # It has to be checked Probability of null (H0) or (H1).



More information about the Returnanalytics-commits mailing list