##anuran larvae example from Mazerolle (2006)
data(min.trap)
##assign "UPLAND" as the reference level as in Mazerolle (2006)
min.trap$Type <- relevel(min.trap$Type, ref = "UPLAND")
##run model
m1 <- glm(Num_anura ~ Type + log.Perimeter + Num_ranatra,
family = poisson, offset = log(Effort),
data = min.trap)
##null model
m0 <- glm(Num_anura ~ 1,
family = poisson, offset = log(Effort),
data = min.trap)
##check c-hat for global model
c_hat(m1) #uses Pearson's chi-square/df
##likelihood ratio test corrected for overdispersion
anovaOD(mod.simple = m0, mod.complex = m1, c.hat = c_hat(m1))
##compare without overdispersion correction
anovaOD(mod.simple = m0, mod.complex = m1)
##example with occupancy model
if (FALSE) {
##load unmarked package
if(require(unmarked)){
data(bullfrog)
##detection data
detections <- bullfrog[, 3:9]
##assemble in unmarkedFrameOccu
bfrog <- unmarkedFrameOccu(y = detections)
##run model
fm <- occu(~ 1 ~ Reed.presence, data = bfrog)
##null model
fm0 <- occu(~ 1 ~ 1, data = bfrog)
##check GOF
##GOF <- mb.gof.test(fm, nsim = 1000)
##estimate of c-hat: 1.89
##display results after overdispersion adjustment
anovaOD(fm0, fm, c.hat = 1.89)
detach(package:unmarked)
}
}
Run the code above in your browser using DataLab