Skip to content
Prev 282 / 7420 Next

"random" lme syntax

Hi Rafael,

Rather than thinking about continuous vs categorical random effects I
think it's better to think about predicting random effects (which are
specified by the left-hand side of the "|" in the random argument) for
each level of the factor specified by the right-hand side of the "|".
Therefore if you use random = ~1|nest_id, you predict a random
intercept for each nest, while random = ~age|nest_id (which is the
same as writing random = ~1 + age|nest_id) specifies that random
intercepts and slopes (for the age effect) are to be predicted for
each nest.

Lattice plots can be very helpful for visualizing what's going on --
in this case creating a scatterplot for each level of nest_id, with
age as the x-axis and feeding as the y-axis. Just by looking at the
plot you'll have an idea if there is random variation in intercepts
and/or slopes between nests.

Now, think about the random argument you asked about: random =
~1|nest_id/age.  The nest_id/age specifies which levels to predict
random effects, and the 1 specifies which random effect to estimate.
So you are asking lme to predict a random interecept for each level of
a factor created by nest_id/age (i.e. each age within each nest).
However, if I understand the study, there is only one feeding value
for each age within each nest, and you therefore would not have
degrees of freedom left for residual error, so that isn't a viable
random argument.  You would also run into this problem if you tried
random = ~ 1 + age + I(age^2)|nest_id because there are only 3 time
points within each nest.

Finally, you also have the problem that after fitting the fixed and
random effects there may well be correlation in the residuals within
nests due to the temporal structure of the measurements, and
correlation between nests due to spatial proximity. The correlation
argument to lme can help you model one of these issues, but not both
simultaneously.  If you wanted to try to deal with the "temporal
pseudoreplication" you could try to fit your fixed effects, then a
random intercept for each nest (which induces a compound symmetric
correlation structure for each nest, but not a temporal structure),
then correlation = corAR1(form = ~age|nest_id) to model the temporal
component with an AR(1) structure.  However 3 time points isn't very
many for estimating an autoregressive correlation structure and you
may be better off sticking with the compound symmetric correlation
from random = ~1|nest_id or random = ~age|nest_id.

Because of the inherent complexity of fitting mixed models I highly
recommend Pinheiro and Bates 2000 as reading for anyone fitting mixed
models in R/S.

best of luck,

Kingsford Jones



On Thu, Jul 17, 2008 at 1:29 PM, Rafael Maia
<queirozrafaelmv at yahoo.com.br> wrote: