Skip to content

Residuals from GLMMs in the lme4 package

2 messages · Mairead Maclean, Renaud Lancelot

#
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:
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:
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
#
I guess you are using obsolete versions of lme4 / Matrix. Please
update and try again. The current versions are:
Information on package 'Matrix'

Description:

Package:              Matrix
Version:              0.99-2
Date:                 2005-11-14

[snip]
Information on package 'lme4'

Description:

Package:       lme4
Version:       0.98-1
Date:          2005-07-27

[snip]

Best,

Renaud

2005/12/9, Mairead Maclean <M.M.Maclean at exeter.ac.uk>:
--
Renaud LANCELOT
D??partement Elevage et M??decine V??t??rinaire (EMVT) du CIRAD
Directeur adjoint charg?? des affaires scientifiques

CIRAD, Animal Production and Veterinary Medicine Department
Deputy director for scientific affairs

Campus international de Baillarguet
TA 30 / B (B??t. B, Bur. 214)
34398 Montpellier Cedex 5 - France
T??l   +33 (0)4 67 59 37 17
Secr. +33 (0)4 67 59 39 04
Fax   +33 (0)4 67 59 37 95