Licensed under the Creative Commons attribution-noncommercial license. Please share & remix noncommercially, mentioning its origin.
library(lme4)
library(broom)
library(broom.mixed)
library(dotwhisker)
Most aspects of GLMMs are carried over from LMMs (random effects) and GLMs (families and links).
You do have to decide on an approximation method.
In lme4
, use the nAGQ=
argument; nAGQ=1
(default) corresponds to Laplace approximation
library(lattice)
aspect <- 0.6
xlab <- "z"; ylab <- "density"; type <- c("g","l"); scaled <- FALSE
mm <- readRDS("../data/toenail_lapldiag.rds")
print(xyplot(y ~ zvals|id, data=mm,
type=type, aspect=aspect,
xlab=xlab,ylab=ylab,
as.table=TRUE,
panel=function(x,y,...){
if (!scaled) {
panel.lines(x, dnorm(x), lty=2)
} else {
panel.abline(h=1, lty=2)
}
panel.xyplot(x,y,...)
}))
g1 <- glmer(incidence/size ~ period + (1|herd),
family=binomial,
data=cbpp,
weights=size)
g2 <- update(g1,nAGQ=5)
g3 <- update(g1,nAGQ=10)
g4 <- MASS:::glmmPQL(incidence/size ~ period,
random = ~1|herd,
data=cbpp,
family=binomial,
weights=size)
## iteration 1
## iteration 2
## iteration 3
## iteration 4
dwplot(list(Laplace=g1,AGQ5=g2,AGQ10=g3,glmmPQL=g4))
aods3::gof()
glmmTMB
/brms
(Brooks et al. 2017)DHARMa
)glmmTMB
etc.Brooks, Mollie E., Kasper Kristensen, Koen J. van Benthem, Arni Magnusson, Casper W. Berg, Anders Nielsen, Hans J. Skaug, Martin Maechler, and Benjamin M. Bolker. 2017. “Modeling Zero-Inflated Count Data With glmmTMB.” BioRxiv, May, 132753. doi:10.1101/132753.
Elston, D. A., R. Moss, T. Boulinier, C. Arrowsmith, and X. Lambin. 2001. “Analysis of Aggregation, a Worked Example: Numbers of Ticks on Red Grouse Chicks.” Parasitology 122 (5): 563–69.