Error with gamma prior

I am trying to set a gamma prior for one of the variables in Beta regression. In fact my model has been working with no issues under R 3.6.1 with brms 2.10.5, however now after upgrading to the latest versions (R 4.0.2 with brms 2.13.0) I keep getting the following error:

Warning message:
It appears as if you have specified a lower bounded prior on a parameter that has no natural lower bound.
If this is really what you want, please specify argument ‘lb’ of ‘set_prior’ appropriately.
Warning occurred for prior b_variable ~ gamma(2,1)

This error pops up during sampling half way through (not when setting priors or model compilation).
The variable in question is strictly positive. When I try to specify “lb” argument, I get another error:

Error: Argument ‘coef’ may not be specified when using boundaries.

What am I doing wrong?

Currently the prior is specified as follows (and that worked before):

set_prior(“gamma(2,1)”,

  •        class = "b",*
    
  •        coef = "variable")*

Currently lb und ub can only be specified for a whole parameter class. I realise this is unnecessarily restricting and may change that in the future. Feel free to open an issue on github about it.

Is there a way to fix the issue without specifying “lb”, but keeping gamma prior?

Ignore the warning and hope you don’t get too many divergent transitions because of the missing boundary.

Is this still true with brms or are we able to specify bounds for specific coefficients instead of an entire class?

This appears to be still the case. As a workaround, you can modify the Stan code within the fit object itself and re-run it to obtain the desired results without having to stray too far from a brms-based workflow.

You can find some instructions on how to do so here. Although I wrote that in the context of setting constraints among parameters, the approach to modifying the model code should work in general.

1 Like

You can hack your way around this via the nonlinear syntax. For example:

dat <- data.frame(y = rnorm(10), x1 = rnorm(10), x2 = rnorm(10))

mod <- brm(
  bf(
    y ~ lp1 + lp2,
    lp1 ~ x1,
    lp2 ~ x2,
    nl = T
  ),
  data = dat, 
  prior = set_prior("normal(0, 1)", class = "b", nlpar = "lp1", lb = 0)
)

prior_summary(mod)
1 Like