# [R-sig-ME] Question about GLMM and overdispersed data

Chad Newbolt newboch at auburn.edu
Fri Jun 24 21:52:01 CEST 2016

```All,

I would first like to say that I'm a relative novice with R so please take that into consideration with your responses.  Basically, give me the totally dumbed down version of answers when you can.

I have a biological data set with count data that I'm currently analyzing.  Namely, I'm interested in looking at the effects of animal age, bodysize, and antler size on annual male reproductive success (i.e. number of fawns produced).  I would also like to see how the relationships are influenced by changes in population demographics.  I have been using a GLMM to evaluate the following global model:

repro = glmer(Fawn~Age+I(Age^2)+BodySize+SSCM+AvgAge+Age*AvgAge+I(Age^2)*AvgAge+BodySize*AvgAge+SSCM*AvgAge+(1|Sire),data=datum,family=poisson)

where:

Age, BodySize, SSCM are measured characteristics

Fawn = number of fawns produced in a given year

AvgAge = Population demographic factor

(1|Sire) = Random effect for each sampled male ID

I first used the following to evaluate potential overdispersion of my data from the global model:

overdisp_fun <- function(model) {
## number of variance parameters in
##   an n-by-n variance-covariance matrix
vpars <- function(m) {
nrow(m)*(nrow(m)+1)/2
}
model.df <- sum(sapply(VarCorr(model),vpars))+length(fixef(model))
rdf <- nrow(model.frame(model))-model.df
rp <- residuals(model,type="pearson")
Pearson.chisq <- sum(rp^2)
prat <- Pearson.chisq/rdf
pval <- pchisq(Pearson.chisq, df=rdf, lower.tail=FALSE)
c(chisq=Pearson.chisq,ratio=prat,rdf=rdf,p=pval)
}

With the following result

repro = glmer(Fawn~Age+I(Age^2)+BodySize+SSCM+AvgAge+Age*AvgAge+I(Age^2)*AvgAge+BodySize*AvgAge+SSCM*AvgAge+(1|Sire),data=datum,family=poisson)
overdisp_fun(repro)
chisq                             ratio                          rdf                              p
1.698574e+02      1.681756e+00       1.010000e+02          2.169243e-05

Since the ratio of Pearson-statistic to rdf is 1.68 I assume that I need to take this overdispersion into account

My first inclination was to use quasipoisson distribution to account for overdispersion; however, I see that in no longer available in lme4.  I used glmmPQL in the MASS package with quasipoisson but do not receive AICc information.  I had planned on using AICc to evaluate competitive models.  My specific question is: 1) is there a way to generate the necessary information (AICc or something like) to compare competitive models from overdispersed data in a current R environment? I have read https://cran.r-project.org/web/packages/bbmle/vignettes/quasi.pdf but I'm having a difficult time understanding exactly how to implement from a technical perspective.  I'm on the path of trying to use a negative binomial (I'm not locked into this method so please provide insight if appropriate) with package glmmADMB: however, I have been unable to get this package to load successfully.  I've followed the instructions to the best of my understanding and abilities but cannot figure out where I'm going wrong.  Any advice is much appreciated as I'm totally stumped right now on many fronts.  I'm running windows 7 on 64-bit machine.  Here is what I have attempted with output:

+             getOption("repos")),
+     type="source")
Installing package into ‘C:/Users/newboch/Documents/R/win-library/3.3’
(as ‘lib’ is unspecified)
Content type 'application/x-gzip' length 9391177 bytes (9.0 MB)

* installing *source* package 'glmmADMB' ...
** R
** data
*** moving datasets to lazyload DB
** inst
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) :
there is no package called 'stringi'

Warning messages:
2: In install.packages("glmmADMB", repos = c("http://glmmadmb.r-forge.r-project.org/repos",  :
installation of package ‘glmmADMB’ had non-zero exit status
Error in loadNamespace(name) : there is no package called ‘glmmADMB’
Error in loadNamespace(name) : there is no package called ‘glmmADMB’
Installing package into ‘C:/Users/newboch/Documents/R/win-library/3.3’
(as ‘lib’ is unspecified)
Warning message:
package ‘glmmADMB’ is not available (for R version 3.3.1)

Thanks,

[[alternative HTML version deleted]]

```