[R] lme4 package: Fitted values and residuals

Joel Dubin jdubin at uwaterloo.ca
Fri Nov 17 22:19:16 CET 2006


Hello,

Indeed, implementing the fitted and resid calls on the fm1 object from example(lmer), the fitted function worked, but the resid did not:

> resid(fm1)
Error in resid(fm1) : no slot of name "family" for this object of class "lmer"

I am using R 2.4.0 (on Windows XP), with the update of lme4 (lmer within) written for 2.4.0.

Thanks, Joel.




> Message: 79 Date: Fri, 17 Nov 2006 03:14:24 +0100 From: "Renaud 
> Lancelot" <renaud.lancelot at gmail.com> Subject: Re: [R] lme4 package: 
> Fitted values and residuals To: "Douglas Bates" <bates at stat.wisc.edu> 
> Cc: r-help at stat.math.ethz.ch, Frank Johannes <fjohannes at fastmail.fm> 
> Message-ID: 
> <c2ee56800611161814w419d7a59u13fbdfe0c02fa784 at mail.gmail.com> 
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed 
> 2006/11/16, Douglas Bates <bates at stat.wisc.edu>:
>> > On 11/16/06, Frank Johannes <fjohannes at fastmail.fm> wrote:
>>> > > Dear all,
>>> > > I have three concerns:
>>> > > 1)
>>> > > I am running models with the lme4 package. I cannot find a way to pull
>>> > > out a vector of the fitted values and the residuals. Does anybody know
>>> > > how to do it?
>> >
>> > The fitted() and resid() extractor functions are the usual way of
>> > doing this for a fitted model in R and, astonishingly enough, they
>> > work!  Try
>> >
>> > library(lme4)
>> > example(lmer)
>> > fitted(fm1)
>> > resid(fm1)
>
> But resid does not seem to work with GLMMs:
>
>> > library(lme4)   ##  version 0.9975-9
> Le chargement a n?cessit? le package : Matrix
> Le chargement a n?cessit? le package : lattice
>> > m1 <- lmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
> +             family = binomial, data = cbpp)
> relative tolerance set to 9.8721686386158e-05
>> > resid(m1)
> Erreur : 'resid' n'est pas encore impl?ment?
>
> [in English: Error: 'resid' is not implemented yet]
>
> Best,
>
> Renaud
>



More information about the R-help mailing list