Skip to content
Prev 14477 / 20628 Next

extract level 2 residuals of merMod from lme() and test for spatial autocorrelation.

Dexter Locke <dexter.locke at ...> writes:
Not sure what you mean here -- this is a little bit inconsistent.
lmer (from lme4) makes merMod objects, lme (from nlme) makes lme objects.
I'm going to assume you're talking about lmer (since that's a more
likely typo).
I always get confused about what levels mean in the context of 
mixed models (i.e. whether one counts down from the population level
or up from the individual level), but the basic answer here is to
get the *predictions* at the desired level and subtract them from
the observed values, see ?predict.merMod -- the re.form argument
is what you need.  re.form=NA or re.form=~0 gives you predictions
at the population level (i.e. neglecting all random effects),
re.form=NULL gives you predictions at the individual level (i.e.
including all random effects), intermediate cases can be gotten
by using a formula.

The results will be ordered the same as the original observation
vector.
Seems reasonable.