How to calculate y-variable mean for hierarchical model “level”?

Data:

level - categorical variable, 2 levels, A and B

Model:

y ~ x + (1 | level)


The model output has multiple intercepts (one for fixed effects and one for random effects).

To calculate a mean y for level B, I have to sum random effects intercept (probably level A used as a reference?) + level B b-coefficient?

Since your level variable has only 2 levels, A and B, you should not be fitting random intercepts for this variable. You are asking the software to estimate a variance of a normally distributed variable from 2 observations. Can you imagine sampling the height of 2 people in a population and using those two heights as an estimate for the variance the height in the population. There is no universal rule for determining how many levels are needed to estimate a reliable variance, but 2 is certainly too few. You should fit level as a fixed effect.