I am having difficulty figuring out how to calculate a dispersion parameter to calculate QAICc for a GLMM with a binomial fit.
I have tested for overdispersion using this code:
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 this code, I have found some of my candidate models show signs of overdispersion, while some do not. I have tried QAICc in MuMin, but I am having difficulty figuring out how to calculate c-hat properly. Could anyone point me in the right direction?
Also, using just AICc, I found that I have two candidate models, one that shows signs of overdispersion and one that does not. Therefore, how does one average candidate models if one should be assessed by QAICc and the other AICc?