Intercept for the nested multilevel models (ranef vs. coef vs. other?)

I have a multilevel model that has countries nested in geopolitical groupings. Let’s say the model is:

y ~ x + (1 | continent / country).

I have three set of intercepts,

A global intercept.
An intercept for ‘continent’
And and intercept for ‘continent:country’

I can calculate each separately using ranef().

Do I use coef(model)$‘continent:country’ to get the final intercept for each country (which does not seem to be the case),

or do I calculate use ranef() for each of the above and sum them up?

coef(model)$continent seems to give me global intercept + ranef(model)$continent, as explained by @paul.buerkner here.

but coef(model)$‘continent:country’ gives me something else.

Unless changed at some time in the last few years, coef() does not consider nesting of random effects. You will need to add them together manually using ranef().

1 Like