Skip to content

mattansb/Hierarchical-Linear-Models-foR-Psychologists

Repository files navigation

Hierarchical Linear Models foR Psychologists

Last updated 2026-03-30.

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.

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.

Setup

You will need:

  1. A fresh installation of R (preferably version 4.5.0 or above).
  2. RStudio IDE or Positron (optional, but recommended).
  3. The following packages, listed by lesson:
Lesson Packages
01 HLM basics tidyverse, lmerTest, performance, parameters, merDeriv, emmeans, haven, sjPlot, afex
02 estimation and inference tidyverse, lmerTest, performance, parameters, haven, scales, glue, sjPlot, bayestestR
03 cross-level interactions and effect sizes tidyverse, datawizard, lmerTest, performance, parameters, marginaleffects, scales
04 growth models tidyverse, lmerTest, parameters, performance, marginaleffects, haven, scales, glue, ggplot2, pak, lme4, parameters, haven, nlme, glmmTMB, brms
05 within-person fluctuation models tidyverse, datawizard, lmerTest, performance, parameters, haven
06 GLMMs tidyverse, lme4, performance, parameters, marginaleffects, haven, insight, scales, glmmTMB, brms
07 multilpe random factors tidyverse, patchwork, lmerTest, performance, parameters, marginaleffects, mlmRev, forcats
08 ANOVA tidyverse, datawizard, lmerTest, emmeans, afex, car, effectsize, patchwork, performance, statmod, see
09 misc tidyverse, lmerTest, performance, DHARMa, scales, brms, dplyr, afex, parameters, rstanarm

Installing R Packages

You can install all the R packages used by running:

# in alphabetical order:

pak::pak(
  c(

    "cran::DHARMa", # 0.4.7
    "cran::afex", # 1.5-1
    "cran::brms", # 2.23.0
    "cran::car", # 3.1-5
    "cran::easystats", # 0.7.5
    "cran::emmeans", # 2.0.2
    "cran::glmmTMB", # 1.1.14
    "cran::glue", # 1.8.0
    "github::lme4/lme4", # 2.0-2
    "cran::lmerTest", # 3.2-1
    "cran::marginaleffects", # 0.32.0
    "cran::merDeriv", # 0.2-5
    "cran::mlmRev", # 1.0-8
    "cran::nlme", # 3.1-168
    "cran::pak", # 0.9.2
    "cran::patchwork", # 1.3.2
    "cran::rstanarm", # 2.32.2
    "cran::scales", # 1.4.0
    "cran::sjPlot", # 2.9.0
    "cran::statmod", # 1.5.1
    "cran::tidyverse" # 2.0.0

  )
)

Acknowledgements

Materials developed with Yael Bar-Shachar.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages