DHARMa icon indicating copy to clipboard operation
DHARMa copied to clipboard

simulateResiduals fails on glmmTMB model with rank_check = "adjust"

Open gordy2x opened this issue 1 year ago • 5 comments

There is now a (optional) argument in glmmTMB that drops terms that make the design matrix rank-deficient (see https://github.com/glmmTMB/glmmTMB/issues/522#issuecomment-1472885734), this is what lme4 does by default. I can run simulateResiduals on an lme4 object but not on a glmmTMB object with rank_check = "adjust".

library(glmmTMB)
library(lme4)
library(DHARMa)
set.seed(101)
dd <- data.frame(z = rnorm(100), 
                 x1 = 1:100, x2 = 2:101,
                 re = rep(1:20, each = 5))

mod_lme4 <- lmer(z ~ x1 + x2 + (1|re), data = dd)
simulateResiduals(mod_lme4, n = 5)


mod_TMB <- glmmTMB(z ~ x1 + x2 + (1|re), data = dd, 
                   control = glmmTMBControl(rank_check = "adjust"))
simulateResiduals(mod_TMB, n = 5)

gordy2x avatar Mar 17 '23 02:03 gordy2x

The issue is not in DHARMa, but in the predict function of glmmTMB, see my comment in the other issue. I think @florianhartig can close this as the problem is not in this repo.

reiniervlinschoten avatar Mar 28 '23 12:03 reiniervlinschoten

Thanks Reinier ... I'll leave it open for now to check later if this has been fixed in glmMTMB, but will likely not address this in DHARMa.

florianhartig avatar Mar 28 '23 13:03 florianhartig

Resolved now with remotes::install_github("glmmTMB/glmmTMB/glmmTMB@rankdef_NA")

bbolker avatar May 06 '23 21:05 bbolker

Hi Ben, many thanks! I'll keep this open until the problem is resolved in CRAN!

florianhartig avatar May 08 '23 07:05 florianhartig

Awesome, thank you very much for fixing this!

reiniervlinschoten avatar May 08 '23 08:05 reiniervlinschoten