3

I've run a set of 23 models using glmmTMB. (I've set up my models as a list, example code seen below)

cand.models<-list()
cand.models[[1]]<-glmmTMB(count~depth + slope + SST + (1|individual), family=list(family="truncated_nbinom1", link="log"), data=df)
cand.models[[2]]<-glmmTMB(count~depth + slope + (1|individual), family=list(family="truncated_nbinom1", link="log"), data=df)

I would like to create a summary table that provides the deviance for each model contained within cand.models. I tried using broom::glance(), which is supposed to create a "one row" summary that includes deviance, among other things like AIC and BIC.

summ.table<-do.call(rbind, lapply(cand.models, broom::glance))

However, the output does not include the model deviance! (it only includes sigma, logLik, AIC, BIC, and df.residual). Does anyone know why it is not providing the deviance (an issue specific to glmmTMB, perhaps?). Or, does anyone have an alternate solution for extracting the deviance?

Splash1199
  • 379
  • 3
  • 14
  • When I generated one of the example models in the help for `glmmTMB` and tried `glance` on it I received the following error: `glance doesn't know how to deal with data of class glmmTMB`. I tried this with both the latest CRAN release and the development version of `broom`, so I'm wondering how you were even able to get `glance` to work on a `glmmTMB` model. When I run `glance` on model objects returned by `lm`, `glm`, and `lmer` (from the `lme4` package), `glance` *does* include the deviance in the output. – eipi10 Oct 22 '17 at 22:43
  • Interesting. I downloaded devtools::install_github("bbolker/broom") so that I could use `dotwhisker::dwplot()` with `glmmTMB`. Maybe that changed how `broom` interacts with `glmmTMB` as well – Splash1199 Oct 22 '17 at 22:55

1 Answers1

3

Following up on the comments: The "master" version of broom doesn't include a glance method for glmmTMB models, meaning glance doesn't work for glmmTMB models.

The version of broom you're using is a forked version by Ben Bolker (bbolker) to which he added a new glance method that works for glmmTMB model objects. However, this glance method doesn't include the deviance in the output. Nevertheless, since deviance = -2*log(likelihood), you can do the following:

summ.table$deviance = -2 * summ.table$logLik
eipi10
  • 91,525
  • 24
  • 209
  • 285
  • 1
    note: (1) there is now a [broom.mixed package](https://github.com/bbolker/broom.mixed) under development that does this. (2) you need to be careful about the definition of the deviance, i.e. is it -2*log(L) or -2*log(L/L_0) ? – Ben Bolker Mar 25 '18 at 23:45
  • I have installed bbolker version and it says: Error: No glance method for objects of class summary.glmmTMB – skan Apr 04 '19 at 10:52