# NOT RUN {
data(AirPassengers)
y <- log(AirPassengers)
ss <- AddLocalLinearTrend(list(), y)
ss <- AddSeasonal(ss, y, nseasons = 12)
# }
# NOT RUN {
model <- bsts(y, state.specification = ss, niter = 500)
# }
# NOT RUN {
errors <- bsts.prediction.errors(model, burn = 100)
PlotDynamicDistribution(errors$in.sample)
## Compute out of sample prediction errors beyond times 80 and 120.
errors <- bsts.prediction.errors(model, cutpoints = c(80, 120))
standardized.errors <- bsts.prediction.errors(
model, cutpoints = c(80, 120), standardize = TRUE)
plot(model, "prediction.errors", cutpoints = c(80, 120))
str(errors) ## three matrices, with 400 ( = 500 - 100) rows
## and length(y) columns
# }
Run the code above in your browser using DataLab