Last updated 2024-09-26.
This Github repo contains all lesson files for Hierarchical Linear
Models in R. The goal is to impart students with the basic tools to
construct, evaluate and compare various (generalized) linear mixed
models, using
lme4
,
based on Lesa Hoffman’s Longitudinal Analysis: Modeling Within-Person
Fluctuation and Change.
(Materials developed with Yael Bar-Shachar.)
These topics were taught in the graduate-level course Hierarchical Linear Models for Psychologists (Psych Dep., Ben-Gurion University of the Negev; Psych Dep., Tel-Aviv University). This course assumes basic competence in R (importing, regression modeling, plotting, etc.), along the lines of Practical Applications in R for Psychologists.
Notes:
- This repo contains only materials relating to Practical Applications in R, and does not contain any theoretical or introductory materials.
- Please note that some code does not work on purpose, to force students to learn to debug.
You will need:
- A fresh installation of
R
(preferably version 4.3.2 or above). - RStudio IDE (optional, but recommended).
- The following packages, listed by lesson:
You can install all the packages used by running:
# in alphabetical order:
pkgs <- c(
"afex", "bayestestR", "brms", "car", "datawizard", "DHARMa",
"dplyr", "effectsize", "emmeans", "forcats", "ggplot2", "glmmTMB",
"glue", "haven", "insight", "lme4", "lmerTest", "loo", "marginaleffects",
"merDeriv", "mixedup", "mlmRev", "nlme", "parameters", "patchwork",
"performance", "posterior", "remotes", "scales", "see", "sjPlot",
"statmod", "tidyverse"
)
install.packages(pkgs, dependencies = TRUE)
Package Versions
The package versions used here:
afex
1.4-1 (CRAN)bayestestR
0.14.0 (CRAN)brms
2.21.0 (CRAN)car
3.1-2 (CRAN)datawizard
0.12.3 (CRAN)DHARMa
0.4.6 (CRAN)dplyr
1.1.4 (CRAN)effectsize
0.8.9 (CRAN)emmeans
1.10.4 (CRAN)forcats
1.0.0 (CRAN)ggplot2
3.5.1 (CRAN)glmmTMB
1.1.9 (CRAN)glue
1.7.0 (CRAN)haven
2.5.4 (CRAN)insight
0.20.4 (CRAN)lme4
1.1-35.5 (CRAN)lmerTest
3.1-3 (CRAN)loo
2.8.0 (CRAN)marginaleffects
0.22.0 (CRAN)merDeriv
0.2-4 (CRAN)mixedup
0.4.0 (Github: m-clark/mixedup)mlmRev
1.0-8 (CRAN)nlme
3.1-164 (CRAN)parameters
0.22.2 (CRAN)patchwork
1.3.0 (CRAN)performance
0.12.3 (CRAN)posterior
1.6.0 (CRAN)remotes
2.5.0 (CRAN)scales
1.3.0 (CRAN)see
0.9.0 (CRAN)sjPlot
2.8.16 (CRAN)statmod
1.5.0 (CRAN)tidyverse
2.0.0 (CRAN)