# How do I identify a particular residual from a mixed-effects model in R?

Here's a plot of my residuals from a mixed-effects model in R (using lme4).

There's one 'outlying' residual with a value of around 35 (index circa 90) that seems anomalous. I don't know if it has any statistical significance (any advice of that would be appreciated) but I'm curious if perhaps I've made an error entering that data point... but how can I find out what the record number for that observation is in my original data set?

Here is an example that illustrates how to find the indices of observations based on residuals.

An example:

library(lme4)
fm1 <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy)
plot(residuals(fm1))


There are two residuals with a absolute value above 100. You can use which to obtain the indices.

which(residuals(fm1) > 100)
# 57
# 57
which(residuals(fm1) < -100)
# 8
# 8


The numbers appear twice because the function residuals returns a named vector, and the names are the indices.

Another possibility (you may need the development version of lme4, installable via devtools::install_github("lme4/lme4")) is

plot(fm1,id=0.05,idLabels=~.obs)


which will add observation-number labels to all observations in the 5% Normal tail of the residuals.

• Thank you for the suggestion. I'm wary of confusing versions of lme4. Your suggestion with the idLabels does work with my current version of lme4 (1.1-7) however it requires about two dozen zeroes after the decimal point to prevent it plotting all the id labels. Feb 15, 2015 at 10:28