Skip to content
Prev 19283 / 20628 Next

glmmTMB predicted values and AIC, vs glmer

What allFit indicates to me is that all of the different optimizers 
reach very similar log-likelihoods (max difference of 1-4), and if I 
recall correctly all of the fixed effects are also very similar, so I 
would feel free to disregard the convergence warning as a false positive.

   The AIC values are still a lot more different than I would like, and 
digging into the gory details (available on request) it seems that they 
are actually giving different likelihood calculations -- e.g. for the 
parameters reached by glmer, glmmTMB returns a deviance of 607.037 while 
glmer returns 609.3362.  I suspect something deep in the guts of e.g. 
the way the Laplace approximation is computed (not technically a bug in 
either code, but some kind of numerical instability).

   This is good news if what you're interested in is making sure you get 
the correct parameter values.  It's bad news if you're interested in 
mixing and matching glmmTMB and lme4 fits in a model comparison.

   I'm not horribly surprised that things are a bit numerically unstable 
- 12 parameters for 95 observations, and the extremely rapid tail 
behaviour of cloglog often makes things worse.

   I do intend to track down where the infinite prediction is coming 
from too, but haven't gotten there yet.

I'm going to include some of my code in case it's useful, but it's 
poorly commented, messy *and may be in the wrong order* - I was bouncing 
around developing it interactively.

====
Obsglmer1.cll <- glmer(form1, nAGQ=1,
                       family=binomial(link="cloglog"), data=ffly)
aa <- allFit(Obsglmer1.cll)
summary(aa)$fixef
ll <- -summary(aa)$llik
ll-min(ll)
dotwhisker::dwplot(modList[-2])

library(dotwhisker)
modList <- list(glmmTMB=ObsTMB.cll, nAGQ0=Obsglmer.cll,
                 nAGQ1=Obsglmer1.cll)
f1 <- ObsTMB.cll$obj$fn
## TMB params, TMB format
p1 <- with(environment(f1),last.par.best[-random])
## TMB params, glmer format
p1B <- c(exp(p1[names(p1)=="theta"]), p1[names(p1)=="beta"])

f3 <- getME(Obsglmer1.cll,"devfun")
## glmer params, glmer format
p3 <- unlist(getME(Obsglmer1.cll,c("theta","beta")))
## glmer params, TMB format
p3B <- c(p3[-(1:2)],log(p3[1:2]))
f3(p1B) ## 609.3559

f3(p3)  ## 609.3362
2*f1(p3B) ## 608.037

2*f1(p1) ## 608.0166

Obsglmer2.cll <- update(Obsglmer1.cll,
                         start=list(theta=p1B[1:2],
                                    fixef=p1B[-(1:2)]))

dwplot(modList)
library(bbmle)
AICtab(modList, logLik=TRUE)
modList2 <- c(modList, list(nAGQ1_newstart=Obsglmer2.cll))
AICtab(modList2, logLik=TRUE)
On 5/21/21 6:24 PM, John Maindonald wrote: