saudiwin / ordbetareg_pack

Repository for R package ordbetareg, used to fit continuous data with lower and upper bounds.
Other
17 stars 3 forks source link

Prior and post-processing function problems for models that predict phi #9

Closed hec-ruiz closed 1 year ago

hec-ruiz commented 1 year ago

Hi!

The ordbetareg:::.load_ordbetareg function only allows extra_prior for ‘priors’, not for ‘priors_phireg’ (and the latter also has a hardcoded prior for b coefficients which interferes with set_prior from the outside).

Also, LOO doesn’t work when phi is predicted (at least seems to get stuck for a long time so I stop the process). Not sure if the following are specific for some characteristic of my model. My formula (without the '0 + Intercept') has the form:

bf( Y ~ factor + (factor | id), phi ~ factor + (factor | id) )

An apparent fix from an adaptation of your early code (https://gist.githubusercontent.com/StaffanBetner/6ec4a10a42d75faf31e612148a8a7789/raw/induced_dirichlet_ordbeta.R) is to change portions of the log_lik and posterior_predict functions, from:

phi <- draws$dpars$phi to if(NCOL(draws$dpars$phi)==1){phi <- draws$dpars$phi}else {phi <- draws$dpars$phi[, i]}

saudiwin commented 1 year ago

I just pushed a commit that allows for extra priors with phi regression. As far as using LOO with the original code, I really can't support that, so please retest with the package.