get.models() fails to work when one or more model fails to converge glmmTMB

34 views Asked by At

I've been trying to carry out model selection on a glmmtmb() object and subsetting the "best" models.

  • dredge() works as expected (but throws some convergence issues).

  • get.models() runs without errors or warnings but does not subset the suite of models produced by dredge(), rather returns all of the fitted models

After some digging i found this only occurs when there is one or more convergence issue in the models fit by dredge() (see minimum viable below).

Can anyone suggest either:

  1. a fix/work around to this issue

or

  1. whether this is actually a bug or some way to force users to ensure their full suite of models fits (I cant think of a reason for this but possibly just my ignorance!)

Many thanks!

Chris

Data available here

library(MuMIn)
library(glmmTMB)

############################################
### full model which fails to subset after dredge
full_mod_min <- glmmTMB(number_of_species ~    
                      scale(Distance) + 
                      scale(Bucket) + 
                      played_cricket + 
                      (1|Group_name),
                    data=mod_data,
                    family="nbinom2",
                    control=glmmTMBControl(optimizer=optim, 
                                           optArgs=list(method="BFGS")),
                    na.action = na.fail)

##then dredge across the full model. Convergence warnings for some models
dredged_models_min <- dredge(full_mod_min)

## 8 models fit by dredge
nrow(dredged_models_min)

## try subsetting, should return 3 but returns 8
length(get.models(dredged_models_min, subset = delta < 2))

############################################
### full model which can subset after dredge

## only difference between the two models is we replace 
## `played_cricket` with `sex`

working_mod_min <- glmmTMB(number_of_species ~    
                          scale(Distance) + 
                            scale(Bucket) + 
                            sex +
                          (1|Group_name),
                        data=mod_data,
                        family="nbinom2",
                        control=glmmTMBControl(optimizer=optim, 
                                               optArgs=list(method="BFGS")),
                        na.action = na.fail)

##then dredge across the full model
working_dredge <- dredge(working_mod_min)

## 8 models fit by dregde, 3 within delta 2 AIC
nrow(working_dredge)

## try subsetting - works, returns 3
length(get.models(working_dredge, subset = delta < 2))

Tried various error structures/types of predictor variable but only consistency is the failure to converge

0

There are 0 answers