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.3 (2024-02-29 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 11 x64 (build 22631)

Matrix products: default


locale:
[1] LC_COLLATE=English_United Kingdom.utf8 
[2] LC_CTYPE=English_United Kingdom.utf8   
[3] LC_MONETARY=English_United Kingdom.utf8
[4] LC_NUMERIC=C                           
[5] LC_TIME=English_United Kingdom.utf8    

time zone: Europe/Berlin
tzcode source: internal

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

other attached packages:
[1] xaringanExtra_0.8.0

loaded via a namespace (and not attached):
 [1] htmlwidgets_1.6.4 compiler_4.3.3    fastmap_1.2.0     cli_3.6.3        
 [5] htmltools_0.5.8.1 tools_4.3.3       yaml_2.3.9        rmarkdown_2.27   
 [9] knitr_1.48        jsonlite_1.8.8    xfun_0.46         digest_0.6.36    
[13] rlang_1.1.4       renv_1.0.5        evaluate_0.24.0  

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},
  url = {http://github.com/gongcastro/gongcastro.github.io/blog/primer-linear-mixed-models/primer-linear-mixed-models.html},
  langid = {en}
}
For attribution, please cite this work as:
Garcia-Castro, G. (2020, March 31). A primer on mixed-effects Models: theory and practice. http://github.com/gongcastro/gongcastro.github.io/blog/primer-linear-mixed-models/primer-linear-mixed-models.html