# Clarification on Random Effects Structure in Linear Mixed Models in R

I am using linear mixed models to analyze a dataset with a hierarchical structure, where measurements over time (level 1) are clustered within individuals (level 2), and individuals are clustered within countries (level 3). I initially used the following syntax in R with the lme4 package to model this structure:

model <- lmer(basdai ~ 1 + time + (1|country) + (1|id), data = data,
REML = FALSE)


However, a reviewer pointed out that the syntax I used does not represent a 3-level model, but rather a 2-level model. They suggested using the following syntax instead:

model <- lmer(basdai ~ 1 + time + (1|country) + (1|country:id),
data = data, REML = FALSE)


From my understanding, the term (1|country) represents the random intercept for each country (level 3), while (1|id) represents the random intercept for each individual (level 2).

I thought that including both terms would account for the clustering. I would appreciate any insights or explanations regarding the differences between these two model specifications and whether my initial syntax truly represents a 2-level structure instead of the intended 3-level hierarchy.

The answer depends a bit on how your country and id variables are coded. Is it the case that:

• a) In each country the numbering for individual ids starts at 1?

or

• b) In country 1 you have ids 1-10 and in country 2 you have ids 11-20? Or at the very least, the id numbers never overlap across countries?

If a, then you would want to use either the reviewer's syntax or the equivalent (1 | country/id). In this case, you must use this alternative syntax because lmer() cannot determine whether the individuals are unique or are repeated (crossed) such that the same set of individuals appear in different countries.

If b, which is the preferred way of coding id variables, then your original syntax is equivalent to the reviewer's syntax. This would mean that each individual gets a unique id number and lmer() correctly infers that you have nested rather than crossed data.

Either way, as long as you specify the syntax appropriately given the coding of the id variable, many (if not most) analysts would say you have three levels of nesting - repeated measures of basdai at level 1 nested within individuals at level 2 who are nested within countries at level 3.

For more information, see Ben Bolker's useful webpage on lme4 syntax.

Erik seems to have sufficiently answered this query with respect to which model to use. I simply explain why the first model isn't doing what you think and how it differs from a typical hierarchical random effects design.

The first model is a crossed random effects design, where instead of the random effects being nested inside of each other, they are instead all shared with each other. Probably the most classic example of a crossed random effects design is the subject x stimuli design (see Baayen et al., 2008). Suppose we have 50 subjects who read 100 words and are measured on their reaction times. This will mean that all subjects are introduced to all words, where we will get repeated measures of both (Subject "Billy" will see 1 to 100 words, and likewise the word "cat" will be read by 50 subjects). When fit to a regression, this can be linearly constructed as:

$$y = X_{ij}\beta + S_is_i + W_jw_j + \epsilon_{ij}$$

where $$y$$ is the outcome, $$X$$ is the design matrix of fixed effects, $$\beta$$ is the vector of fixed effects coefficients, $$S$$ is the subject matrix with $$s$$ vector adjustments to the population intercept, $$W$$ is the word matrix with $$w$$ vector adjustments to the population intercept, and $$\epsilon_{ij}$$ is the leftover error for $$i$$ subjects and $$j$$ words.

Because of this crossing, we can technically expand the grid of observations to be multiplied $$n_{\text{subjects}}$$ by $$n_{\text{words}}$$ since each has a number of repeated rows. So with our 50 subjects and 100 words, we effectively get $$50 \times 100 = 5000$$ observations. Thus this design is quite powerful, as simply having many stimuli alone can greatly increase the number of observations in a model, even if there aren't that many people in the design. This differs from the design you were after, which simply includes the observations as-is and consequently only models the random effect variation within hierarchical clusters.

The difference between these two types of models is expertly defined by Robert Long in this post if you would like to explore further. You can see his example of the schools and classes with "crossed arrows" is a similar dynamic to the subject x stimuli design described above, whereas the arrows that point uniquely between schools and students are more what you are after.

#### References

Baayen, R. H., Davidson, D. J., & Bates, D. M. (2008). Mixed-effects modeling with crossed random effects for subjects and items. Journal of Memory and Language, 59, 390–412. https://doi.org/10.1016/j.jml.2007.12.005