Hi Thierry,
Thank you for the reply. Would you be able to explain what the 0 does (I
have read the lme4 documentation, but it's not very clear to me), and why
you would use the (0+ PrePeriod|...) for the site x year interaction term
and not the other two random effects that should also vary by period? Would
that coding be more appropriate for the year.factor and Site random effects
too? Also, why does it work differently if I have a single factor column of
0s and 1s named 'period' and simply use (0+ period | Site:year.factor)?
Thank you again!
Tiffany
On Tue, Apr 5, 2016 at 3:17 AM, Thierry Onkelinx <thierry.onkelinx at inbo.be
Dear Tiffany,
You could try to make dummy variables for each level of period.
dat$PrePeriod <- as.integer(dat$period == "Pre")
dat$PostPeriod <- as.integer(dat$period == "Post")
mod.pois <- glmer( count ~ 1 + period + year + year*period +
(period|year.factor) + (period|Site) + (0 + PrePeriod|Site:year.factor)
+ (0 + PostPeriod|Site:year.factor),
data=dat, family=poisson)
Best regards,
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium
To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to say
what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey
2016-04-02 21:23 GMT+02:00 Tiffany Vidal <tiffany.vidal at gmail.com>:
I am interested in estimating a mixed model with a random effect for
year,
site, and an observation-level effect to account for overdispersion,
assuming Poisson error structure, using the lme4 package in R.
Additionally, I have an indicator variable 'period' to adjust the
parameter
estimated by pre- and post- time periods. I am running into problems
trying
to specify the observation level effect by time period. I could model
this
using glmer.nb and avoid the observation-level effect, but I would like
the
flexibility to allow overdispersion to vary by time period as well. If
there was a way to allow the negative binomial scaling parameter to vary
by
time period, I would probably use glmer.nb.
My model as I'm trying to specify with glmer:
mod.pois <- glmer( count ~ 1 + period + year + year*period +
(period|year.factor) + (period|Site) ,
data=dat, family=poisson)
The above runs and I think does what I want, but doesn't include the
observation-level effect.
I have tried:
mod.pois <- glmer( count ~ 1 + period + year + year*period +
(period|year.factor) + (period|Site) + (period|Site:year.factor),
data=dat, family=poisson)
but the error indicates identifiability issues. I have one observation at
each site x year combination.
Is there a way to achieve this using this package? Thank you in advance
for
any thoughts.
[[alternative HTML version deleted]]