There are occasions where I would like to fit log-linear models where the independence assumption between observations is violated. It is the normal case that I have multiple observations from each subject. Is there a mixed-effects extension to log-linear models like there are for linear and generalized linear models?
I'm interested in the existence of such a thing in principle, but also its concrete existence in an R library.
Best Answer
Log-linear or Poisson model are part of generalized linear models. Look at the lme4 package which allows for mixed-effects modeling, with
family=poisson()
.Here is an example of use:
The scale parameter (useful to check for possible overdispersion) is available through the following slot:
(The equivalent for usual GLM would be
summary(glm(...))$dispersion
).More information about mixed-effects modeling as implemented in
lme4
can be found on R-forge, in the Mixed-effects models project, or the GLMM FAQ, as suggested by @fabians.The gamm4 package may also be of interest as it allows to fit generalized additive mixed models.