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

Leo Gürtler leog at anicca-vijja.de
Sun Nov 23 11:48:47 CET 2008


Dear Douglas,

> 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.

thanks for your explanations. In my case the grouping factors are nested
and in the way they are nested they do make sense (i.e. no crossed or
patially crossed grouping factors):

repeated measurements of persons in classes in schools

However, your answer means that I have to write my own code in
accordance to the level for which I need residuals. AFAIU the residuals
(e.g. on the level of 'classes') are 'shrunken' towards the group mean
so I have to reflate them? Is there a formula for that (I found in the
literature a formula for 'intercept' but not for 'slope'). In my case I
have 'slope' involved.

Thanks - to know how to reflate would be sufficient for me (or any
literature link where I can find that). I assume that by knowing how to
reflate I can proceed by formulating the equation for the level for
which I need residuals.

best regards,
leo

> 
> 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