[R-sig-ME] residuals for different levels (lmer)

Douglas Bates bates at stat.wisc.edu
Fri Nov 21 15:29:07 CET 2008

On Fri, Nov 21, 2008 at 12:49 AM, Leo Gürtler <leog at anicca-vijja.de> wrote:
> Dear SIG-ME,

> is there a way to obtain residuals for the different levels with lmer as
> it is possible with lme?

To fit a model with lme incorporating random effects for more than one
grouping factor you must have nested grouping factors, which means
that the concept of levels will make sense.  The lmer specification is
more general, allowing for crossed or partially crossed grouping
factors.  In those circumstances defining residuals incorporating
random effects from some grouping factors but not from others is
trickier.  That's even before considering other models like
generalized linear mixed models and nonlinear mixed models that can be
fit in lme4.

I often regret adding code that works for certain special cases
without thinking through the general situation.  The "coef" method in
lme4 is an example of such a case.  It is not clear that the result is
meaningful when applied to models with crossed or partially crossed
grouping factors.

> library(nlme)
> example(lme)
> residuals(fm1, level=0:1)
> library(lme4)
> example(lmer)
> residuals(fm1, level=0:1)
> -> the call to 'residuals' in combination with 'lmer' brings only the
> residuals of one level.
> How can I obtain residuals for different levels?
> thanks,
> best regards,
> leo gürtler
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models

More information about the R-sig-mixed-models mailing list