# How to build in a prior for a random slope in ordinal mixed effect regression

Dear stan-modellers,

I am back with another question trying to figure out my priors for an ordinal mixed effects regression with a categorical predictor, two random effects, and a random slope for the predictor by one of the random effects. The question I have is how to specify a prioir for the random slope.

Here is where I am:

model2 ← brm(

data = NSgjt,

family = cumulative(probit),

rating ~ Type + (1+Type | Subject) + (1 | ITEM),

prior = c(prior(normal(-0.84, 1), class = Intercept, coef = 1),

prior(normal(-0.25, 1), class = Intercept, coef = 2),

prior(normal( 0.25, 1), class = Intercept, coef = 3),

prior(normal( 0.84, 1), class = Intercept, coef = 4),

prior(normal(0, 1), class = b),

prior(exponential(1), class = sd)),

cores = 2,

seed = 1, iter = 5000,

init_r = 0.2)


The model was adapted from https://solomonkurz.netlify.app/blog/2021-12-29-notes-on-the-bayesian-cumulative-probit/ which I also used to come up with the priors for the intercepts of each level of the dependent outcome(priors for coef 1-4), the categorical predictor Type ( prior(normal(0, 1), class = b) and the random effect (prior(exponential(1), class = sd))). I am not sure whether I need to specify one for each random effect or if one is enough for both. Solomon Kurz only specifies one even though he has two random effects.

The data in a nutshell is unordered ordinal data where the DV ranges from 1-5, likert-scale-like. I followed Verissimo (2021) (https://osf.io/7n92b) for the rest of the analysis after running the model. That is for looking at model fit through posterior predictive checks and the distribution of the posterior through conditional_effects. I also integrated R codes for running Bayes factor analyses to test for main effects or model fit with and without random effects from https://vasishth.github.io/bayescogsci/book/index.html and am using the same book to interpret main effects of my categorical predictor Type.

The Bayes factor analysis shows the random slope is needed in that a model without it is inferior to one with it ( 

## Estimated Bayes factor in favor of x1 over x2: Very high number


Thank you in advance for any advice. Francesco
2 Likes

If you want to use the same prior for all level-2 \sigma parameters, your

prior(exponential(1), class = sd)`

code is good to go.

Hi Francesco,

I’m glad my paper helped, but note that it was a brief paper that omitted a lot of what is involved in a full Bayesian analysis (including priors). This one by Schad et al. on Bayesian workflow in cognitive science may be useful: APA PsycNet . Specifically, running prior predictive checks may help your choice of prior.

Also, I think the final part of your post has been cut - but from what I understand, you’ve computed a Bayes Factor for the random slope in order to justify its inclusion? I don’t think I would select a random-effects structure on the basis of BF, but others will know better than me about how appropriate this is. I would probably go for something like LOOIC for that purpose, or otherwise just fit the ‘maximal’ model. Moreover, that BF may change substantially depending on your choice of prior for the random slope.