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 phi <- summary(svsampleOBJ)$para
sigma <- summary(svsampleOBJ)\$para
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.

• Hi BeneSP, welcome to quant.SE! Thank you for asking your question here! Aug 11 '14 at 15:14