Multilevel analysis of Reaction time vs. Days of Sleep Deprevation

An analysis of subject reaction time vs. how many days they've been sleep deprived.

I fit a number of models to the Sleepstudy dataset (https://rdrr.io/cran/lme4/man/sleepstudy.html)
The first model is a common slope and intercept. This is analagous to linear regression with days predicting reaction time.
The second model fits a random intercept for each subject with a common slope.
The third model fits a random intercept and random slope for each subject.
The fourth model, which I judge as the best based on RMSE, fits a random intercept, slope, and independent within subject variance.


The model parameterization for the fourth model is:



Linear Regression


The "linear regression" assumes a general effect of sleep deprivation days on the population, but does a poor job of explaining subjects that don't follow the general pattern.


Random Slopes and Intercepts


The random slopes and intercepts model fits the data the best. It shows a general effect of sleep deprivation days on reaction time, but this is dependent on the subject.


The random slopes and intercepts model fits the data the best. It shows a general effect of sleep deprivation days on reaction time, but this is dependent on the subject.


RMSE for each of the models on the dataset is as follows:

m0: 47.533

m1: 29.500

m2: 23.434

m3: 23.240


The notebook for my analysis is here: https://github.com/btbyrnes/multilevel_models/blob/main/sleepstudy.ipynb