I have collected crop yield data from multiple blocks for multiple years and associated rainfall data. Each block is located within a municipality and each municipality is located within a State. I am interested in knowing the relationship between yield and rainfall while accounting for the effect of location and year. This is how I specified my model:

lmer(yield ~ rainfall + (1 | block) + (1 | muni) + (1 | state) + (1 + year | block))

I am somewhat confused by different way of writing the formula specification and would appreciate if someone could advise me if the above specification is correct? The reason I am asking is because in this post I found a specification which suggests to me that model should be specified like this:

lmer(yield ~ rainfall + (1 | state:muni:block)

What is the difference between the two?


The two models you show are not the same because in the former you also have the random slope for year in the block level. BTW, you don't need both (1 | block) and (1 + year | block), the latter is sufficient, i.e.,

lmer(yield ~ rainfall + (year | block) + (1 | muni) + (1 | state))

Now, check the Section 'Nested or Crossed' of the GLMM FAQ. As you can see in the last bullet-point, there is a difference between the two formulations when the lower-level groups have the same values for the upper-level groups. For example, if in your dataset the blocks are coded as {1, 2, 3, ...} within each municipality, then you need the latter type of syntax. If however, they're coded as {1, 2, 3} for municipality 1, and {4, 5, 6} for municipality 2, etc., then the former type of syntax will also work correctly.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.