[R-sig-ME] multiple nested random factors
Amanda Adams
aadams26 at uwo.ca
Fri Feb 22 08:18:49 CET 2013
Hello!
I have been having a heck of a time figuring out how to estimate the
proportion of variance from several random factors. I have a count data
of the number of bat calls recorded at 3 sites, on 6 detectors, over 12
nights. Detectors were at 2 heights.
If I understand nested factors correctly, Detectors are nested in Site
and Night is nested in Site. Site/Detector and Site/Night are random
factors and Height is a fixed factor.
Also, data is overdispersed so I am transforming number of calls as
log(Calls+1).
'data.frame': 249 obs. of 11 variables:
$ Night : int 1 3 5 11 12 1 3 5 11 12 ...
$ Night2 : int 1 2 3 4 5 1 2 3 4 5 ...
$ Site : int 1 1 1 1 1 1 1 1 1 1 ...
$ Species : int 1 1 1 1 1 1 1 1 1 1 ...
$ Detector : int 1 1 1 1 1 2 2 2 2 2 ...
$ Height : int 1 1 1 1 1 2 2 2 2 2 ...
$ Calls : int 6 444 236 12 143 5 815 712 30 142 ...
$ f.Night : Factor w/ 12 levels "1","2","3","4",..: 1 2 3 4 5 1 2 3
4 5 ...
$ f.Site : Factor w/ 4 levels "1","2","3","4": 1 1 1 1 1 1 1 1 1 1 ...
$ f.Detector: Factor w/ 6 levels "1","2","3","4",..: 1 1 1 1 1 2 2 2 2
2 ...
$ f.Height : Factor w/ 2 levels "1","2": 1 1 1 1 1 2 2 2 2 2 ...
I then coded for the nested variables:
data$detector <- with(data, factor(f.Site:f.Detector))
data$night <- with(data, factor(f.Site:f.Night))
trans.log <- log(data$Calls+1)
model <- glmer(round(trans.log,digits=0)~ f.Height + (1|night) +
(1|detector) +
(1|f.Site) , data = data, family=poisson)
I am uncertain on a couple things. Are my nested variables correct? Can
I correct for overdispersion with a transformation?
I was also wondering if there is a reference explaining why there is no
residual variance term for the Poisson distribution. I saw the
explanation on a forum, but was hoping there was something I could cite.
Any help or advice would be appreciated.
Thank you!
Amanda
--
Amanda Adams, MSc
PhD Candidate
Department of Biology
Western University
London, ON
Canada
N6A 5B7
Work (519) 661-2111 Ext: 81349
More information about the R-sig-mixed-models
mailing list