Discussion:
[R-sig-ME] Fwd: glmer won't allow quasi- distribution mixed models
Luke Duncan
2018-07-09 15:13:27 UTC
Permalink
Dear R folk

I am trying to run a series of models on distance data for three different
species of animals. My data are not zero-inflated (distances were recorded
for locomotion only and so if the animal didn't move, it wasn't recorded)
and are Poisson distributed. However, all of the models that I run are
horrifically over-dispersed and based on what I read online I thought that
maybe I should consider using a quasi-Poisson distribution to attempt to
account for the over-dispersion. All the online posts of others show that
they do so successfully but for some reason, my lme4 package cannot use
quasi-distributions. I have uninstalled and reinstalled R and the packages
and I still get the same problem.

I am

a) at a loss as to how to deal with the over-dispersion I have and
b) baffled by the fact that lme4 everywhere else can cope with
quasi-distributions but mine can't.

Any help would be appreciated!

My code:

library(lme4)
woodlicedata<-read.csv("Woodlice.csv",header=T)
attach(woodlicedata)
names(woodlicedata)
### This set of models examine whether there are differences in distances
travelled.
distmodel<-glmer(Distance~Treatment*Sex+(1|ID)+(1|Path.set/ID),family=poisson(link='log'))
summary(distmodel) ### AIC= 42972.6
Generalized linear mixed model fit by maximum likelihood (Laplace
Approximation) [
glmerMod]
Family: poisson ( log )
Formula: Distance ~ Treatment * Sex + (1 | ID) + (1 | Path.set/ID)

AIC BIC logLik deviance df.resid
42972.6 43007.3 -21479.3 42958.6 1038

Scaled residuals:
Min 1Q Median 3Q Max
-11.853 -4.074 -1.656 2.146 38.035

Random effects:
Groups Name Variance Std.Dev.
ID:Path.set (Intercept) 6.485e-02 0.2546560
ID (Intercept) 6.906e-02 0.2627973
Path.set (Intercept) 1.368e-10 0.0000117
Number of obs: 1045, groups: ID:Path.set, 104; ID, 52; Path.set, 2

Fixed effects:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 4.20814 0.07757 54.248 < 2e-16 ***
TreatmentRestricted 0.10843 0.14359 0.755 0.45015
SexMale -0.08408 0.11545 -0.728 0.46644
TreatmentRestricted:SexMale -0.49300 0.18781 -2.625 0.00866 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Correlation of Fixed Effects:
(Intr) TrtmnR SexMal
TrtmntRstrc -0.540
SexMale -0.672 0.363
TrtmntRs:SM 0.413 -0.765 -0.615
distmodel2<-glmer(Distance~Treatment*Sex+(1|ID)+(1|Path.set/ID),family=quasipoisson(link='log'))
Error in lme4::glFormula(formula = Distance ~ Treatment * Sex + (1 | ID) +
:
"quasi" families cannot be used in glmer

[[alternative HTML version deleted]]
Ben Bolker
2018-07-09 15:58:39 UTC
Permalink
I don't know what examples you're looking at that show successful use
of quasilikelihood with lme4; it's been years since that option was
removed from the package ... (can you point me to those links? I would
be curious to see how old they are ...)

You have a variety of other choices for handling overdispersion (see
the GLMM FAQ. See
http://bbolker.github.io/mixedmodels-misc/glmmFAQ.html#overdispersion ,
which (as of 5 minutes ago) includes a quasi-likelihood hack for use
with glmer models ...

A few other points from your code below:

- most folks now deprecate the use of attach() (even the manual page
?attach says not to, under "Good practice !) - it generally leads to
more confusion than it's worth
- Your overdispersion seems to be extreme (min/max of scaled residuals
from -12 to 38, deviance/resid df = 42958.6/1038 ~ 40); before you
paper over the cracks using an overdispersion model, it would be a good
to plot your data and model diagnostics and look for outliers and/or
severe violations of the model fit ...
- it seems weird for movement distances to be count variables (suitable
for modeling via Poisson/NB). I would expect them to be continuous and
positive, e.g. log-Normal or Gamma. Can you explain how they come to be
counts in this case?
Post by Luke Duncan
Dear R folk
I am trying to run a series of models on distance data for three different
species of animals. My data are not zero-inflated (distances were recorded
for locomotion only and so if the animal didn't move, it wasn't recorded)
and are Poisson distributed. However, all of the models that I run are
horrifically over-dispersed and based on what I read online I thought that
maybe I should consider using a quasi-Poisson distribution to attempt to
account for the over-dispersion. All the online posts of others show that
they do so successfully but for some reason, my lme4 package cannot use
quasi-distributions. I have uninstalled and reinstalled R and the packages
and I still get the same problem.
I am
a) at a loss as to how to deal with the over-dispersion I have and
b) baffled by the fact that lme4 everywhere else can cope with
quasi-distributions but mine can't.
Any help would be appreciated!
library(lme4)
woodlicedata<-read.csv("Woodlice.csv",header=T)
attach(woodlicedata)
names(woodlicedata)
### This set of models examine whether there are differences in distances
travelled.
distmodel<-glmer(Distance~Treatment*Sex+(1|ID)+(1|Path.set/ID),family=poisson(link='log'))
summary(distmodel) ### AIC= 42972.6
Generalized linear mixed model fit by maximum likelihood (Laplace
Approximation) [
glmerMod]
Family: poisson ( log )
Formula: Distance ~ Treatment * Sex + (1 | ID) + (1 | Path.set/ID)
AIC BIC logLik deviance df.resid
42972.6 43007.3 -21479.3 42958.6 1038
Min 1Q Median 3Q Max
-11.853 -4.074 -1.656 2.146 38.035
Groups Name Variance Std.Dev.
ID:Path.set (Intercept) 6.485e-02 0.2546560
ID (Intercept) 6.906e-02 0.2627973
Path.set (Intercept) 1.368e-10 0.0000117
Number of obs: 1045, groups: ID:Path.set, 104; ID, 52; Path.set, 2
Estimate Std. Error z value Pr(>|z|)
(Intercept) 4.20814 0.07757 54.248 < 2e-16 ***
TreatmentRestricted 0.10843 0.14359 0.755 0.45015
SexMale -0.08408 0.11545 -0.728 0.46644
TreatmentRestricted:SexMale -0.49300 0.18781 -2.625 0.00866 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Intr) TrtmnR SexMal
TrtmntRstrc -0.540
SexMale -0.672 0.363
TrtmntRs:SM 0.413 -0.765 -0.615
distmodel2<-glmer(Distance~Treatment*Sex+(1|ID)+(1|Path.set/ID),family=quasipoisson(link='log'))
Error in lme4::glFormula(formula = Distance ~ Treatment * Sex + (1 | ID) +
"quasi" families cannot be used in glmer
[[alternative HTML version deleted]]
_______________________________________________
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
Loading...