[R-sig-ME] [R] Help with lmer, nested data and repeated measures

Andrew Robinson mensurationist at gmail.com
Thu Nov 18 22:12:28 CET 2010


Hi Simon,

I'm not sure that I agree with your nesting of the fixed effects inside each other, or inside the random effect. I would do that if I had a reason based on poor fit of a simpler model, but not as a consequence of the design that you have described. Also, do you want to allow for the possibility of learning? Your model doesn't presently accommodate that. 

Cheers

Andrew

On 19/11/2010, at 5:14 AM, Simon Garnier <sgarnier at princeton.edu> wrote:

> Dear all,
> 
> I'm discovering the somehow confusing (for me) world of linear mixed models after having been advised it could be the best option to analyze my dataset. After several days of reading, I'm not sure that what I ended up with makes some sense and I'd greatly appreciate any help and explanations.
> 
> The dataset has been obtained as follows. In 15 different locations, I counted during 10 seconds the number of ants crossing a gap, before and after destroying a bridge that ants had previously built over the gap. I then waited for the ants to rebuild the bridge and repeated two more times the counting and destroying process. Therefore, for each gap observed, I have 3 replicates of the same experiment, each of them providing 1 count value for each treatment tested (before and after bridge destruction), i.e. 6 values in total per gap. I also measured for each gap its length. 
> 
> I now want to model the effect of the gap length (GapLength, continuous variable), the treatment (Treatment, categorical variable) and the replicate position (Replicate, categorical variable) on the number of ants crossing the gap (AntCount, count variable). As far as I understand, the gap (Gap) can be treated here as a random effect, the gap length, the treatment and the replicate position as fixed effects. Moreover, the treatment variable is nested in the replicate position variable that is also nested in the gap variable. Finally, since I have count data, a poisson distribution should be used for the model. With all this information in mind and some additional information from various sources, I ended up with the following R code:
> 
> lmer(AntCount ~ Treatment + GapLength + (Treatment | Gap / Replicate) + (GapLength | Gap), data=dat, family=poisson(link=log))
> 
> The code runs fine and does not return any error. But of course this does not mean the model was correctly designed. Am I right when I'm doing this or am I (most likely) completely wrong? 
> 
> Thanks in advance for your help.
> 
> Best,
> Simon.
> 
> -- 
> --------------------------------------------------------------------------------
> Dr. Simon Garnier
> Department of Ecology & Evolutionary Biology
> Princeton University
> Guyot Hall
> 
> e-mail: sgarnier at princeton.edu / simon.garnier at gmail.com
> website: http://www.simongarnier.com
> photoblog: http://www.simongarnier.org
> --------------------------------------------------------------------------------
> 
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models




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