Skip to content

Commit

Permalink
set default for type
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Jun 2, 2023
1 parent c315c97 commit 010601c
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 13 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: performance
Title: Assessment of Regression Models Performance
Version: 0.10.3.6
Version: 0.10.3.7
Authors@R:
c(person(given = "Daniel",
family = "Lüdecke",
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

* `check_predictions()` gains a `type` argument, which is passed down to the
`plot()` method to change plot-type (density or discrete dots/intervals).
By default, `type` is set to `"default"` for models without discrete outcomes,
and else `type = "discrete_interval"`.

* `performance_accuracy()` now includes confidence intervals, and reports those
by default (the standard error is no longer reported, but still included).
Expand Down
6 changes: 6 additions & 0 deletions R/check_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,12 @@ check_model.default <- function(x,
insight::format_error(paste0("`check_model()` not implemented for models of class `", class(x)[1], "` yet."))
}

# try to find sensible default for "type" argument
suggest_dots <- (minfo$is_bernoulli || minfo$is_count || minfo$is_ordinal || minfo$is_categorical || minfo$is_multinomial)
if (missing(type) && suggest_dots) {
type <- "discrete_interval"
}

# set default for show_dots, based on "model size"
if (is.null(show_dots)) {
n <- .safe(insight::n_obs(x))
Expand Down
14 changes: 10 additions & 4 deletions R/check_predictions.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
#' default used here is `"nrd"` (which seems to give more plausible results
#' for non-Gaussian models). When problems with plotting occur, try to change
#' to a different value.
#' @param type Plot type for the posterior predictive checks plot. Can be `"density"`
#' (default), `"discrete_dots"`, `"discrete_interval"` or `"discrete_both"` (the
#' `discrete_*` options are appropriate for models with discrete - binary, integer
#' or ordinal etc. - outcomes).
#' @param type Plot type for the posterior predictive checks plot. Can be `"density"`,
#' `"discrete_dots"`, `"discrete_interval"` or `"discrete_both"` (the `discrete_*`
#' options are appropriate for models with discrete - binary, integer or ordinal
#' etc. - outcomes).
#' @param verbose Toggle warnings.
#' @param ... Passed down to `simulate()`.
#'
Expand Down Expand Up @@ -108,6 +108,12 @@ check_predictions.default <- function(object,
# retrieve model information
minfo <- insight::model_info(object, verbose = FALSE)

# try to find sensible default for "type" argument
suggest_dots <- (minfo$is_bernoulli || minfo$is_count || minfo$is_ordinal || minfo$is_categorical || minfo$is_multinomial)
if (missing(type) && suggest_dots) {
type <- "discrete_interval"
}

# args
type <- match.arg(type, choices = c("density", "discrete_dots", "discrete_interval", "discrete_both"))

Expand Down
8 changes: 4 additions & 4 deletions man/check_model.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions man/check_predictions.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 010601c

Please sign in to comment.