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.
Asked
Active
Viewed 3.4k times
13
kjetil b halvorsen
- 77,844
Roey Angel
- 345
1 Answers
18
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")

Sven Hohenstein
- 6,833
influence.MEpackage. Unfortunately, I don't have a solution for this task. – Sven Hohenstein Apr 01 '13 at 09:34infl <- influence(model, group = "cyl"), because you specified random effect as(1|cyl)? I don't know, I don't understand this at all, I just installed influence... but I don't really know when to useobs = TRUEand when to usegroup... – Tomas Dec 28 '15 at 10:11cooksD_data<-as.data.frame(cooks.distance(ft1)) cooksD_data_select<-cooksd[cooksD_data>0.1,drop=FALSE,] cooksD_oultiers<-as.numeric(rownames(cooksD_data_select))]– Estatistics May 26 '17 at 14:29hatvalues()function recommended here? – Tomas Jun 19 '19 at 18:04