Compute Value-at-Risk (VaR) and expected shortfall (ES)
Compute Value-at-Risk (VaR) and expected shortfall (ES)
Compute Value-at-Risk (VaR) and Expected Shortfall (ES) for a fitted GARCH-APARCH model.
## S3 method for class 'fGARCH'VaR(dist, p_loss =0.05,..., tol)## S3 method for class 'fGARCH'ES(dist, p_loss =0.05,...)
Arguments
dist: an object from class "fGARCH", obtained from garchFit().
p_loss: level, default is 0.05.
...: not used.
tol: tollerance
Details
We provide methods for the generic functions cvar::VaR and cvar::ES.
Note
We use the traditional definition of VaR as the negated lower quantile. For example, if X are returns on an asset, VARa = −qa, where −qa is the lower a quantile of X. Equivalently, VARa is equal to the lower 1−a quantile of −X (the loss series). For details see the vignette in package cvar availalble at https://cran.r-project.org/package=cvar/vignettes/Guide_cvar.pdf
(or by calling vignette("Guide_cvar", package = "cvar")).
If you wish to overlay the VaR or ES over returns, just negate the VaR/ES, see the examples.
See Also
VaR and ES in package cvar
Examples
## simulate a time series of returnsx <- garchSim( garchSpec(), n =500)class(x)## fit a GARCH modelfit <- garchFit(~ garch(1,1), data = x, trace =FALSE)head(VaR(fit))head(ES(fit))## use plot method for fitted GARCH modelsplot(fit, which =14)# VaRplot(fit, which =15)# ESplot(fit, which =16)# VaR & ES## plot(fit) # choose the plot interactively## diy plots## overlay VaR and ES over returns## here x is from class 'timeSeries', so we convert VaR/ES to timeSeries## don't forget to negate the result of VaR()/ES(),plot(x)lines(timeSeries(-VaR(fit)), col ="red")lines(timeSeries(-ES(fit)), col ="blue")## alternatively, plot losses (rather than returns) and don't negate VaR()/ES()plot(-x)lines(timeSeries(VaR(fit)), col ="red")lines(timeSeries(ES(fit)), col ="blue")