Tutorial: Linear, generalized and nonlinear mixed models with the lme4 package

Douglas Bates, University of Wisconsin - Madison, USA, and R-core Development Team.


In workshops at the useR!2006 and useR!2007 meetings we illustrated the use of the lmer function in the lme4 package to fit linear mixed models to longitudinal data. This workshop will also describe fitting and analyzing mixed models using the lme4 package but will concentrate on data structures beyond longitudinal data for which mixed models can be appropriate. We will consider models for data with random effects for crossed factors. Typically these are data on a selection of subjects exposed to a selection of stimuli. Models for Such data can be fit and analyzed in a straightforward way in lme4 without the need to resort to awkward approximate analyses, such as "F1" and "F2" analyses. We will discuss the use of glmer to fit generalized linear mixed models, used when the observed responses are binary responses (or, more generally, binomial responses) or counts that may be modeled with a Poisson distribution or positive values for which a Gamma conditional distribution may be appropriate. We will also discuss the use of nlmer to fit nonlinear mixed models, such as compartment models that used in population pharmacokinetics. Finally we will combine all of these variations in a generalized nonlinear mixed model with crossed random effect for item-response analysis, which is the analysis of response data from tests or surveys, such as correct/incorrect scores on an objectively scored exam like a multiple-choice exam, with random effects for student abilities and for item difficulties and discriminations. The ability and difficulty random effects appear as location effects in the predictor obtained by applying the link function to the probability of a correct answer. However, random effects for item discriminations are scale effects leading to a generalized nonlinear mixed model with crossed random effects. Such models can be fit with the lme4 package.