[R-sig-ME] Simple lme/lmer random effects questions
Andrew Robinson
A.Robinson at ms.unimelb.edu.au
Tue Aug 12 00:46:33 CEST 2008
Hi Brandon,
On Tue, Aug 12, 2008 at 12:03:34AM +0200, Brandon Invergo wrote:
> Hello,
> (I already sent this to the R-help list before I was informed that
> there's a SIG for mixed effects models...apologies if you receive this
> twice)
>
> I have two very rudimentary questions regarding the random effects terms
> in the lme and lmer functions. I apologize if this also partly strays
> into a general statistics question, but I'm a bit new to this all. So
> hopefully it'll be a quick problem to sort out...
>
> Here is my experimental setup: I raised butterflies in 5 different
> testing chambers all set to different temperatures. Within the testing
> chambers, the butterflies were held in 10 different sleeves, which were
> rotated daily to compensate for microenvironmental effects. I measured
> several traits of the butterflies and I am constructing models for each
> trait (unfortunately, multivariate analysis isn't possible). In my
> models, sex and temperature are fixed factors and the sleeve is a random
> effect. Most of the response variables are normally distributed, but
> there is one with a Gamma distribution (time until an event) and another
> with poisson distribution (counts), so some models use lme while others
> use lmer. I would like to determine if, despite the daily rotation,
> there are still random effects from the individual sleeves. My two
> questions (assuming I haven't already made grave errors in my
> description of the setup) are:
First, let me compliment you on the quality of the description of your
setup. Nice work!
> 1) In my data file, the "sleeve" variable is just marked with a number 1
> through 10; the temperature is noted in a different column, so the 50
> sleeves do not have unique names, but rather there are 5 instances of
> each of the 10 sleeve numbers. If sleeve is to be properly included in
> the models as a random effect, is it sufficient to leave the values as
> they are or should I generate unique names for all combinations of
> sleeve number and temperature, using something like
> > data$sleeve.in.temp <- factor(with(data, temp:sleeve)[drop=TRUE])
You should generate unique names for all combinations.
> 2) (this is the one that strays more into standard statistics territory,
> sorry) I'm a bit confused on how to actually set up the random effects
> term for the models. Given my experimental setup, using the lme syntax,
> should it be:
> > model <- lme(response ~ sex*temp, random=~temp|sleeve, data)
> or
> > model <- lme(response ~ sex*temp, random=~1|sleeve, data)
> or something else? I've searched and searched, but everything I find
> online seems to be significantly more advanced than what I'm doing,
> leaving me even more confused than when I started!
Based on your earlier description, I think that it should be
model <- lme(response ~ sex*temp, random=~1|temp/sleeve.in.temp, data)
but the following would also work just fine:
model <- lme(response ~ sex*temp, random=~1|temp/sleeve, data)
For the lmer syntax, I think that you should use
model <- lmer(response ~ sex*temp + (1|temp) + (1|sleeve.in.temp), ...
I strongly recommend Pinheiro and Bates as top reading for getting the
analysis right :)
Good luck!
Andrew
--
Andrew Robinson
Department of Mathematics and Statistics Tel: +61-3-8344-6410
University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599
http://www.ms.unimelb.edu.au/~andrewpr
http://blogs.mbs.edu/fishing-in-the-bay/
More information about the R-sig-mixed-models
mailing list