# Lesson 18: Mixed Effects Models

Lesson 18: Mixed Effects Models## Overview

In this chapter we'll make a quick non-technical overview of fitting mixed effects models, focusing on the use of the function lme().

## Objectives

- Recognize when a mixed effects model might be appropriate
- Be able to fit simple repeated measures models with lme()
- Be able to fit simple split-plot models with lme()

## R

The R code file and data files for this lesson can be found on the Essential R - Notes on learning R page.

# 18.1 - What is a Mixed Effects Model?

18.1 - What is a Mixed Effects Model?Here we'll introduce the idea behind the mixed-effects model.

# 18.2 - Repeated Measures Done the Wrong Way

18.2 - Repeated Measures Done the Wrong WayNow we'll begin a demonstration of the *wrong* way to analyze data that includes repeated measures, using the "machines" data included in the package nlme.

# 18.3 - Repeated Measures Using Mixed Effects I

18.3 - Repeated Measures Using Mixed Effects IHere we'll demonstrate the use of `lme()`

to fit a mixed effects model - in this case a separate intercept for each worker.

# 18.4 - Repeated Measures Using Mixed Effects II

18.4 - Repeated Measures Using Mixed Effects IINow we'll try a different model, with the machine * worker interaction as a random effect. The substantial reducion in AIC and the more reduced patterning in the residuals suggests thtat this ia a superior model.

# 18.5 - Split-plot Using Mixed Effects

18.5 - Split-plot Using Mixed EffectsHere we'll revisit the split-plot experiment we analyzed using `aov()`

in Lesson 13, this time with `lme()`

.

# 18.6 - Using anova() to Compare Models

18.6 - Using anova() to Compare ModelsHere we'll demonstrate the use of `anova()`

to compare two models fit by `lme()`

- note that the models must be nested and the both must be fit by ML rather than REML.