Properly fitting a model with nested effects

Hi everyone,

I’m trying to fit a model similar to the one included in the screenshot below. I have no issues running the model with brms, I am trying to see if I am getting the syntax down right.

fit <-  brm(cbind(pro, against) ~ 1 + (1| race_gender)  
        + (1 | age_categories2)  + (1|edu_categories) 
        + (1 | region2 + religion_categories | state), 
        data = collapsed, family = binomial(link = "logit"), 
        chains =4, cores = 4)

The tricky part for me is modeling the state effects, because of the region level effect that’s endogenous to it. From what I understand, (1 | region2 + religion_categories | state) allows the intercept to vary by region for each state, with each region level intercept being drawn independently, and allows the slope to vary by religion for each state. Does this seem correct?

  • Operating System: mac
  • brms Version:2.12.0

Thank you,
Gabriel

Hi,
sorry for letting your question sit for so long. Few notes about brms syntax:

  • (1 | state) actually models correlations between the individual intercepts, the case with no correlation (as appears in the screenshot) is captured with (1 || state)
  • The (1| <something> | state) is actually syntax to manage correlations (I think @paul.buerkner treat whatever is between the two | as a string and does not parse it in any way) so it is almost certainly not doing what you think it does :-).

AFAIK brms does not directly support this “nested linear regression” approach, but you IMHO can get something very similar by having (1||region) + (1 + religion_categories || state) where the noise in \alpha_s^{state} is absorbed into the state varying intercept. This should work out due to additivity of normal distributions, but please double check me.

Does that make sense?

Hi @martinmodrak, thanks a lot for your answer, it makes sense!