Lecture 9: Mixed models

A model for the mean

  • The sleep-study data set contains data from a sleep deprivation experiment. The outcome is reaction times (ms).
  • We will start by describing the data using a simple regression model \(y=\beta_0\), describing the average in the data.

The mean changes with Days

  • In the study, participants were deprived of sleep over several days, we have reason to believe that reaction times gets worse
  • To capture this we add a parameter to the model that will describe the change over Days in Reaction time.
\(y_i=\beta_0 + \beta_1 \times \text{Days}_i\)

The mean changes with Days

Accounting for different participants

  • In the study we follow individuals over time, the model should account for this
  • We could start by adding our first varying effect, participant-level intercepts.

\(y_i = \beta_0 + \beta_1 \times \text{Days}_i + b_{0~ij}\)

Adding varying slopes

  • We would like to let the model account for differences between participants in the response to the experiment
  • We add our second varying effect, participant-level slopes.

\(y_i = \beta_0 + \beta_1 \times \text{Days}_i + b_{0~ij} + b_{1~ij}\)

Pooling of effects

  • Our model now contains partially pooled varying effects(!)
  • Varying effects means that an effect may vary between clusters (groups, participants, etc.)
  • Partially pooled means that when estimating a cluster specific effect the model borrows (pools) information from other clusters.
  • Complete pooling means that we estimate a common parameter for all clusters, no pooling means that we estimate separate parameters for all clusters.

Partial pooling

A model with many names

  • The varying effects models with partial pooling are also sometimes called mixed-effects models, random effects models, multilevel models, hierarchical models
  • A random effect is the varying part of a mixed model, we can think of this effect being drawn from a population of effects.
  • The fixed effect is the population average.

Interpreting outputs

  • We can fit a mixed-effects model using the lme4 package in R
  • lme4 has a simple syntax lmer(Reaction ~ Days + (1 + Days|Subject), data = df)
Linear mixed model fit by REML ['lmerMod']
Formula: Reaction ~ Days + (1 + Days | Subject)
   Data: dat

REML criterion at convergence: 1404.1

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-4.0157 -0.3541  0.0069  0.4681  5.0732 

Random effects:
 Groups   Name        Variance Std.Dev. Corr 
 Subject  (Intercept) 992.69   31.507        
          Days         45.77    6.766   -0.25
 Residual             651.59   25.526        
Number of obs: 144, groups:  Subject, 18

Fixed effects:
            Estimate Std. Error t value
(Intercept)  245.097      9.260  26.468
Days          11.435      1.845   6.197

Correlation of Fixed Effects:
     (Intr)
Days -0.454

When mixed models fail

  • Sometimes we do not have enough data to estimate varying effects, a simpler varying effects model has even simpler alternatives (workshop).
  • Sometimes models gets too complicated and the algorithm does not converge.

Thank you!