diff --git a/R/check_heteroscedasticity.R b/R/check_heteroscedasticity.R index f3e0368c2..526f2f184 100644 --- a/R/check_heteroscedasticity.R +++ b/R/check_heteroscedasticity.R @@ -41,8 +41,14 @@ check_heteroskedasticity <- check_heteroscedasticity #' @export check_heteroscedasticity.default <- function(x, ...) { # only for linear models - if (!insight::model_info(x)$is_linear) { - stop("This Breusch-Pagan Test currently only works Gaussian models.") + info <- insight::model_info(x) + if (!info$is_linear) { + msg <- "This Breusch-Pagan Test currently only works Gaussian models." + if (info$is_count) { + paste0(msg, " You may check your model for overdispersion or zero-inflation instead (see 'check_overdispersion()' and 'check_zeroinflation()').") + } + message(msg) + return(NULL) } r <- .pearson_residuals(x) diff --git a/R/check_normality.R b/R/check_normality.R index c42204e25..acd2806b1 100644 --- a/R/check_normality.R +++ b/R/check_normality.R @@ -47,8 +47,15 @@ check_normality <- function(x, ...) { } +#' @importFrom insight model_info #' @export check_normality.default <- function(x, ...) { + # valid model? + if (!insight::model_info(x)$is_linear) { + message("Checking normality of residuals is only useful an appropriate assumption for linear models.") + return(NULL) + } + # check for normality of residuals p.val <- .check_normality(stats::rstandard(x), x) @@ -73,6 +80,12 @@ check_normality.merMod <- function(x, effects = c("fixed", "random"), ...) { effects <- match.arg(effects) info <- insight::model_info(x) + # valid model? + if (!info$is_linear) { + message("Checking normality of residuals is only useful an appropriate assumption for linear models.") + return(NULL) + } + if (effects == "random") { if (!requireNamespace("lme4", quietly = TRUE)) { stop("Package 'lme4' required for this function to work. Please install it.", call. = FALSE)