In the paper "CAViaR: Conditional Autoregressive Value at Risk by Regression Quantiles" by Robert F. Engle and Simone Manganelli (2004), the authors propose a new method for estimating and evaluating Value-at-Risk (VaR) forecasts. The main idea is to model the quantiles of future returns directly, rather than modeling the entire distribution of returns. The model they propose is called the Conditional Autoregressive Value at Risk (CAViaR) model.
This library caviar
is designed to build the below 4 types of models based on the paper and our additional research on the parameter setting and optimization method.
where:
-
$y_t$ is the return at period t (author using log return * 100) -
$f_t(\beta)$ is the predicted VaR at period t -
$\theta$ is the quantile level, which ranges from 0 to 1
where:
-
$y_t$ is the return at period t, assumming$y_t$ follows Asymmetric Skewed Laplace Distribution with$\tau$ > 0 -
$f_t(\beta)$ is the predicted VaR at period t -
$\theta$ is the quantile level, which ranges from 0 to 1
We optimized the problem differently. Instead of best start: picking m best
Instead of using simplex algorithm followed by quasi-newton method, we have used L-BFGS-B to optimize the problems.
Estimated parameters and performances are much stable compared to the unbounded solution (for asymmetric slope and IGARCH). We bounded the parameters in (-1, 1) except IGARCH where its bound is (0, 1)
# firstly initialize the in-sample and out-of-sample returns
in_samples = some_returns[in] * 100
out_samples = some_returns[out] * 100
# initialize the parameters by choosing from these
# q = 0 to 1 exclusively
# model is from {'adaptive', 'asymmetric', 'symmetric', 'igarch'}
# method is from {'RQ', 'mle'}
# declare a model instance
caviar_model = CaviarModel(q, model, method)
# fit the beta
caviar_model.fit(in_samples)
# print the statistic of beta
print(caviar_model.beta_summary())
# predict the fittedvalues
in_VaR_predicted = caviar_model.predict(in_samples, 'in')
out_VaR_predicted = caviar_model.predict(out_samples, 'out')
# get the predicted values
in_VaR_fitted, in_VaR_forecast = in_VaR_predicted[:-1], in_VaR_predicted[-1]
out_VaR_fitted, out_VaR_forecast = out_VaR_predicted[:-1], out_VaR_predicted[-1]
# DQ Test [OPTIONAL]
# the null hypothesis of the Dynamic Quantile Test used in the CAViaR paper is that
# the CAViaR model provides accurate VaR forecasts for a given confidence level
print(caviar_model.dq_test(in_samples, 'in'))
print(caviar_model.dq_test(out_samples, 'out'))
Notice that since the model is a time series model, when you want to perform out of sample prediction, the in-sample and out-of-sample data must be consecutive. If the in-sample are from 0, 1, ..., T, then the out-of-sample must be starting from T+1, T+2, ...
- Engle, R. F., & Manganelli, S. (2004). CAViaR: Conditional autoregressive value at risk by regression quantiles. Journal of business & economic statistics, 22(4), 367-381.
- Chen, C. W., Gerlach, R., Hwang, B. B., & McAleer, M. (2012). Forecasting value-at-risk using nonlinear regression quantiles and the intra-day range. International Journal of Forecasting, 28(3), 557-574.
- Rubia, A., & Sanchis-Marco, L. (2013). On downside risk predictability through liquidity and trading activity: A dynamic quantile approach. International Journal of Forecasting, 29(1), 202-219.