Skip to content

Commit

Permalink
also fix for linear
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Apr 3, 2024
1 parent d54d85a commit fc5d7cd
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions R/check_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,11 @@ check_model.default <- function(x,
residual_type <- ifelse(minfo$is_linear && !minfo$is_gam, "normal", "simulated")
}

# catch models/families not supported by DHARMa
if (minfo$family == "quasipoisson") {
# catch models/families not supported by DHARMa - we need to add more
# exceptions here as they appear, but for now, `check_model()` also
# automatically falls back to normal Q-Q plot for all models not supported
# by DHARMa
if (minfo$family %in% c("quasipoisson", "quasibinomial")) {
residual_type <- "normal"
}

Expand Down Expand Up @@ -463,6 +466,13 @@ check_model.DHARMa <- check_model.performance_simres
simulated = .safe(simulate_residuals(model, ...)),
.diag_qq(model, model_info = model_info, verbose = verbose)
)
# sanity check - model supported by DHARMa?
if (is.null(dat$QQ) && residual_type == "simulated") {
if (verbose) {
insight::format_alert("Cannot simulate residuals for this model. Using normal Q-Q plot instead.")
}
dat$QQ <- .diag_qq(model, model_info = model_info, verbose = verbose)
}
}

# Random Effects Q-Q plot (normality of BLUPs) --------------
Expand Down Expand Up @@ -524,6 +534,7 @@ check_model.DHARMa <- check_model.performance_simres
simulated = .safe(simulate_residuals(model, ...)),
.diag_qq(model, model_info = model_info, verbose = verbose)
)
# sanity check - model supported by DHARMa?
if (is.null(dat$QQ) && residual_type == "simulated") {
if (verbose) {
insight::format_alert("Cannot simulate residuals for this model. Using normal Q-Q plot instead.")
Expand Down

0 comments on commit fc5d7cd

Please sign in to comment.