steve-the-bayesian / BOOM

A C++ library for Bayesian modeling, mainly through Markov chain Monte Carlo, but with a few other methods supported. BOOM = "Bayesian Object Oriented Modeling". It is also the sound your computer makes when it crashes.
GNU Lesser General Public License v2.1
35 stars 14 forks source link

predict method fails in mbsts with no regression component. #51

Open steve-the-bayesian opened 4 years ago

steve-the-bayesian commented 4 years ago

I fit a model with regressors using the mbsts function (using the long data format), but get the following error message when use the predict method:

fitted$has.regression [1] TRUE preds <- predict(fitted, newdata=future_incr,

  • timestamps = length(max(dat2$ds) + 1:nrow(future_incr))
  • ) Error in .ExtractPredictors(object, newdata, na.action = na.action) : Cannot extract predictors for a model with no regression component. traceback() 5: stop(paste0("Cannot extract predictors for a model with no ", "regression component.")) 4: .ExtractPredictors(object, newdata, na.action = na.action) 3: .FormatMultivariatePredictionData(object, newdata, horizon, na.action, timestamps) 2: predict.mbsts(fitted, newdata = future_incr, timestamps = length(max(dat2$ds) + 1:nrow(future_incr))) 1: predict(fitted, newdata = future_incr, timestamps = length(max(dat2$ds) + 1:nrow(future_incr)))

Looking through the code, it looks like the .ExtractPredictors function expect the model to have a coefficients attribute (line 570 in predict.bsts.R ), but my mbsts object's coefficients are in an attribute named 'regression.coefficients'.

Not ruling out user error, but I wanted to bring this to your attention in case this is a bug. Thanks for all you've put into the package, I've been using it for a while and gotten some great results out of it.