[R-sig-ME] Simple lme/lmer random effects questions

Martin Henry H. Stevens HStevens at muohio.edu
Tue Aug 12 11:58:17 CEST 2008

Hi Brandon,
Yet another perspective.
On Aug 11, 2008, at 6:03 PM, 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:
> 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!
### Assuming temp is continuous...
m1 <- lmer(response ~ sex*temp + (1|sleeve.in.temp) + (temp-1| 
sleeve.in.temp), data) # enforcing independence of slope and intercept
m2 <- lmer(response ~ sex*temp + (temp|sleeve.in.temp), data) #  
enforcing dependence of slope and intercept
m3 <- lmer(response ~ sex*temp + (1|sleeve.in.temp), data) # No  
difference in slopes; merely difference in intercept
### Assuming temp is categorical...
m1 <- lmer(response ~ sex*temp + (1|sleeve.in.temp) + (1|temp), data)
m2 <- lmer(response ~ sex*temp + (1|sleeve.in.temp), data) #  
enforcing dependence of slope and intercept
m3 <- lmer(response ~ sex*temp + (1|temp), data) # No difference in  
slopes; merely difference in intercept

> Thank you very much for your help!! I want to be sure I do this  
> analysis
> right....
> Cheers,
> -brandon
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models

Dr. Hank Stevens, Associate Professor
338 Pearson Hall
Botany Department
Miami University
Oxford, OH 45056

Office: (513) 529-4206
Lab: (513) 529-4262
FAX: (513) 529-4243
"E Pluribus Unum"

"I love deadlines. I love the whooshing noise they make as they go by."
                                             (Douglas Adams)

If you send an attachment, please try to send it in a format anyone  
can read, such as PDF, text, Open Document Format, HTML, or RTF.
Why? See:  http://www.gnu.org/philosophy/no-word-attachments.html

More information about the R-sig-mixed-models mailing list