Linear Mixed Effects Models – How to Extract Leverage and Cook’s Distances

leveragelinear modelmixed modelrresiduals

Does anyone know how to compute (or extract) leverage and Cook's distances for a mer class object (obtained through lme4 package)?
I'd like to plot these for a residuals analysis.

Best Answer

You should have a look at the R package influence.ME. It allows you to compute measures of influential data for mixed effects models generated by lme4.

An example model:

library(lme4)
model <- lmer(mpg ~ disp + (1 | cyl), mtcars)

The function influence is the basis for all further steps:

library(influence.ME)
infl <- influence(model, obs = TRUE)

Calculate Cook's distance:

cooks.distance(infl)

Plot Cook's distance:

plot(infl, which = "cook")

enter image description here