Posterior Simulation for Rolling Stochastic Volatility Forecasts
Summary
The document examines how to make rolling one-step-ahead volatility forecasts from a stochastic volatility model fitted to DAX returns using the R package stochvol. The example squares demeaned log returns, fits the model to a training sample, and then attempts to forecast later observations. Its proposed forecast function uses posterior mean parameters and updates volatility deterministically.
The accepted response identifies three issues: fitting once does not constitute refitting a rolling model, posterior means discard parameter uncertainty, and latent volatility should be simulated rather than deterministically updated. It points to the package’s prediction procedure and an algorithm in its vignette as relevant guidance. The exchange does not provide a corrected implementation or resolve the question about units in detail. The example therefore highlights modeling and forecasting pitfalls, while leaving the forecast code and unit interpretation for further work.
Key ideas
- A single model fit followed by repeated predictions is not the same as refitting on a rolling window.
- Using posterior mean parameters alone omits uncertainty about the model parameters.
- Stochastic volatility forecasts should account for randomness in the latent volatility state.
- The example uses squared log returns, but the exchange leaves the stated unit concern unresolved.
Tags
Full text
# Estimate rolling stochastic volatility forecast using stochvol in R
# Estimate rolling stochastic volatility forecast using stochvol in R
I want to use the R package stochvol to fit a SV model to a DAX training set and use the output to estimate a rolling one-step-ahead forecast:
```
DAX2log<- (logret(DAX, demean=TRUE))^2
trainset <- DAX2log[1:1912]
SV <- svsample(trainset, priormu = c(-10, 1), priorphi =
c(20, 1.1), priorsigma = .1, draws = 50000, burnin = 5000)
SVroll <- function(svsampleOBJ, NumofForecast, Data)
{
mu <- summary(svsampleOBJ)$para[1]
phi <- summary(svsampleOBJ)$para[2]
sigma <- summary(svsampleOBJ)$para[3]
HSV <- vector(mode=c("double"),length=NoF)
for(i in 1:NumofForecast)
{
H <- mu + phi*(Data[i] - mu) + sigma
HSV[i] <- exp(H/2)
}
return(HSV)
}
HSV <- SVroll(svsampleOBJ = SV,NumofForecast = 2000,
Data = DAX2log[1913:length(DAx2log)])
```
The main problem with this code is that the model becomes deterministic, but I did not manage to extract further draws from the predict function for the rolling forecast.
How can I get those draws from the posterior distribution and is my formula adequate?
In addition, there seems to be some mix up in the units, since HSV is squared daily returns, while the input is in log.
## Answer by Gregor (score 4, accepted)
https://quant.stackexchange.com/a/14883
You might want to have a look at the stochvol vignette (http://cran.r-project.org/web/packages/stochvol/vignettes/article.pdf), where this process is described in detail in Algorithm 1. In particular, if I understand you correctly, what you need is step 4b.
Now to your code:
1) It's not really a rolling forecast, because you estimate the model only once.
2) When predicting, in the first three lines of your function, you only use the posterior mean of the parameters (as a point estimate). Why not use the entire distribution? That way you can also handle parameter uncertainty properly.
3) In an SV model (as opposed to GARCH-type models), volatility is assumed to be a latent random variable, thus when predicting (line H <- ...), you might want to do so by drawing from the corresponding (normal) distribution instead of updating deterministically. That's exactly what predict.svdraws does. You could have a look at the code there and adapt it to your needs.
Best, GregorShown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.