comodin19 / BayesVarSel

BayesVarSel: R package to calculate Bayes factors, model choice and variable selection in linear models
8 stars 5 forks source link

Error in GibbsBvs when prior.models="User" #48

Closed gongardo closed 1 month ago

gongardo commented 6 months ago

It happens when trying to estimate the normalizing constant, at the end of the main call:

    if (priorprobs=="ScottBerger") lpriorAset<- -log(p+1)-lchoose(p, dimAset)
if (priorprobs=="Constant") lpriorAset<- -p*log(2)
if (!is.character(priorprobs)) {
    dimnotzero<- which(priorprobs>0)
    priorAset<- priorprobs[dimAset+1]/sum(exp(log(priorprobs[dimnotzero])+lchoose(p, dimnotzero-1)))
    lpriorAset<- log(priorAset)
}   

since priorprobs is a vector, it crashes

gongardo commented 6 months ago

To solve the issue it suffices to put if (!is.character(priorprobs)) as the first conditional

gongardo commented 1 month ago

solved in a branch called issue48 then incorporated into the master branch