[R] lme with nested factor and random effect
Mari Pesek
marifrances at gmail.com
Thu Dec 15 19:48:17 CET 2011
Hello all,
I'm having difficulty with setting up a mixed model using lme in the
nlme package. To summarize my study, I am testing for effects of
ornamentation on foraging behavior of wolf spiders. I tested spiders
at two different ages (penultimate vs. mature) and of two different
phenotypes (one species tested lacks ornamentation throughout life
[non-ornamented males] while the other acquires ornamentation upon
maturation [i.e. brush-legged males]). I tested a sample of
brush-legged and non-ornamented males (as both penultimates and
matures) in 2009, and an additional sample of brush-legged males in
2010 (as both penultimates and matures again) because I had a very
small sample of brush-legged males in 2009.
I would like to set up my lme so the fixed effects are "age"
(penultimate vs mature), "phenotype" (non-ornamented vs brush-legged),
and "year" (2009 vs 2010) nested within "phenotype" to test for
differences between the two samples of brush-legged males.
Additionally I want to include "id" (a unique identification number
given to each spider tested) as a random factor to account for testing
each individual twice (once as a penultimate and once as a mature).
So far I have the following code: lme(behavior ~ age*phenotype,
random=~1|maturity/id, data)
But I don't know how to include the code to nest year within phenotype
while testing for all possible interactions. Any help would be greatly
appreciated.
Thank you!
Mari Pesek
More information about the R-help
mailing list