[R-sig-ME] lmer formula syntax?
Toby Marthews
toby.marthews at ouce.ox.ac.uk
Wed Feb 2 01:24:49 CET 2011
Hi Colin,
I'm perhaps not very "informed opinion", but:
- Shouldn't your formula be simply ept~wshed*riparia+(1|stream) ? (no need to put in (1|wshed/stream) because you've specified you've got non-implicit labels for your streams, i.e. if you know the stream number then you automatically know the wshed value already).
- Not sure about using stream:riparia as a random variable ...
- Also, where did you read that "wshed/stream" is interchangeable with "wshed:stream"? For me they're different ...
HTH?
Toby
----------------
Toby Marthews - Plant Ecologist / Modeller / Mathematician
________________________________________
From: r-sig-mixed-models-bounces at r-project.org [r-sig-mixed-models-bounces at r-project.org] On Behalf Of Colin Wahl [biowahl at gmail.com]
Sent: 01 February 2011 22:14
To: r-sig-mixed-models at r-project.org
Subject: [R-sig-ME] lmer formula syntax?
Dear r-sig-mixed-models List,
I've been digging through the r-help archive and various books in search of an answer to my query. I have been thus far unsuccessful. I am not new to R, but have primarily focused on multivariate non parametric analyses in the past; my experience with lmer has been confined to the last few weeks. The model formulas I have written work and I have some idea of which are accurate/best based on AIC scores, but I would very much appreciate an informed opinion on my syntax.
I am performing an ecological study of stream health using %EPT (An aggregate relative abundance variable for invertebrates) as my response variable. I am interested in how invertebrate counts vary between different watershed types (forested, cultivated, developed, grassland) and reach types (forested, non forested). There are a total of 12 streams, 12 watersheds and 24 reaches. The wshed factor is unbalanced.
Data structure:
> str(ept)
'data.frame': 72 obs. of 4 variables:
$ wshed : Factor w/ 4 levels "c","d","f","g": 1 1 1 1 1 1 1 1 1 1 ...
$ stream : Factor w/ 12 levels "BA","D1","D2",..: 4 4 4 6 6 6 10 10 10 4 ...
$ riparia: Factor w/ 2 levels "F","N": 1 1 1 1 1 1 1 1 1 2 ...
$ ept : num 0.318 0.156 0.194 0.146 0.158 ...
stream is the only random variable and it is nested (not implicitly) in wshed. My standard statistical model is as follows:
ept(ijkl) = ì + wshedi + stream(i)j + ripariak + wshed*ripariaik + stream*riparia(i)jk + å(ijk)l
The best option I have come up with thus far is:
>model<-lmer(ept ~ wshed + riparia + wshed:riparia + (1| wshed/stream) + (1| stream:riparia), data=ept, family="gaussian")
or alternatively:
>model<-lmer(ept ~ wshed*riparia + (1| wshed/stream) + (1| stream:riparia), data=ept, family="gaussian")
Question: Am I specifying the random terms and nesting structure correctly?
Secondarily: I have read a few times that "wshed/stream" is interchangeable with "wshed:stream" which is a meaningless interaction. Also I've seen that random effects are specified as (a|b) where a is a covariate and b is a grouping factor. Does having 1 as a covariate simply specifying an intercept of 1? What is the purpose of placing a factor in the place of 1 as a covariate? OR is there a nice complete summary tutorial that I've missed.
I'm looking forward to hearing any comments.
Thank you,
--
Colin Wahl
Department of Biology
Western Washington University
Bellingham, WA 98225
ph: 360-391-9881
More information about the R-sig-mixed-models
mailing list