Reputation: 1610
bsts is an R package for bayesian structural time series modeling.
library(bsts)
# Load data
data(iclaims)
#Specify the trend and seasonality.
ss <- AddLocalLinearTrend(list(), initial.claims$iclaimsNSA)
ss <- AddSeasonal(ss, initial.claims$iclaimsNSA, nseasons = 52)
#set the seed within bsts.
model2 <- bsts(iclaimsNSA ~ ., state.specification = ss, data =
initial.claims, niter = 3000, seed = 1)
model3 <- bsts(iclaimsNSA ~ ., state.specification = ss, data =
initial.claims, niter = 3000, seed = 1)
# plot the results
par(mfrow=c(2, 2))
plot(model2, "coefficients")
plot(model3, "coefficients")
plot(model2, "size")
plot(model3, "size")
The results are given by the figure above. Apparently, even when we set up the seed of bsts and increase the number of iterations to 3000, the two results are not identical.
I have also tried to set.seed() out of bsts. It also does not work.
set.seed(1); model2 <- bsts(iclaimsNSA ~ ., state.specification = ss, data =
initial.claims, niter = 3000, seed = 1)
set.seed(1); model3 <- bsts(iclaimsNSA ~ ., state.specification = ss, data =
initial.claims, niter = 3000, seed = 1)
Upvotes: 1
Views: 1824
Reputation: 268
You should check parameter burn
in predict.bsts
. Play around with SuggestBurn function as well. Hope that helps.
Upvotes: 1