In brms: Two categorical predictors with unique intercepts

Operating System: macOS 10.14.3
Interface Version: brms 2.7.0
Compiler/Toolkit: clang 7.0.1

I’m setting up a model in brm() where there’s a continuous outcome (Y) and two categorical predictors (A, B), each with four levels. (The example comes from the end of chapter 5 of Statistical Rethinking.) I’m trying to set up just a simple linear model of the form:

Y ~ N(mu, sigma)
mu = alpha_A[i] + alpha_B[j]

The prior on the alpha parameters is N(0, 0.5); for sigma Exponential(1).

When I set up the model with the formula Y ~ 0 + A + B I get four b_ parameter estimates for A but only three for B. If I build the model with only one of A or B I get all four. If I put B before A I get four for B and three for A.

Am I missing something really obvious? Do I need to build a design matrix with all of the predictors to ‘force’ calculation of parameters for all eight levels across the two predictors? Is there something in the lme4-style syntax that I’ve missed? I’ve followed links to some other questions I thought were similar here and on the brms GitHub page, and to the lme4 vignettes on CRAN, but cannot figure this out.

Thanks
Hamed

I’m sure @paul.buerkner will know, but you might want your A and B to be group-level terms, i.e.,

y ~ 1 + (1 | A) + (1 | B)

Then each A and B will be offset from the intercept. Check ?brmsformula and the section on Group-level terms.

Thanks for the suggestion. I had tried it but couldn’t see the parameter estimates for the group-level terms, but when I tried it again and used posterior_summary() they were in there. Thanks for your help with this, much appreciated.