Skip to content

Commit

Permalink
check_model() does not produce Uniformity of Residuals plot for binom…
Browse files Browse the repository at this point in the history
…ial models (#363)

Fixes #362
  • Loading branch information
strengejacke authored Sep 5, 2024
1 parent b294a18 commit 57ac150
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
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 @@ -45,6 +45,7 @@ plot.see_performance_simres <- function(x,
...) {
# 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 @@ plot.see_performance_simres <- function(x,
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 @@ plot.see_performance_simres <- function(x,
)

# 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

0 comments on commit 57ac150

Please sign in to comment.