Skip to content

bas.predict error when n<p when using estimator= BMA and se.fit =T #70

@petersen-f

Description

@petersen-f

Describe the bug
Great package! A noticed a bug however when trying to perform predictions.
When training a model with more predictors than variables (n<p) via method = BAS, the prediction of new data (with se.fit =T and estimator= BMA) fails with the following error: Error in solve.default(qr.R(qr(oldX))) : 'a' (14 x 15) must be square

To Reproduce
Steps to reproduce the behavior:

data("bodyfat")
bas_mod <- bas.lm(Bodyfat ~.,data = bodyfat[1:14,], method = 'BAS')
pred <- predict(bas_mod,newdata = bodyfat[15:20,], se.fit = T, estimator = 'BMA') 

Expected behavior
The function should return predictions with the 95% credible interval.
If this behavior is not a bug and this type of prediction is impossible I would expect a more informative error that se.fit =T is not supported for n>p scenarios via BMA and the BAS method. It seems to work fine if the method is set to MCMC however.

Desktop (please complete the following information):

  • OS: Ubuntu 22.04
  • R Version: 4.2.2
  • BAS version: 1.6.4

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions