vwhs | R Documentation |
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.
vwhs(x, p = 0.975, model = c("EWMA", "GARCH"), lambda = 0.94, ...)
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 |
Returns a list with the following elements:
Calculated Value at Risk
Calculated Expected Shortfall (Conditional Value at Risk)
Confidence level for VaR calculation
The model fit. Is the respective GARCH fit for
model = 'GARCH'
(see rugarch
documentation) and 'EWMA'
for
model = 'EWMA'
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.