Skip to content

Markov Switching GARCH models (MSGARCH) in R

David Ardia edited this page Mar 16, 2017 · 1 revision

Background

Modeling the volatility of financial markets is central in risk management. A seminal contribution in this field was the development of the GARCH model by Bollerslev (1986) where the volatility is a function of past asset returns. The GARCH model is today a widespread tool in risk management. However, recent studies show that estimates of GARCH models can be biased by structural breaks in the volatility dynamics (Bauwens et al., 2010; Bauwens et al., 2014). These structural breaks typically occur during periods of financial turmoil. Estimating a GARCH model on data displaying a structural break yields a non-stationary estimated model and implies poor risk predictions. A way to cope with this problem is provided by Markov-switching GARCH models (MSGARCH) whose parameters vary over time according to some regimes. These models can quickly adapt to variations in the unconditional volatility level, which improves risk predictions (see Ardia, 2008).

Related work

In 2016, GSoC financed “Phase I” of the MSGARCH project. This allowed the construction of the package MSGARCH, which implements Markov-switching GARCH-type models very efficiently by using C++ object-oriented programming techniques. It allows the user to perform simulations as well as Maximum Likelihood and Bayesian estimation of a very large class of Markov-switching GARCH-type models. Risk management tools such as Value-at-Risk and Expected-Shortfall calculations are available. The MSGARCH package has been received as a valuable addition to the set of R packages dealing with volatility estimation by the R community (large number of downloads on CRAN and additional funding received for its development). The development version of the MSGARCH package is available at https://github.com/keblu/MSGARCH. Details regarding the package can be found in Ardia et al. (2016). Details of your coding project

This year, we would like to work on “Phase II” of the MSGARCH project. In particular, we envision the following steps:

  1. Review:
  • Familiarize with the package.
  • Use Hungarian notation in the R code and unify notation.
  • Unify input/outputs for function.
  • Complete documentation.
  1. Improvements (in R and Rcpp/C++):
  • Speed up in-sample risk measures computations (currently too slow).
  • EM algorithm or grid search for initialization in estimation.
  • Enable parameters constraints in estimation. *Standard errors of the estimates.
  • Hidden states: ** Implement Viterbi algorithm. ** Implement Baum-Welch algorithm. ** Smoothed probabilities.
  • h-step ahead simulation.
  1. Multivariate MSGARCH models:
  • Add multivariate MSGARCH-type models (using a copula approach). This should by inspired from the “rmgarch” package (Ghalanos, 2015).
  • Update of the vignette for the package illustration and description.

The project will be developed with https://www.rstudio.com/ and stored on https://github.com. In order to manage efficiently the development of the package, the various tasks and deadlines will be managed via https://asana.com/

Expected impact

As mentioned, the MSGARCH package was received very favorably by the R community. We have currently several thousand of downloads on CRAN, and more than 400 downloads of the vignette on SSRN. Moreover, every week, we get emails from users requesting additional features in the package. So we expect Phase II to provide improvements useful for practitioners and academics in the financial community.

Mentors

Prof. Dr. David Ardia, Prof. Dr. Kris Boudt and Dr. Brian Peterson

Tests

Applicants have to be able to show that they have:

  • A very good working knowledge of programming in R, Rcpp and C++.
  • A very good working knowledge of Roxygen for the documentation.
  • A very good working knowledge of knitr/LaTeX for the vignette.
  • Familiarities with the construction of R packages.
  • Good coding standards (Google’s C++ and R style guide).
  • Good knowledge of GARCH type model.
  • Experience with Maximum Likelihood and MCMC estimation.
  • Experience with GitHub.

Students should show their motivation by following the points below:

  • Easy: Reproduce all steps in Ardia et al. (2016) for alternative datasets.
  • Medium: Propose an R/Rcpp code for the h-step ahead simulation under a given MSGARCH model specification. Compute VaR and ES risk measures from it (by simulation).
  • Hard: Propose a multivariate extension of the MSGARCH specification of your choice. Extend the current Rcpp framework for this model.

Solutions of tests

Students, please post a link to your test results here.

References

Ardia D (2008). Financial Risk Management with Bayesian Estimation of GARCH Models: Theory and Applications. Lecture Notes in Economics and Mathematical Systems 612. Springer. 206 pages

Ardia, D., Bluteau, K., Boudt, K., Trottier, D.-A. (2016). Markov-switching GARCH models in R: The MSGARCH package. Working paper. https://ssrn.com/abstract=2845809

Bauwens L, Preminger A, Rombouts JVK (2010). Theory and Inference for a Markov Switching GARCH Model. Econometrics Journal, 13(2), 218-244

Bauwens L, Backer B, Dufays A, (2014). A Bayesian Method of Change-Point Estimation with Recurrent Regimes: Application to GARCH Models, Journal of Empirical Finance, 29, issue C, 207-229

Bollerslev T (1986). Generalized Autoregressive Conditional Heteroskedasticity. Journal of Econometrics, 31(3), 307-327

Ghalanos A (2015). “rmgarch”: Multivariate GARCH models. R package version 1.3-0. URL: https://cran.r-project.org/web/packages/rmgarch/

Clone this wiki locally