From ad60db15550c406e533ad037107c81d81a66590d Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 16 Mar 2024 11:33:48 +0100 Subject: [PATCH] fix --- R/check_overdispersion.R | 5 ++++- R/check_zeroinflation.R | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/R/check_overdispersion.R b/R/check_overdispersion.R index 9c3b33e99..e09265e61 100644 --- a/R/check_overdispersion.R +++ b/R/check_overdispersion.R @@ -164,7 +164,10 @@ check_overdispersion.glm <- function(x, verbose = TRUE, ...) { # for certain distributions, simulated residuals are more accurate use_simulated <- info$is_bernoulli || info$is_binomial || (!info$is_count && !info$is_binomial) || info$is_negbin - if (use_simulated) { + # model classes not supported in DHARMa + not_supported <- c("fixest", "glmx") + + if (use_simulated && !inherits(x, not_supported)) { return(check_overdispersion(simulate_residuals(x, ...), ...)) } diff --git a/R/check_zeroinflation.R b/R/check_zeroinflation.R index 0d7ce94a4..be76f748b 100644 --- a/R/check_zeroinflation.R +++ b/R/check_zeroinflation.R @@ -68,9 +68,12 @@ check_zeroinflation.default <- function(x, tolerance = 0.05, ...) { return(NULL) } + # model classes not supported in DHARMa + not_supported <- c("fixest", "glmx") + # for models with zero-inflation component or negative binomial families, # we use simulated_residuals() - if (model_info$is_zero_inflated || model_info$is_negbin) { + if (!inherits(x, not_supported) && (model_info$is_zero_inflated || model_info$is_negbin)) { if (missing(tolerance)) { tolerance <- 0.1 }