Data-Driven Model Structure Diagrams for Hierarchical Linear Mixed Models
Pub. online: 26 March 2026
Type: Statistical Data Science
Open Access
Received
11 August 2025
11 August 2025
Accepted
21 February 2026
21 February 2026
Published
26 March 2026
26 March 2026
Abstract
Hierarchical linear mixed models are commonly used in many scientific fields. However, without a strong statistical background, it can be hard to understand the relationships between the random effect variables and the inferences that can be made when a model has nested random effects. Visualizing relationships makes it easier for the practitioner to understand what relationships the model is capable of estimating and testing. We present an R package modeldiagramR that seamlessly creates a visualization of the model based on the data and the model object created when fitting a linear mixed model using either lme4 or nlme.
Supplementary material
Supplementary MaterialThe supplementary material is an R script file that contains all the code used to create the figures and model diagrams from this manuscript.
References
Bates D, Mächler M, Bolker B, Walker S (2015). Fitting linear mixed-effects models using lme4. Journal of Statistical Software, 67(1): 1–48. https://doi.org/10.18637/jss.v067.i01
Brooks ME, Kristensen K, van Benthem KJ, Magnusson A, Berg CW, ... Bolker BM (2017). glmmTMB balances speed and flexibility among packages for zero-inflated generalized linear mixed modeling. The R Journal, 9(2): 378–400. https://doi.org/10.32614/RJ-2017-066
Kuznetsova A, Brockhoff PB, Christensen RHB (2017). lmerTest package: Tests in linear mixed effects models. Journal of Statistical Software, 82(13): 1–26. https://doi.org/10.18637/jss.v082.i13
Luetkemeier MJ, Hanisko JM, Aho KM (2017). Skin tattoos alter sweat rate and Na+ concentration. Medicine & Science in Sports & Exercise, 49(7): 1432–1436. https://doi.org/10.1249/MSS.0000000000001244
Shönbrodt F (2014). Mixed Models in R. Ludwig-Maximilians-Universität München. https://www.personality-project.org/r/tutorials/summerschool.14/MLM_Schoenbrodt.pdf.