Skip to content

Commit

Permalink
Merge branch 'main' into rc_0_10_7
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke authored Oct 26, 2023
2 parents 0aff3d5 + d315848 commit 57c2f33
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions R/check_model_diagnostics.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@

# prepare data for random effects QQ plot ----------------------------------

.diag_reqq <- function(model, level = 0.95, model_info, verbose = TRUE) {
.diag_reqq <- function(model, level = 0.95, model_info = NULL, verbose = TRUE) {
# check if we have mixed model
if (!model_info$is_mixed) {
if (is.null(model_info) || !model_info$is_mixed) {
return(NULL)
}

Expand Down Expand Up @@ -156,7 +156,10 @@
r <- try(as.numeric(stats::residuals(model)), silent = TRUE)

if (inherits(r, "try-error")) {
insight::format_alert(sprintf("Non-normality of residuals could not be computed. Cannot extract residuals from objects of class '%s'.", class(model)[1]))
insight::format_alert(sprintf(
"Non-normality of residuals could not be computed. Cannot extract residuals from objects of class '%s'.",
class(model)[1]
))
return(NULL)
}

Expand Down Expand Up @@ -223,7 +226,10 @@

if (is.null(ncv)) {
if (verbose) {
insight::format_alert(sprintf("Non-constant error variance could not be computed. Cannot extract residuals from objects of class '%s'.", class(model)[1]))
insight::format_alert(sprintf(
"Non-constant error variance could not be computed. Cannot extract residuals from objects of class '%s'.",
class(model)[1]
))
}
return(NULL)
}
Expand Down Expand Up @@ -264,7 +270,10 @@

if (is.null(r)) {
if (verbose) {
insight::format_alert(sprintf("Homogeneity of variance could not be computed. Cannot extract residual variance from objects of class '%s'.", class(model)[1]))
insight::format_alert(sprintf(
"Homogeneity of variance could not be computed. Cannot extract residual variance from objects of class '%s'.",
class(model)[1]
))
}
return(NULL)
}
Expand Down Expand Up @@ -327,7 +336,7 @@
}
d$Prob <- stats::predict(model, type = ptype)
d$Disp <- insight::get_sigma(model)
d$V <- d$Predicted * (1 + d$Predicted / d$Disp) * (1 - d$Prob) * (1 + d$Predicted * (1 + d$Predicted / d$Disp) * d$Prob)
d$V <- d$Predicted * (1 + d$Predicted / d$Disp) * (1 - d$Prob) * (1 + d$Predicted * (1 + d$Predicted / d$Disp) * d$Prob) # nolint
d$StdRes <- insight::get_residuals(model, type = "pearson")
}

Expand All @@ -343,7 +352,7 @@
}
d$Prob <- stats::predict(model, type = ptype)
d$Disp <- stats::predict(model, type = "disp")
d$V <- d$Predicted * (1 + d$Predicted / d$Disp) * (1 - d$Prob) * (1 + d$Predicted * (1 + d$Predicted / d$Disp) * d$Prob)
d$V <- d$Predicted * (1 + d$Predicted / d$Disp) * (1 - d$Prob) * (1 + d$Predicted * (1 + d$Predicted / d$Disp) * d$Prob) # nolint
d$StdRes <- insight::get_residuals(model, type = "pearson")
}

Expand Down

0 comments on commit 57c2f33

Please sign in to comment.