14.1 Introduction

This week we will talk about extending linear models and generalized linear models to include “random effects” in the model, thus resulting in the “generalized linear mixed model” or GLMM. The GLMM is actually the most generalized formulation of the linear models that we have been discussing now for the past several weeks. All linear models (GLM, ANCOVA, ANOVA, regression, t-tests, etc.) are special cases of the GLMM. As such, we can think of the GLMM as the framework within which we have been working for weeks now! We will start with examples of the linear mixed model (LMM) in this Chapter and extend these to include non-normal data when we dig into the GLMM in Chapter 15.

In this chapter, we’ll introduce some tools from the lme4 and merTools packages in addition to the usual suite of functions we need from the tidyverse. You’ll need to install these before you can use them. Then, go ahead and load them up when you are ready to get started:

library(tidyverse)
library(lme4)
library(merTools)