Hierarchical and Mixed Effects Models in R
Richard Erickson
Data Scientist
library(lme4)
lmer(y ~ x + (Random-effect), data = my_data)
(1 | group)
: Random intercept with fixed mean(1 | g1/g2)
: Intercepts vary among g1
and g2
within g1
(1 | g1) + (1 | g2)
: Random intercepts for 2 variablesx + (x | g)
: Correlated random slope and interceptx + (x || g)
: Uncorrelated random slope and interceptlme4
for additional detailsHierarchical and Mixed Effects Models in R