###INSTALL PACKAGES### # uncomment and run if you need to install # install.packages("lme4") # install.packages("r2mlm") # install.packages("dplyr") ###LOAD PACKAGES### library(lme4) library(r2mlm) library(dplyr) ###LOAD DATA### recall <- read.csv("https://stats.oarc.ucla.edu/wp-content/uploads/2024/12/recall.csv") ###EXERCISE 1### # 1. Run the random intercept model with words as the outcome and random intercepts by subj_id. # 2. Calculate the ICC for words. # 3. Use dplyr::mutate() to add the following to the data set: # a. cluster means for sleep and study (call them sleep_m and study_m) # b. subject-mean-centered sleep and subject-mean-centered study (call them sleep_c and study_c) # 4. Run a multilevel model with fixed and random slopes for sleep_c, # interpret the coefficient, and take note of the changes in residual and # random intercept variances from the random intercept model. # 5. Add sleep_m to the model in (4), interpret its coefficient, # and take note of the changes in variances again. ###EXERCISE 2### # 1. Use r2mlm() on the model in (5) in Exercise 1 # (fixed and random slopes of sleep_c, fixed slope for sleep_m) and interpret all output # 2. Use r2mlm_comp() to determine whether (sleep_c + sleep_m) or (study_c + study_m) explain # more variation in words. Model fixed and random slopes for the subject-mean-centered predictors.