Skip to content

Commit

Permalink
check for DHARMa is already implemented, comes later
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Apr 3, 2024
1 parent 380cfcd commit e4409ef
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 20 deletions.
18 changes: 2 additions & 16 deletions R/check_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@ check_model.default <- function(x,
}

# did Q-Q plot work with simulated residuals?
if (verbose && is.null(assumptions_data$QQ) && residual_type == "simulated") {
insight::format_warning(paste0(
if (is.null(assumptions_data$QQ) && residual_type == "simulated") {
insight::format_alert(paste0(
"Cannot simulate residuals for models of class `",
class(x)[1],
"`. Please try `check_model(..., residual_type = \"normal\")` instead."
Expand Down Expand Up @@ -466,13 +466,6 @@ 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 @@ -534,13 +527,6 @@ 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)
}
}

# homogeneity of variance --------------
Expand Down
2 changes: 1 addition & 1 deletion R/check_predictions.R
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ plot.performance_pp_check <- function(x, ...) {
# validation check, for mixed models, where re.form = NULL (default) might fail
if (is.null(out) && insight::is_mixed_model(object) && !isTRUE(is.na(re_formula))) {
if (verbose) {
insight::format_warning(
insight::format_alert(
paste0(
"Failed to compute posterior predictive checks with `re_formula=",
deparse(re_formula),
Expand Down
4 changes: 2 additions & 2 deletions R/cronbachs_alpha.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ cronbachs_alpha.data.frame <- function(x, verbose = TRUE, ...) {
# we need at least two columns for Cronach's Alpha
if (is.null(ncol(.data)) || ncol(.data) < 2) {
if (verbose) {
insight::format_warning("Too few columns in `x` to compute Cronbach's Alpha.")
insight::format_alert("Too few columns in `x` to compute Cronbach's Alpha.")
}
return(NULL)
}
Expand Down Expand Up @@ -68,7 +68,7 @@ cronbachs_alpha.parameters_pca <- function(x, verbose = TRUE, ...) {
pca_data <- attr(x, "data")
if (is.null(pca_data)) {
if (verbose) {
insight::format_warning("Could not find data frame that was used for the PCA.")
insight::format_alert("Could not find data frame that was used for the PCA.")
}
return(NULL)
}
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-check_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,5 @@ test_that("`check_model()` warnings for zero-infl", {
art ~ fem + mar + kid5 + ment | kid5 + phd,
data = bioChemists
)
expect_message(expect_warning(check_model(model, verbose = TRUE), regex = "Cannot simulate"), regex = "Homogeneity")
expect_message(expect_message(check_model(model, verbose = TRUE), regex = "Cannot simulate"), regex = "Homogeneity")
})

0 comments on commit e4409ef

Please sign in to comment.