I thought of this solution (should have mentioned it) and rejected it for the following reasons:
- I want to give the intercept a lower bound, but not the other regression weights
- There are often good reasons that the prior for the intercept is wider than the prior for regression weights
These two points are of course only correct if one sets only one prior for all regression weights. I never checked if brms allows to set different priors for different regression weights like this:
my_prior =
set_prior(normal(0,10), class = "b", coef = "my_intercept", lb = 0) +
set_prior(normal(0,2), class = "b", coef = "x1")
If this is possible, the solution to with y ~ 0 + ...
is clearly more elegant.
Edit: OK, I checked, and @Solomon’s solution does not work (except one thinks it’s OK giving intercept and regression weights the same prior and boundaries), because
Argument ‘coef’ may not be specified when using boundaries.
What does work is to use different priors, and not to specify boundaries i.e. :
my_prior =
set_prior(normal(0,10), class = "b", coef = "my_intercept") +
set_prior(normal(0,2), class = "b", coef = "x1")
However, this means that Stan can use negative values for my_intercept
during initialisation, which is problematic for the data set I was am currently working with. More generally, it is my understanding that it is good practice that the one should add the correct boundaries when specifying model parameters.
In sum, the solution @Solomon proposes gets one half the way. If one wants correct specification of prior distribution and parameter boundaries, as of now one has to work with modified stan_code as described above.