Mixed Models

Mixed models (aka multilevel or hierarchical models) are statistical models containing both fixed- and random-effects terms. They are useful when multiple measurements exist for each unit of observation (e.g., participant or item), or for hierarchical data. Linear mixed models (LMMs) are used for normally distributed dependent variables, generalized linear mixed models (GLMMs) are applicable to other distributions (e.g., binomial data).

lmm_exampleMixed models extend ordinary linear, ANOVA, or generalized linear models and have only relatively recently been introduced to psychology . They allow for the modeling of dependency structures in the data that are difficult to handle with ordinary linear or generalized linear models such as repeated measurements by the same individual  (e.g., allowing repeated-measures logistic regressions) or hierarchical data structures such as participants blocked in classes or sessions. Furthermore, they enable the modeling  of multiple independent random effects simultaneously, such as participant and item effects, unifying so-called F1 and F2 analysis. Together with David Kellen, I have written an introductory chapter to mixed models. Further information on how to specify mixed models for experimental designs are given by Barr and colleagues and arguments for considering both participants and items simultaneously are given by Judd et al.  .

The reference package for estimating mixed models in the statistical programming language R is lme4. A technical introduction to the models estimated by lme4 can be found here. I have developed the afex package which complements the functionality of lme4, for example by obtaining *p*-values for effects in mixed models.



R Core Team. (2022). R: A Language and Environment for Statistical Computing. R Foundation for Statistical Computing. http://www.R-project.org/
Baayen, H., Davidson, D. J., & Bates, D. (2008). Mixed-effects modeling with crossed random effects for subjects and items. Journal of Memory and Language, 59(4), 390–412. https://doi.org/10.1016/j.jml.2007.12.005
Judd, C. M., Westfall, J., & Kenny, D. A. (2012). Treating stimuli as a random factor in social psychology: A new and comprehensive solution to a pervasive but largely ignored problem. Journal of Personality and Social Psychology, 103(1), 54–69. https://doi.org/10.1037/a0028347
Barr, D. J., Levy, R., Scheepers, C., & Tily, H. J. (2013). Random effects structure for confirmatory hypothesis testing: Keep it maximal. Journal of Memory and Language, 68(3), 255–278. https://doi.org/10.1016/j.jml.2012.11.001
Barr, D. J. (2013). Random effects structure for testing interactions in linear mixed-effects models. Frontiers in Quantitative Psychology and Measurement, 328. https://doi.org/10.3389/fpsyg.2013.00328