Mixed-Effects Models in R

The very basics of how to run models with random effects in R

This page assumes that you already understand the basics of how to run a linear model and how to interpret linear model output.

Mixed-effects models can be built in R using the lme4 package. Other packages to work with mixed-effects models are GLMMadaptive, glmmML, glmmTMB, and MCMCglmm.

Linear and generalized linear mixed-effects models have the following structure: outcome variable ~ fixed effects + random effects.

  • Outcome variable = the variable that is hypothesized to be modified by the predictors. For example in a looking while listening study looking time would be a likely outcome variable.

  • Fixed effects are predictors that affect the outcome consistently across all observations. For example, in a looking while listening task where children heard some mixed language phrases, language mixing is a fixed predictor of looking time because mixing was always the same in each experiment for each participant.

  • Random effects are grouping variables where we expect individual differences. For example, in a looking while listening task we expect each child to perform differently based on their individual traits, so participant is a random predictor of looking time.

To learn more about mixed-effects modelling:

Last updated