From 25f2a1656a1889122bfb1b989502c566bb31be71 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 16 Mar 2024 12:05:59 +0100 Subject: [PATCH] fix --- R/check_overdispersion.R | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/R/check_overdispersion.R b/R/check_overdispersion.R index e09265e61..63fb2c633 100644 --- a/R/check_overdispersion.R +++ b/R/check_overdispersion.R @@ -171,6 +171,18 @@ check_overdispersion.glm <- function(x, verbose = TRUE, ...) { return(check_overdispersion(simulate_residuals(x, ...), ...)) } + # check if we have poisson - need this for models not supported by DHARMa + if (!info$is_count && !info$is_binomial) { + insight::format_error( + "Overdispersion checks can only be used for models from Poisson families or binomial families with trials > 1." + ) + } + + # check for Bernoulli + if (info$is_bernoulli) { + insight::format_error("Overdispersion checks cannot be used for Bernoulli models.") + } + yhat <- stats::fitted(x) n <- stats::nobs(x)