Lme4 Random Effects Cheat SheetΒΆ

Because Lmer models just call the lme4 package in R behind the scenes, some familiarity with lmer model formulae is required. Here is a quick reference for common random effects specifications:

#Random intercepts only
(1 | Group)

#Random slopes only
(0 + Variable | Group)

#Random intercepts and slopes (and their correlation)
(Variable | Group)

#Random intercepts and slopes (without their correlation)
(1 | Group) + (0 + Variable | Group)

#Same as above but will not separate factors (see: https://rdrr.io/cran/lme4/man/expandDoubleVerts.html)
(Variable || Group)

#Random intercept and slope for more than one variable (and their correlations)
(Variable_1 + Variable_2 | Group)