|
| 1 | +## Garch Modeling in BRMS |
| 2 | + |
| 3 | +### Abstract |
| 4 | + |
| 5 | +The student will implement common General Autoregressive Conditional Heteroskedasticity ([GARCH](https://vlab.stern.nyu.edu/docs/volatility)) style models for users in the [brms](https://cran.r-project.org/web/packages/brms/index.html) R package. The R package brms is a frontend for Stan that allows R users to write R formula syntax for models that is translated and compiled into a Stan model. Currently brms allows for [`arma`](https://github.com/paul-buerkner/brms/issues/708) style models on the mean, but does not support GARCH style models on the variance. The student will code up several of these models in Stan, testing with simulation based calibration that the models are well calibrated, write a technical document describing the GARCH model form and how it can be incorporated into brms, then implement these models directly into brms. |
| 6 | + |
| 7 | +| **Intensity** | **Priority** | **Involves** | **Mentors** | |
| 8 | +| ------------- | ------------ | ------------- | ----------- | |
| 9 | +| Medium | Low | R, Bayesian Modeling |[Paul-Christian Bürkner](https://github.com/paul-buerkner), [Asael A Matamoros](https://github.com/asael697), [Steve Bronder](https://github.com/SteveBronder) | |
| 10 | + |
| 11 | +### Project Details |
| 12 | + |
| 13 | +An Autoregressive Moving Average model (ARMA) is of the form |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | +where |
| 18 | +- `Y_t` is the series at time `t`, |
| 19 | +- `p` and `\rho_i` is the number of autoregressive parameters and autoregressive parameters |
| 20 | +- `q` and `\theta_i` is the number of moving average parameters and moving average parameters. |
| 21 | +- `epsilon_t` is the error at time `t` |
| 22 | + |
| 23 | +Currently, brms users are able to express autoregressive and moving average components of the mean of their model with syntax such as |
| 24 | + |
| 25 | +```R |
| 26 | +# Only auto regressive |
| 27 | +y ~ ar(time | group, p = 1) |
| 28 | +# Only moving average |
| 29 | +y ~ ma(time | group, q = 1) |
| 30 | +# Both |
| 31 | +y ~ arma(time | group, p = 1, q = 1) |
| 32 | +``` |
| 33 | + |
| 34 | +We would like to extend this functionality to support General Autoregressive Conditional Heteroskedasticity ([GARCH](https://vlab.stern.nyu.edu/docs/volatility)) style models which have the form |
| 35 | + |
| 36 | +<img src="https://latex.codecogs.com/svg.latex?\small&space;\begin{align*}&space;y_t&\sim\mu_t&space;+&space;\epsilon_t&space;\\&space;\epsilon_t&space;&\sim&space;\mathcal{N}{\left(0,\sigma_t^2\right)}&space;\\&space;\sigma_t^2&=\omega&space;+&space;\sum_{i=1}^p&space;\beta_i\sigma_{t-i}^2&space;+&space;\sum_{i=1}^q&space;\alpha_i\epsilon_{t-i}^2&space;\\&space;\end{align*}" title="\small \begin{align*} y_t&\sim\mu_t + \epsilon_t \\ \epsilon_t &\sim \mathcal{N}{\left(0,\sigma_t^2\right)} \\ \sigma_t^2&=\omega + \sum_{i=1}^p \beta_i\sigma_{t-i}^2 + \sum_{i=1}^q \alpha_i\epsilon_{t-i}^2 \\ \end{align*}" /> |
| 37 | + |
| 38 | +Where |
| 39 | + |
| 40 | +- `y` is the series with mean `mu` and error `epsilon` at time `t` |
| 41 | +- `epsilon` is normally distributed with mean 0 and variance `sigma_t^2` at time `t` |
| 42 | +- `sigma_t^2` is modeled with |
| 43 | + - `p` autoregressive parameters `beta` |
| 44 | + - `q` moving average components `alpha` |
| 45 | + |
| 46 | +As you can see, ARMA and GARCH are pretty similar! The fun starts happening when we are talking about real life modeling where it's very common to have very nasty tails on volatility models. Then we start building models such as asymmetric GARCH (AGARCH) models where one side of volatility leads to more conditional heteroskedasticity than the other. |
| 47 | + |
| 48 | +<img src="https://latex.codecogs.com/svg.latex?\small&space;\sigma_t^2=\omega&space;+&space;\sum_{i=1}^p&space;\beta_i\sigma_{t-i}^2&space;+&space;\sum_{i=1}^q&space;\alpha_i&space;(\epsilon_{t-i}&space;-&space;\gamma_i)^2&space;\\" title="\small \sigma_t^2=\omega + \sum_{i=1}^p \beta_i\sigma_{t-i}^2 + \sum_{i=1}^q \alpha_i (\epsilon_{t-i} - \gamma_i)^2 \\" /> |
| 49 | + |
| 50 | +Here, `gamma` acts like a weight that when positive amplifies the expected volatility if previous errors were negative. |
| 51 | + |
| 52 | +Inside of brms it's possible to [distributional parameters](https://paul-buerkner.github.io/brms/articles/brms_distreg.html) and so for `sigma` we would like to allow syntax such as |
| 53 | + |
| 54 | +```R |
| 55 | +# Only autoregressive |
| 56 | +sigma ~ ar(time | group, p = 1) |
| 57 | +# Only moving average |
| 58 | +sigma ~ ma(time | group, q = 1) |
| 59 | +# Both autoregressive and moving average |
| 60 | +sigma ~ garch(time | group, p = 1, q = 1) |
| 61 | +# Asymmetric autoregressive |
| 62 | +sigma ~ aar(time | group, q = 1) |
| 63 | +# Asymmetric autoregressive and moving averag |
| 64 | +sigma ~ agarch(time | group, p = 1, q = 1) |
| 65 | +``` |
| 66 | + |
| 67 | +This would be combined with the current ARMA syntax to create models with varying autoregressive components for both the mean and variance such as |
| 68 | + |
| 69 | +```R |
| 70 | +bf_mod = bf( |
| 71 | + y ~ arma(time | group, p = 1, q = 1), |
| 72 | + sigma ~ agarch(time | group, p = 1, q = 1) |
| 73 | +) |
| 74 | +``` |
| 75 | + |
| 76 | +Challenges from brms side will be to determine which of all the other modeling options can be combined with GARCH models. For example, how to combine GARCH models on sigma with distributional regression in sigma. Other difficulties will be to implement all the post-processing such as posterior predictions etc. The existing ARMA terms already pave the way for all of this but we will have to figure out if the current structure is satisfactory for autoregressive terms to be applied to distributional parameters other than the mean. There are also other minor difficulties such as if/how GARCH models can be combined with a covariance formulation of ARMA models on the mean `arma(..., cov = TRUE)`. These are all details we have to figure out in the process. |
| 77 | + |
| 78 | +### Expected Results and Milestones |
| 79 | + |
| 80 | +The expected result of this project is that brms users will have access to a simple way to incorporate standard volatility models into their overall model structure. |
| 81 | + |
| 82 | +#### Milestone 1 |
| 83 | +Take models from [NYU Stern Volatility lab](https://vlab.stern.nyu.edu/docs/volatility) and write them in Stan along with data generating processes. Then use both of these to perform [Simulation Based Calibration](https://mc-stan.org/docs/2_23/stan-users-guide/simulation-based-calibration.html) |
| 84 | + |
| 85 | +#### Milestone 2 |
| 86 | +Write tech spec as an issue in BRMS suggesting the syntax style, supported models, outstanding issues, any good default priors for the parameters that were found, etc. (Paul you'd probably need to lay out the template here). |
| 87 | + |
| 88 | +#### Milestone 3 |
| 89 | +Make a prototype with tests, prediction methods, and docs for simple a simple `garch(p, q)` on sigma |
| 90 | + |
| 91 | +#### Milestone 3 |
| 92 | +Add additional garch flavors such as GJR-GARCH, EGARCH, APARCH, AGARCH, etc. |
| 93 | + |
| 94 | +### Helpful Prerequisite Experience |
| 95 | + |
| 96 | +- Knowledge of the tools behind developing R packages |
| 97 | +- Experience with Stan and Bayesian modeling |
| 98 | +- Studies in time series and volatility modeling |
| 99 | + |
| 100 | +### What Will You Learn? |
| 101 | + |
| 102 | +By the end of the project students will have experience in R package development and working with a large, international open source development team, the algorithms behind volatility modeling, an understanding of the workflow in developing Bayesian models. |
| 103 | + |
| 104 | +### What Can You do To Prepare? |
| 105 | + |
| 106 | +It would be very good to read materials related to time series modeling with Bayesian Statistics [link](https://mc-stan.org/docs/2_20/stan-users-guide/time-series-chapter.html), be familiar with [Simulation Based Calibration](https://mc-stan.org/docs/2_23/stan-users-guide/simulation-based-calibration.html), and try some practice models in the Stan programming language. |
0 commit comments