[R] Simple lme/lmer random effects questions
Mark Difford
mark_difford at yahoo.co.uk
Tue Aug 12 09:33:37 CEST 2008
Hi Brandon,
>> ...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 might be luckier posting this on
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
You need to make a unique identifier for each of your five sets of sleeves
(or you need to nest sleeve in temp) if you wish to take account of that
structure (temp/sleeve) as a random effect. I could be mistaken, but I think
there are subtle differences between ~ 1|temp/sleeve and ~
1|data$sleeve.in.temp designs.
>> confused on how to actually set up the random effects term for the
>> models. Given my experimental setup, using the lme syntax...
The difference between (1) random = ~ 1|sleeve, ... and (2) random = ~
1+temp|sleeve is that the first will give a random intercept for each level
of sleeve, but the slope is fixed to be the same as their is no random term
for slope. In the second specification there is a random term for slope, viz
temp, so both intercepts and slopes can --- and probably will --- vary.
## To get some idea of what's being done, look at the following example.
## random intercepts, parallel slopes
mod1 <- lme(distance ~ age, Orthodont, random = ~ 1 | Subject)
## random intercepts, separate slopes
mod2 <- lme(distance ~ age, Orthodont, random = ~ age | Subject)
plot(augPred(mod1, primary=~age)) ## parallel slopes
plot(augPred(mod2, primary=~age)) ## separate slopes
HTH, Mark.
Brandon Invergo wrote:
>
> Hello,
>
> 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:
>
> 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])
>
>
> 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!
>
>
> Thank you very much for your help!! I want to be sure I do this analysis
> right....
> Cheers,
> -brandon
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
--
View this message in context: http://www.nabble.com/Simple-lme-lmer-random-effects-questions-tp18933698p18939376.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list