[R] Residuals from GLMMs in the lme4 package

Mairead Maclean M.M.Maclean at exeter.ac.uk
Fri Dec 9 11:12:01 CET 2005


Hello there

This is the first time I have used r-help message board so I hope I have got
the right address.

I am trying to check the residuals of a GLMM model(run using the package
lme4). I have been able to check the residiuals of REMLs in lme4 using the
following:

m1<-lmer(vTotal~Week+fCollar+ (1|fCat), collars)

res<-resid(m1)
plot(res)
qqnorm(res)
library(MASS)
par(mfrow=c(2,3))
res<-residuals(m1)
truehist(res,main="Histogram of Residuals")
curve(dnorm(x,mean=mean(res),sd=sd(res)),add=TRUE)
qqnorm(fitted(m1),resid(m1), ylim=range(fitted(m1)), main="QQNorm Plot")
plot(residuals(m1)~fitted(m1),main="Resid
vs.Fits",xlab="Fits",ylab="Resids");abline(h=0)
plot(residuals(m1),type="l",main="Resid vs Order",ylab="Resids")
acf(residuals(m1), main="Resid Autocorrelation")
boxplot(vTotal~fCollar, data=collars,main="Box plot of Collars", ylab="No.of
Prey", xlab="Collar")

but with this model:

m1<-lmer(vTotal~Week+fCollar+ (1|fCat), collars, poisson(), method = "PQL")

I can not get the above code line for residuals to work.  The stumbling
block is the residual command.  When I run it I get the following:
> res<-resid(m1)
> res
numeric(0)

Can not find any other way to get the residuals and I even tried getting the
fitted values from the model but get a similar output:

> catfit<-fitted(m1)
> catfit
numeric(0)

Do you think there may be something wrong with the model itself or is it
just that there is an alternative way to checking residuals in GLMMs?  I
would be very grateful for any help!

Many thanks

Mairead Maclean
Centre for Ecology and Conservation Biology
Exeter University
Tremough Campus
CORNWALL
UK
TR10 9EZ




More information about the R-help mailing list