Exercise

# Random-effect slopes

In the previous exercise, you saw how to code random-effect intercepts. During this exercise, you will see how to code random-effect slopes. With `lme4`

syntax, `lmer()`

uses `(countinuousPredictor|randomEffectGroup)`

for a random effect slope. When `lme4`

estimates a random-effect slope, it also estimates a random-effect intercept.

After fitting this model, you will see how to extract and plot the fitted model.
`ggplot2`

can plot many models using `geom_smooth()`

or `stat_smooth()`

, but not all models.
One trick to plot models not included with `ggplot2`

is to use the `predict()`

function to extract predicted values for a fit model.
These points can then be plotted with `ggplot2`

using `geom_line()`

.

Instructions 1/2

**undefined XP**

Use the

`lmer`

function from the`lme4`

package to fit a random-effects slope model. Using the`data.frame`

`multIntDemo`

to examine how`response`

can be predicted by a random slope using`group`

and`x`

.Examine both the default

`summary()`

output and the`tidy`

output. Notice how it differs from a normal linear model.