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

 vwhs R Documentation

## Volatility weighted historical simulation

### 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

```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)

p

Confidence level for VaR calculation

garchmod

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

### Examples

```prices <- DAX\$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. 1, 2022, 1:06 a.m.