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

Error in bas.lm: $ operator is invalid for atomic vectors #57

Closed emmaleeberry closed 2 years ago

emmaleeberry commented 2 years ago

Describe the bug function "bas.lm" can't work with error message "Error: $ operator is invalid for atomic vectors".

To Reproduce

`x<- mvtnorm::rmvnorm(100, mean=rep(0,9), sigma=diag(9)) b <- c(2,2,2,0.2,0.2,0.2,0,0,0) y <- x%*%b + rnorm(100, mean=0, sd=1) test <- cbind(x,y) test <- as.data.frame(test)

bas.out<-bas.lm(V10~V1+V2+V3+V4+V5+V6+V7+V8+V9, data=test, method="MCMC", MCMC.iterations=20000, prior="hyper-g", modelprior = "uniform", pivot = FALSE)`

Expected behavior Have the function "bas.lm" run with clear instruction on the input data format.

Screenshots Capture

Desktop:

merliseclyde commented 2 years ago

modelprior should not be a string, but a function - e.g. should be one of modelprior = uniform()

merliseclyde commented 2 years ago

Add a warning message if a string is given for modelprior; note a future enhancement is to convert the argument for priors to be objects like in bas.glm

merliseclyde commented 2 years ago

Added error message of modelprior is not of class 'prior' in bas.lm and bas.glm to catch this