Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check_model() does not produce Uniformity of Residuals plot for binomial models #363

Merged
merged 1 commit into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: see
Title: Model Visualisation Toolbox for 'easystats' and 'ggplot2'
Version: 0.8.5.6
Version: 0.8.5.7
Authors@R:
c(person(given = "Daniel",
family = "Lüdecke",
Expand Down Expand Up @@ -120,4 +120,3 @@ Config/testthat/edition: 3
Config/testthat/parallel: true
Config/Needs/website: easystats/easystatstemplate
Config/rcmdcheck/ignore-inconsequential-notes: true
Remotes: easystats/performance
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

- New `plot()` method for `performance::check_dag()`.

## Bug fixes

- Fixed issue in `plot()` for `performance::check_model()` when package *qqplotr*
is not installed.

# see 0.8.5

## Major Changes
Expand Down
16 changes: 13 additions & 3 deletions R/plot.performance_simres.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
#'
#' @return A ggplot2-object.
#'
#' @seealso See also the vignette about [`check_model()`](https://easystats.github.io/performance/articles/check_model.html).

Check warning on line 15 in R/plot.performance_simres.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/plot.performance_simres.R,line=15,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 125 characters.
#'
#' @examplesIf insight::check_if_installed("performance", "0.10.9.7") && require("glmmTMB") && require("qqplotr") && require("DHARMa")

Check warning on line 17 in R/plot.performance_simres.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/plot.performance_simres.R,line=17,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 134 characters.
#' data(Salamanders, package = "glmmTMB")
#' model <- glmmTMB::glmmTMB(
#' count ~ mined + spp + (1 | site),
Expand Down Expand Up @@ -45,6 +45,7 @@
...) {
# need DHARMa to be installed
insight::check_if_installed("DHARMa")
qqplotr_installed <- insight::check_if_installed("qqplotr", quietly = TRUE)

# extract data, if from check_residuals
if (inherits(x, "see_check_residuals")) {
Expand All @@ -56,12 +57,21 @@
res <- stats::residuals(x)
dp <- list(min = 0, max = 1, lower.tail = TRUE, log.p = FALSE)
dp_band <- list(min = 0, max = 1)
dfun <- "unif"
# "distribution" argument has different handling in qqplotr
if (qqplotr_installed) {
dfun <- "unif"
} else {
dfun <- stats::qunif
}
} else if (identical(transform, stats::qnorm)) {
res <- stats::residuals(x, quantileFunction = stats::qnorm)
dp <- list(mean = 0, sd = 1)
dp_band <- list(mean = 0, sd = 1)
dfun <- "norm"
if (qqplotr_installed) {
dfun <- "norm"
} else {
dfun <- stats::qnorm
}
} else if (is.character(transform)) {
insight::format_error("`transform` must be a function, not a string value.")
} else {
Expand All @@ -76,7 +86,7 @@
)

# when we have package qqplotr, we can add confidence bands
if (requireNamespace("qqplotr", quietly = TRUE)) {
if (qqplotr_installed) {
qq_stuff <- list(
qqplotr::stat_qq_band(
distribution = dfun,
Expand Down
Loading