Skip to content

KhalilBelghouat/ExtremeRiskForecastingviaMarkovRegimeSwitchingModels

Repository files navigation

Extreme Risk Forecasting via Markov Regime-Switching Models: Evidence from the Moroccan All Shares Index

This repository includes the code used in one of the master's projects "Extreme Risk Forecasting via Markov Regime-Switching Models: Evidence from the Moroccan All Shares Index" by Khalil Belghouat.

In this project, a Markov regime-switching extreme value theory approach is followed in order to model and forecast the tail risk of the Moroccan All Shares Index.

Prerequisites

The R programming language, version 4.2.0, and its statistical and machine learning libraries were used to build all applied models. The R script packages.R in the packages folder installs and loads all necessary R packages.

All operations, from data preprocessing to model estimation, were carried out on the Google Colaboratory platform.

Theoretical Background

So far in the literature, two models have been developed that capture the time-varying autocorrelated volatility process: the stochastic volatility model and that of GARCH (Generalized Autoregressive Conditional Heterscedasticity). In the stochastic volatility model, the variance is modeled as a latent component that follows a stochastic process. While GARCH models define time-varying variance as a deterministic function of past squared innovations and lagged conditional variances. Multiple extensions of GARCH's sedastic function have been proposed to capture additional stylized facts observed in financial and economic time series, such as non-linearities, asymmetries, and long memory properties. GARCH-type models are, until now, widely used to model various financial phenomena such as risk management of futures contracts, estimation of the volatility of yield spreads, and portfolio optimization. However, various studies have shown that one of the most problematic features of these models is the excessive persistence attributed to the volatility of financial variables. This suggests that conditional variance shocks that arose in the distant past continue to have sizeable effects on the present value. This long-lasting persistence is in fact the reason attributed to the relatively poor forecasts of the GARCH models. A number of researchers have observed that the high persistence of GARCH models and therefore poor forecasting performance could be related to structural changes in the data generating process. And pointed out that GARCH models may be limited in their ability to model the volatility of financial time series if structural breaks, caused by some dramatic events such as financial crises, recessions or changes in government policies, are present. Therefore, Markov regime-switching GARCH models, as introduced by James D. Hamilton and several other econometers, were advanced and found to be useful in solving this problem. These models allow the conditional volatility process to switch between a discrete number of states, the transitions between states being governed by a Markov chain of hidden and finite order. More often than not, such a structure has been found to improve the forecasting of volatility and risk. The Markov regime-switching model and its variants have found application in the analysis of the fluctuation of interest rates and exchange rates, forecasting business cycles, and portfolio management for hedging against financial risks. In this paper, we conduct an empirical analysis of the Moroccan All Shares Index using several Markov regime-switching GARCH specifucations. We also study, combined with extreme value theory, their forecasting performance in estimating VaR.

Application and Results

We note that, for all volatility and distribution specifications, the Markov regime-switching models offer a better trade-off between goodness-of-fit and model complexity than their single-regime counterparts. Furthermore, we note that for all regime specifications, asymmetric and fat-tailed distributions are widely preferred. The three-regime GARCH model with a Student-t distribution is found to be the best fit to our data based on Akaike's information criterion, 9232.1672. While the standard single-regime GARCH model with a Student-t distribution was found to be the best based on the Bayesian information criterion, 9306.0622. A point raised by several researchers is that Akaike and Bayesian information criteria are appropriate for different tasks. In particular, the Bayesian information criterion is considered appropriate to select the so-called true model among the set of candidate models, while Akaike's information criterion is not appropriate. Proponents of Akaike's information criterion argue that this problem is negligible, since the true model is almost never in the candidate set. In a simulation study by Scott I. Vrieze, Akaike's information criterion was shown to sometimes select a much better model than its Bayesian counterpart even when the true model is in the candidate set. The reason is that, for finite n, the Bayesian information criterion may have a substantial risk of selecting a very bad model from the candidate set. With Akaike's information criterion, the risk of selecting a very bad model is minimized. The volatility of MASI returns is separated into three regimes: a high volatility regime, a medium volatility regime, and a low volatility regime. The high volatility regime is linked to significantly high return spreads, the medium volatility regime is linked to moderately high return spreads, and the low volatility regime is linked to low return fluctuation. The parameter estimates indicate that the evolution of the volatility process is heterogeneous between the three regimes. Indeed, the three regimes report different levels of unconditional volatility: 9.0437% in the first regime, 9.7334% in the second regime and 20.8600% in the third. Moreover, the persistence of volatility in each of the regimes is different. The first regime yields 0.8046, the second regime yields 0.5605, while the third yields 0.8960. The stable probabilities indicate that the probability of being in the first regime is 0.4330, while being in the second or third is 0.4049 and 0.1621, respectively. Additionally, the estimated probability of staying in the same market conditions over the next period is high for all three regimes, exceeding 95%. While the probabilities associated with switching from one regime to another are very low. Finally, the results from backtesting VaR at 5% risk show that the two-regime Markov-switching GARCH model with a Student-t distribution outperforms its single-regime and three-regime counterparts.

Code Structure

About The Data

The data, a financial time series, is organized in a table containing 7 columns and 5105 rows. The first column contains the date, the following 4 columns contain the closing, opening, high and low prices of the MASI index, while the remaining columns contain the index's trading volumes and daily variations.

Model Building and Estimation

The 72 models in this study were all built using the MSGARCH package. The estimation procedure was done via the Maximum Likelihood technique.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages