merliseclyde / BAS

BAS R package for Bayesian Model Averaging and Variable Selection
https://merliseclyde.github.io/BAS/
GNU General Public License v3.0
41 stars 16 forks source link

predict.basglm not compatible with MPM estimator #51

Closed aagaardk closed 3 years ago

aagaardk commented 4 years ago

When estimator = 'MPM' predict.basglm produces an error regarding the prior values.

Reproducible example:

data(Pima.tr, package="MASS")
data(Pima.te, package="MASS")
Pima.bas = bas.glm(type ~ ., data=Pima.tr, n.models= 2^7, method="BAS",
                   betaprior=CCH(a=1, b=nrow(Pima.tr)/2, s=0), family=binomial(),
                   modelprior=uniform())
pred = predict(Pima.bas, newdata=Pima.te, estimator = 'MPM')

#Error in bas.lm(eval(object$call$formula), data = eval(object$call$data,  : 
#  prior  1 is not one of  g-prior, hyper-g, hyper-g-laplace, hyper-g-n, AIC, BIC, ZS-null, ZS-full, EB-local, EB-global, JZSprior

Desktop (please complete the following information):

merliseclyde commented 3 years ago

For MPM, predict extracts the median probability model and runs bas a second time to create a new bas object. Currently predict code calls bas.lm, rather than bas.glm.

Fix: add a switch to check class of object before calling bas.lm or bas.glm