I am interested in forecasting conditional volatility, $h_t$, and returns, $y_t$, in a Bayesian GARCH framework. I am using the bayesGARCH package by Ardia in R (https://cran.r-project.org/web/packages/bayesGARCH/index.html) in order to estimate the Bayesian GARCH. The model setup implemented by the bayesGARCH package can be seen below.
$r_t$ = $\varepsilon_t(\frac{v-2}{v}\omega_th_t)^{1/2}$ $\quad$ with $\quad$ $t=1,...,T$
$\varepsilon_t \overset{iid}{\sim}N(0,1)$
$\omega_t \overset{iid}{\sim}IG(\frac{v}{2},\frac{v}{2})$
$h_t = \alpha_0 + \alpha_1r^{2}_{t-1}+\beta h_{t-1}$
This setup represents a GARCH(1,1) model with student-t innovations. Currently I am able to forecast $h_t$. I have however only managed to do so using one estimation window. Ideally, I would like to create a rolling window forecast which essentially allows me to update the posterior distribution of the parameters say every 50 observations instead of using the same posterior parameter estimates for the entire test sample. Does anyone have any ideas as to how to go about this?
I set out my existing R code below. Any advice/critiques/comments would be greatly appreciated.
Fit bayesGARCH on training data
MCMC.1 = bayesGARCH(train_data, mu.alpha = c(0,0), Sigma.alpha = 10000 * diag(1,2),mu.beta = 0, Sigma.beta = 10000, lambda = 0.01, delta = 4, control = list(n.chain=2,l.chain=nr_iterations,refresh=1000))
Extract parameter posterior distribution
smpl <- formSmpl(MCMC.1, l.bi = 10000, batch.size = 2) alpha0 = smpl[, 1] alpha1 = smpl[, 2] beta = smpl[, 3] nu = smpl[, 4]
Create an empty conditional volatility series, with 100 rows (one entry for every percentile) and where the amount of columns equals the length of your test(forecast) sample - i.e. you'll have a sigma distribution for each day in your forecast sample
ind = seq(1,nr_iterations - burn-in,by=100) nind = length(ind) sigma2 = matrix(0,nind, test_length - 1)
For the conditional volatility forecast merely substitute the estimated parameters into the equation and use the training data as your return series for period t and then the test data for every period thereafter.
l = 0 for (i in ind){ sigma2_temp = rep(0, test_length - 1) sigma2_temp[1] = alpha0[i]+alpha1[i]*train_data[train_length - 1]^2 for (t in 2:(test_length - 1)) sigma2_temp[t] = alpha0[i]+alpha1[i]*test_data[t-1]^2+beta[i]*sigma2_temp[t-1] l = l + 1 sigma2[l,] = sigma2_temp }
I am also interested in forecasting $y_t$. While I have seen the math and intuition for forecasting $y_t$ (https://stats.stackexchange.com/a/152427/98939) I am yet to find any code. Any ideas?