Skip to content

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

Description

@steve-the-bayesian

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bstsbugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions