# Compute Expected Shortfall and Value at Risk for Continuous Distributions

Compute expected shortfall (ES) and Value at Risk (VaR) from a quantile function, distribution function, random number generator or probability density function. ES is also known as Conditional Value at Risk (CVaR). Virtually any continuous distribution can be specified. The functions are vectorized over the arguments. The computations are done directly from the definitions, see e.g. Acerbi and Tasche (2002) . Some support for GARCH models is provided, as well.

## Overview

Compute expected shortfall (ES) and Value at Risk (VaR) from a quantile function, distribution function, random number generator or probability density function. ES is also known as Conditional Value at Risk (CVaR). Virtually any continuous distribution can be specified. The functions are vectorised over the arguments. The computations are done directly from the definitions, see e.g. Acerbi and Tasche (2002). Some support for GARCH models is provided, as well.

## Installing cvar

The latest stable version is on CRAN.

``````install_packages("cvar")
``````

The vignette shipping with the package gives illustrative examples (`vignette("Guide_cvar", package = "cvar")`).

You can install the development version of `cvar` from Github:

``````library(devtools)
install_github("GeoBosh/cvar")
``````

## Overview

Package `cvar` is a small `R` package with, essentially two functions â€” `ES` for computing the expected shortfall and `VaR` for Value at Risk. The user specifies the distribution by supplying one of the functions that define a continuous distributionâ€”currently this can be a quantile function (qf), cumulative distribution function (cdf) or probability density function (pdf). Virtually any continuous distribution can be specified.

The functions are vectorised over the parameters of the distributions, making bulk computations more convenient, for example for forecasting or model evaluation.

The name of this package, "cvar", comes from Conditional Value at Risk (CVaR), which is an alternative term for expected shortfall.

We chose to use the standard names `ES` and `VaR`, despite the possibility for name clashes with same named functions in other packages, rather than invent possibly difficult to remember alternatives. Just call the functions as `cvar::ES` and `cvar::VaR` if necessary.

Locations-scale transformations can be specified separately from the other distribution parameters. This is useful when such parameters are not provided directly by the distribution at hand. The use of these parameters often leads to more efficient computations and better numerical accuracy even if the distribution has its own parameters for this purpose. Some of the examples for `VaR` and `ES` illustrate this for the Gaussian distribution.

Since VaR is a quantile, functions computing it for a given distribution are convenience functions. `VaR` exported by `cvar` could be attractive in certain workflows because of its vectorised distribution parameters, the location-scale transformation and the possibility to compute it from cdf's when quantile functions are not available.

# cvar 0.3-1

• fix tests to pass with the changed R random generator.

• some new examples and minor documentation changes.

# cvar 0.2-1

• now `\VignetteIndexEntry` in `Guide_cvar.Rnw` is plain text.

• added experimental support for GARCH models - currently GARCH(1,1) (the API may change).

• now the first argument of `VaR()` and `ES()` can be a numeric vector. This is useful, e.g., for computing VaR by simulation.

• bugfix: in `VaR_cdf()` and `VaR_qf()`, the code for the `if/else` clauses had been wrongly swappped.

# cvar 0.2-0 (CRAN)

• prepare for CRAN

# cvar 0.1-3

• suggest 'covr'.

• setup for travisCI and Coveralls.

• more tests.

# cvar 0.1-2

• corrected \VignetteIndexEntry in the vignette --- I used the vignette for Rdpack as a template but didn't change this entry, which resulted in the vignette appearing with a puzzling title on CRAN and other sites.!

• added [email protected] in DESCRIPTION.

• added experimental web site (docs/)

# cvar 0.1-1 (CRAN)

• added a doi to DESCRIPTION.

# cvar 0.1-0

• first public release.

# Reference manual

install.packages("cvar")

0.4-0 by Georgi N. Boshnakov, 2 years ago

https://github.com/GeoBosh/cvar https://geobosh.github.io/cvar/

Report a bug at https://github.com/GeoBosh/cvar/issues

Browse source code at https://github.com/cran/cvar

Authors: Georgi N. Boshnakov [aut, cre]

Documentation:   PDF Manual

Task views: Empirical Finance

GPL (>= 2) license

Imports gbutils, Rdpack, fGarch

Suggests testthat, PerformanceAnalytics, covr

See at CRAN