# vwhs: Volatility weighted historical simulation In quarks: Simple Methods for Calculating Value at Risk and Expected Shortfall

## Description

Calculates univariate Value at Risk and Expected Shortfall (Conditional Value at Risk) by means of volatility weighted historical simulation. Volatility can be estimated with an exponentially weighted moving average or a GARCH-type model.

## Usage

 `1` ```vwhs(x, p = 0.975, model = c("EWMA", "GARCH"), lambda = 0.94, ...) ```

## Arguments

 `x` a numeric vector of asset returns `p` confidence level for VaR calculation; default is `0.975` `model` model for estimating conditional volatility; default is `'EWMA'` `lambda` decay factor for the calculation of weights; default is `0.94` `...` additional arguments of the `ugarchspec` function from the `rugarch`-package; the default settings for the arguments `variance.model` and `mean.model` are ```list(model = 'sGARCH', garchOrder = c(1, 1))``` and `list(armaOrder = c(0, 0))`, respectively

## Value

Returns a list with the following elements:

VaR

Calculated Value at Risk

ES

Calculated Expected Shortfall (Conditional Value at Risk)

garchmod

The model fit. Is the respective GARCH fit for `model = 'GARCH'` (see `rugarch` documentation) and `'EWMA'` for `model = 'EWMA'`

## Examples

 ```1 2 3 4 5 6 7 8 9``` ```prices <- DAX30\$price.close returns <- diff(log(prices)) # volatility weighting via EWMA ewma <- vwhs(x = returns, p = 0.975, model = "EWMA", lambda = 0.94) ewma # volatility weighting via GARCH garch <- vwhs(x = returns, p = 0.975, model = "GARCH", variance.model = list(model = "sGARCH")) garch ```

quarks documentation built on Sept. 6, 2021, 9:07 a.m.