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

error for group-level model for phi #15

Closed stefgehrig closed 1 year ago

stefgehrig commented 1 year ago

It is currently not possible to specify a group-level model for phi that has no population-level effects ("fixed effects"). Setting

ordbetareg(..., phi_reg = "both")

and a formula for phi like phi ~(1|country)

will return an error of the type

Error: The following priors do not correspond to any model parameter: b_phi ~ normal(0,5) Function 'get_prior' might be helpful to you.

The reason is simply that for phi_reg = "both" the current code will force priors on the population-level coefficients in the model for phi even if there are none. Setting phi_reg = "none" is no help, because then brms will try to set a prior on the global phi, but again, there is no global phi. I have solved that locally for me, but it might be worth to make this more flexible midterm.

saudiwin commented 1 year ago

This is kind of an edge case, and it's actually supported, but I added some documentation to cover it.

Essentially, set phi_reg to "intercepts" and then use extra_prior if you want to change the prior on the intercepts. You can do that by passing:

extra_prior=set_prior("normal(0,2)", class="sd", dpar="phi")

See the brms documentation for more specification options for priors.

Note that if you want priors on stuff in the main model, you'll need to pass those to extra_prior as well.