Test random slopes against zero

For a research question, I would like to test if at least some people in my dataset have a (true) random slope that is negative, while the fixed effect is positive. So for most people, x and y are positively associated and I want to test if for some people, the association is in fact negative.

I wonder if I can test this question using multilevel models in brms, for instance by constraining negative values of the random slope priors to zero (or to zero minus the estimated fixed effect) and comparing the model to an unconstrained model? If the second model fits the data better, this could indicate that at least some random slopes have values below zero.

Does anyone know if this can be implemented using brms and if so, how could I compare the constrained and unconstrained models?

As you correctly say, this would require truncating the hierarchial normal prior at zero which is currently not possible in brms.

1 Like

Would this be possible in Stan? I think it would be a nice feature for others as well.

Maybe a (very unelegant) workaround could be to check how many individual random slope estimates have 95%-credibility intervals excluding values above zero and comparing this against chance expectations. But individual slopes are often estimated with great uncertainty…

It would be possible in stan yes. You can let brms generate the stan code with make_stancode and then change it accordingly

1 Like