Stanplot only a subset of random effects

Say I have a model with a random effect

y ~ (1|effectX)

and effectX has levels A, B, C, D, E, and F.

If I use
stanplot(fit_object, pars = "^r_")
it will plot all six levels of the random effect.

Is there a way to make stanplot only plot levels A, B, and C?


  • brms Version: 2.7

You have to name the parameters exactly. That is look at parnames(fit_object) find the full names and put them into pars. Likely, you should set exact_match = TRUE.

The exact_match = TRUE is part that I was missing. Now that I understand that, I see what the argument description means in the brms documentation. But that wasn’t clear to me before. It would be very helpful if you were able to add an example in the brms documentation, something like:

stanplot(model, pars = c("^r_patient[4,Intercept]", "^r_patient[8,Intercept]"), exact_match = TRUE)

Thanks for your help as always!