[R-sig-eco] "random" lme syntax

Kingsford Jones kingsfordjones at gmail.com
Fri Jul 18 00:22:08 CEST 2008


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:
> Hello everyone!
>
> I am helping a friend analyze her data on the effect of helpers-at-nest on
> feeding rates ("feeding") in a species of bird. Her data is as follows:
>
> - two groups ("helpers"; helpers/no helpers)
> - observations conducted at several development stages of the nestlings
> ("age"; repeated measures at each nest, days 1, 6 and 12)
> - during 2 years ("year"; 2006/2007, as a covariate; each couple and nest
> only observed during one of these years)
>
> She's also interested in the interaction between helpers and age of the nest
> Intuitively, using lme, I'd guess the formula should be:
>
> lme(feeding~helpers*age+year, random=~1|nest_id, data=tanagers)
>
> However, in Michael Crawley's "The R Book" example of "Mixed-Effects models
> with Temporal Pseudoreplication", page 642, the explanation goes as follows:
>
> "Because we have a continuous random effect (weeks) we write ~week in the
> random-effects formula rather than the ~1 that we used with categorical
> random effects (above)."
>
> It may be because I am not so familiarized with lme models, but this didn't
> make much sense to me... Only due to the repeated measures being continuous
> or categorical, I should change the syntax of which portion of my model has
> random effects? If I'm measuring the same individual through time, shouldn't
> that be specified on the model as an hierarchical design (say,
> random=~1|nest_id/age) rather than earlier?
>
> This got me quite confused, so any comments would be greatly appreciated...
>
> Best,
> Rafael Maia
> ---
> "A little learning is a dangerous thing; drink deep, or taste not the
> Pierian spring." (A. Pope)
> M.Sc. Student
> Animal Behavior Lab - Dept. of Zoology
> Universidade de Brasilia, Brazil
> http://www.unb.br/ib/zoo/rhmacedo/
>
> _______________________________________________
> R-sig-ecology mailing list
> R-sig-ecology at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
>



More information about the R-sig-ecology mailing list