Take the 2-minute tour ×
Quantitative Finance Stack Exchange is a question and answer site for finance professionals and academics. It's 100% free, no registration required.

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)

 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.

share|improve this question
Hi BeneSP, welcome to quant.SE! Thank you for asking your question here! –  Bob Jansen Aug 11 at 15:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.