0

I've built a bsts model using 2 years of weekly historical data. I'm able to predict using the model with the existing training data. In order to mimic the process that would occur with the model in production, I've created an xts object that moves the 2 years of data forward by one week. When I try to predict using this dataset (populating the olddata parameter in predict.bsts), I receive the following error:

Error in terms.default(object) : no terms component nor attribute

I realize I'm probably doing something dumb here, but haven't been able to find any examples of usage of values of olddata when predicting. Appreciate any help you can provide.

Thanks

dat = xts(fcastdat$SumScan_units,order.by = fcastdat$enddate)
traindat = window(dat, start=as.Date("2015-01-03"), end=as.Date("2016-12-26"))

ss = AddLocalLevel(list(), traindat)
ss = AddSeasonal(ss, traindat, nseasons = 52)

holidays = c("EasterSunday", "USMothersDay", "IndependenceDay", "MemorialDay", "LaborDay", "Thanksgiving", "Christmas")

ss = AddNamedHolidays(ss, named.holidays = holidays, traindat)

model_loclev_seas_hol = bsts(traindat, state.specification = ss, niter = 500, ping=50, seed=1289)
burn = SuggestBurn(0.1, model_loclev_seas_hol)

pred_len = 5

pred = predict.bsts(model_ll_seas_hol, horizon = pred_len, burn = burn, quantiles = c(.025, .975))

begdt = index(traindat[1]) + 7

enddt = index(traindat[length(traindat)]) + 7

predseries = window(dat, start=as.Date(begdt), end=as.Date(enddt))

pred2 = predict.bsts(model_ll_seas_hol, horizon=pred_len, burn=burn, olddata = predseries,quantiles = c(.025, .975))
  • Welcome to Stack Overflow! Please read [how to properly ask questions](https://stackoverflow.com/questions/how-to-ask) and [how to provide a helpful reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) and edit your post accordingly. – Julian Wittische Aug 01 '17 at 23:01
  • Hi! It's been a while, but in case it helps, I had the same problem. I didnt see your question and opened a [new one](https://stackoverflow.com/questions/45802767/bsts-r-library-error-in-predict-using-olddata-toboomvectorview-called-with-a). As you can see, I played quite a bit with the library guts, but I could not solve it. I also contacted Steve Scott, the creator of the library, and he confirmed this is a bug. Probably you've implemented it already, anyway the workaround is quite clear: train again your model with the previous training data plus the olddata. Not ideal, but ok. Cheers. – lrnzcig Sep 18 '17 at 14:26

0 Answers0