A primer on mixed-effects Models: theory and practice

Slides from a tutorial on mixed-effects models I presented to my research group.
r
statistics
multilevel
mixed models
animations
Author
Published

Tuesday, March 31, 2020

When I started my PhD I had to get familiar with Linear Mixed Models very well very quickly. Then I was asked to present what I learnt and prepare this informal tutorial for my colleagues, which I presented on March 10th, 2020 (yes, early pandemic :confounded:). This post shares the result.

This is not supposed to be taken as a formal guide to linear mixed-effects models, but rather as a semi-coherent compilation of notes and self-suggestions that I considered worth sharing with my lab mates during my early stages of in the PhD. Here are the slides:

What I should be taken more seriously are (1) the references I suggest in the first slides (which I consider some of the best resources available to learn linear mixed-effects models), and (2) the memes, which I personally curated and even created to sweeten up the dreadful incoherence of the content of some of the slides (sorry about that).

Before the presentation I tweeted one of the animations I generated for it.

This tweet got some attention (for my usual numbers) and many kind folks have asked for the R code or the GIF file of the specific animation included in the tweet, so here they are (you’ll also find them in the GitHub repository) in a perhaps more comfortable format, ready to be cloned or downloaded):

Linear mixed models animated

Session info

R version 4.3.2 (2023-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.3 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0 
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=es_ES.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=es_ES.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=es_ES.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=es_ES.UTF-8 LC_IDENTIFICATION=C       

time zone: Europe/Madrid
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base     

other attached packages:
[1] xaringanExtra_0.7.0 quarto_1.2         

loaded via a namespace (and not attached):
 [1] digest_0.6.31   later_1.3.0     fastmap_1.1.0   xfun_0.36      
 [5] magrittr_2.0.3  glue_1.6.2      stringr_1.5.0   knitr_1.41     
 [9] htmltools_0.5.4 rmarkdown_2.19  lifecycle_1.0.3 ps_1.7.2       
[13] cli_3.6.0       processx_3.8.0  vctrs_0.5.1     renv_0.16.0    
[17] compiler_4.3.2  rstudioapi_0.14 tools_4.3.2     evaluate_0.19  
[21] Rcpp_1.0.9      yaml_2.3.6      rlang_1.1.2     jsonlite_1.8.4 
[25] stringi_1.7.8  

Reuse

Citation

BibTeX citation:
@online{garcia-castro2020,
  author = {Garcia-Castro, Gonzalo},
  title = {A Primer on Mixed-Effects {Models:} Theory and Practice},
  date = {2020-03-31},
  langid = {en}
}
For attribution, please cite this work as:
Garcia-Castro, G. (2020, March 31). A primer on mixed-effects Models: theory and practice.