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

Leonardo Salas lsalas at prbo.org
Fri Nov 19 18:30:47 CET 2010


Simon,

It's not clear to me why you distinguish between gap and gaplength. If there is any effect of gap, is that not reflected in gaplength? Is there an ordinal or spatial effect of gap?

Try this?
glmer(AntCount ~ Treatment + GapLength + Replicate + (1|Gap) + (0|Gap), data=dat, family=poisson)

Leo

------------------------------

Message: 5
Date: Thu, 18 Nov 2010 13:14:36 -0500
From: Simon Garnier <sgarnier at Princeton.EDU>
To: r-sig-ecology at r-project.org
Subject: [R-sig-eco] [R] Help with lmer, nested data and repeated
        measures
Message-ID: <E8C1A04D-E780-4D70-8AA7-287CCD3E54E5 at Princeton.EDU>
Content-Type: text/plain; charset=us-ascii

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
--------------------------------------------------------------------------------



------------------------------

Message: 6
Date: Thu, 18 Nov 2010 15:03:44 -0600
From: "Carl Von Ende" <cvonende at niu.edu>
To: <r-sig-ecology at r-project.org>
Subject: [R-sig-eco]  New to R
Message-ID: <4CE540500200005F000CD72A at wpo.cso.niu.edu>
Content-Type: text/plain

Hi Bob,

Probably the most broad-based book for statistical analysis in R is the  "R Book" by Michael Crawley, puublished by John Wiley. All the code and data sets used in the book are available on the web.

Carl von Ende


******************************************
Carl N. von Ende
Department of Biological Sciences
Northern Illinois University
DeKalb, IL 60115-2861

Office:            (815) 753-7826
Fax:                (815) 753-0461
email:              cvonende at niu.edu
******************************************

        [[alternative HTML version deleted]]



------------------------------

_______________________________________________
R-sig-ecology mailing list
R-sig-ecology at r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology


End of R-sig-ecology Digest, Vol 32, Issue 18



More information about the R-sig-ecology mailing list