# NOT RUN {
data(exrates)
y <- exrates$USD
## Fit AR(1)-SV model to EUR-USD exchange rates
res <- svsample(y, designmatrix = "ar1")
## Use predict.svdraws to obtain predictive volatilities
ahead <- 100
predvol <- predict(res, steps = ahead)
## Use arpredict to obtain draws from the posterior predictive
preddraws <- arpredict(res, predvol)
## Calculate predictive quantiles
predquants <- apply(preddraws, 2, quantile, c(.1, .5, .9))
## Visualize
ts.plot(y, xlim = c(length(y) - ahead, length(y) + ahead),
ylim = range(predquants))
for (i in 1:3) {
lines((length(y) + 1):(length(y) + ahead), predquants[i,],
col = 3, lty = c(2, 1, 2)[i])
}
# }
Run the code above in your browser using DataLab