I am investigating the stability of results from a bayesian structural time series model using bsts package in R. The following code estimates a local linear trend model (using an example from the R package) for three different numbers of MCMC draws (100, 1000, 10000). For each of the three cases, I repeat the estimation 10 times and store the R-square in a data frame:
library(bsts)
data(AirPassengers)
y <- log(AirPassengers)
df=data.frame(niter100=NA,niter1000=NA,niter10000=NA)
dfcolumn=0
for (j in c(100,1000,10000)) {
dfcolumn=dfcolumn+1
for (i in 1:10) {
ss <- AddLocalLinearTrend(list(), y)
model_benchmark <- bsts(y,state.specification = ss,niter = j)
summary=summary(model_benchmark)
df[i,dfcolumn]=summary$rsquare
}
}
Below the results:
> df
niter100 niter1000 niter10000
1 0.9058217 0.8959122 0.8352333
2 0.9058217 0.6254595 0.7148984
3 0.9058217 0.8956490 0.8840317
4 0.9058217 0.9071929 0.8682971
5 0.9050454 0.9076566 0.9017717
6 0.9050454 0.8904109 0.8416038
7 0.9050454 0.9073501 0.8674943
8 0.9050454 0.9059262 0.8563360
9 0.9050454 0.9070879 0.8585177
10 0.9050454 0.6612644 0.8920700
My expectation is that the results should get more accurate and stable as we increase the number of MCMC draws. The above test however indicates to me that results tend to become less stable with more MCMC draws, i.e. for 100 iterations the R-square varies only marginally while for 1000 iterations it varies between 0.63 and 0.91. What could be the reason for this? Are there any strategies how to deal with this in a real application?