Predictions Garch model - one step ahead


#1

Hi,

I want to estimate a simple GARCH(1,1) in STAN. Until now, I used the following code to simulate an out-of-sample prediction, which, however, doesn’t perform well. So, I want to make one-step-ahead forecast rolling forecast. Does someone have an idea how to write it in STAN.

data {
  int<lower=2> T; 
  real y[T];
  real<lower=0> sigma1;
  int<lower=0> T_pred;
}
parameters {
  real mu; 
  real<lower=0> alpha0;          
  real<lower=0,upper=1> alpha1;  
  real<lower=0, upper=(1-alpha1)> beta1; 
}
transformed parameters {
  real<lower=0> sigma[T];
  sigma[1] = sigma1;
  for (t in 2:T)
    sigma[t] = sqrt(alpha0 +
                     + alpha1 * square(y[t - 1] - mu)
                     + beta1  * square(sigma[t - 1]));
}
model {
  y ~ normal(mu,sigma);
}
generated quantities {
  real y_pred[T_pred];
  real sigma_pred[T_pred];
  sigma_out[1] = sqrt(alpha0 + alpha1 * square(y[T] - mu) + beta1 * square(sigma[T]));
  y_pred[1] = normal_rng(mu, sigma_pred[1]);
  for (t in 2:T_pred) {
    sigma_pred[t] = sqrt(alpha0 + alpha1 * square(y_pred[t - 1] - mu) 
                        + beta1 * square(sigma_pred[t - 1]));
    y_pred[t] = normal_rng(mu, sigma_pred[t]);
  }
}

#2

By “one-step-ahead rolling forecast” do you mean getting a one-day forecast from the model fit on a larger / different history every day?

As far as I know, that’s impossible in Stan (and pretty much everything else) without re-running the estimation procedure on the new data. If you don’t expect the posterior to be too different from day to day (e.g., if you have a large history or the sample has more or less fixed dynamics), you might be able to rig something up using the previous day’s posterior as part of an importance or accept-reject sampler, but you’ll eventually want to refit the model with Stan anyways.

Since refitting is slow, you often see folks “filtering” out of sample data through the fitted model as opposed to making a T-day ahead forecast. (Filtering is essentially running the real data through the model (fixing the parameters instead of inferring them) and making new predictions) In a Bayesian context, you typically want to filter using each posterior draw separately and then taking a posterior mean / median / interval rather than filtering using the posterior mean / median of the parameters. I’ve found this to work pretty well on reasonable (week to month) time scales.

Michael