vwhs {quarks} | 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 |
model |
model for estimating conditional volatility; default is |
lambda |
decay factor for the calculation of weights; default is |
... |
additional arguments of the |
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'
(seerugarch
documentation) and'EWMA'
formodel = '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