Learn R Programming

MSGARCH (version 0.17.7)

risk: Value-at-Risk And Expected-shortfall.

Description

Method returning the Value-at-Risk and Expected-shortfall in-sample or at t = T + 1 based on the predictive density.

Usage

risk(object, theta, y, level = c(0.95, 0.99), ES = TRUE, do.its = FALSE, ctr = list(n.mesh = 500, tol = 1e-04, itermax = 5))

Arguments

object
Model specification of class MSGARCH_SPEC created with create.spec or fit object of type MSGARCH_MLE_FIT created with fit.mle or MSGARCH_BAY_FIT created with fit.bayes.
theta
Vector (of size d) or matrix (of size M x d) of parameter estimates (not require when using a fit object).
y
Vector (of size T) of observations (not require when using a fit object).
level
Vector (of size R) of Value-at-risk and Expected-shortfall levels. (Default: level = c(0.95,0.99))
ES
Boolean indicating if Expected-shortfall is also calculated. (Default: ES = TRUE)
do.its
Boolean indicating if the in-sample risk estimator are returned. (Default: do.its = FALSE)
ctr
List of control parameters for VaR evaluation.

Value

A list containing of class MSGARCH_RISK containing two or three components:
  • VaR : If do.its = FALSE: Value-at-Risk at t = T + 1 at the choosen levels (vector of size R). If do.its = TRUE: In-sample Value-at-Risk at the choosen levels (Matrix of size T x R).
  • ES : If do.its = FALSE: Expected-shortfall at t = T + 1 at the choosen levels (vector of size R). If do.its = TRUE: In-sample Expected-shortfall at the choosen levels (Matrix of size T x R).
  • y : Vector (of size T) of observations.
The MSGARCH_RISK contains the plot method. The Bayesian risk estimator can take long time to calculate depending on the size of the MCMC chain.

Details

If a matrix of MCMC posterior draws estimates is given, the Bayesian Value-at-Risk and Expected-shortfall are calculated. If do.its = FALSE, x the risk estimator at t = T + 1, the method uses the variance estimated at t = T + 1. If do.its = TRUE, The in-sample risk estimator are calculated.

Examples

Run this code
# load data
data("sp500")
sp500 = sp500[1:1000]

# create model specification
spec = MSGARCH::create.spec() 

# fit the model on the data with ML estimation using DEoptim intialization
set.seed(123)
fit = MSGARCH::fit.mle(spec = spec, y = sp500, ctr = list(do.init = FALSE))

# compute the Value-at-Risk and Expected-shortfall 
# Risk estimation in-sample 
risk.its = MSGARCH::risk(object = fit, level = 0.95, ES = FALSE, do.its = TRUE)

plot(risk.its)                     

# Risk estimation at T + 1                     
risk = MSGARCH::risk(object = fit, level = 0.95, ES = FALSE, do.its = FALSE)

Run the code above in your browser using DataLab