I am self-learning about structural time series, and for me the best way to understand topic is to simulate the data myself. I want to simulate a time series of local level model with seasonal components:
$$y_t = \mu_t + \gamma_t + v_t$$ $$ \mu_t = \mu_{t-1} +w_t$$
Where both disturbance terms are normally distributed. My code to simulate the time series is:
require(bsts)
set.seed(1234)
y2 <- c()
mu2 <- c(0)
seasons <- seq(-5,5,length.out =12)/5
for (i in 2:200) {
w1 <- rnorm(1,0,0.1)
v <- rnorm(1,0,0.1)
mu2 <- c(mu2, mu2[i-1] +w1)
y2 <- c(y2,mu2[i]+seasons[i%%12-1] +v)
}
I intentionally put really strong seasonality and small disturbance variances, so the model could capture it easier:
ss <- AddLocalLevel(list(), y2)
ss <- AddSeasonal(ss, y2, nseasons = 12)
model <- bsts(y2 ,state.specification = ss,niter = 3000)
pr <- predict(model,horizon = 30,burn = 100)
plot(pr)
Unfortunately, the predictions don't seem to capture the seasonality at all:
What did I do wrong? Did I poorly simulate the time series? Or did I mis-specify the model? Or boht?