Skip to content

Commit 49b5cd4

Browse files
authored
check_model() linearity & variance for categorical predictors (#883)
1 parent 64bb99f commit 49b5cd4

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Type: Package
22
Package: performance
33
Title: Assessment of Regression Models Performance
4-
Version: 0.15.3.4
4+
Version: 0.15.3.5
55
Authors@R:
66
c(person(given = "Daniel",
77
family = "Lüdecke",

R/check_model.R

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@
4747
#' time-consuming. By default, `show_dots = NULL`. In this case `check_model()`
4848
#' tries to guess whether performance will be poor due to a very large model
4949
#' and thus automatically shows or hides dots.
50+
#' @param show_ci Logical, if `TRUE`, confidence intervals in plots are shown.
51+
#' For models with only categorical predictors, confidence intervals are not shown
52+
#' by default, because in this case, these are usually on very large scales.
5053
#' @param maximum_dots Limits the number of data points for models with many
5154
#' observations, to reduce the time for rendering the plot. Defaults to a
5255
#' maximum of 2000 data points to render
@@ -206,6 +209,7 @@ check_model.default <- function(
206209
type = "density",
207210
residual_type = NULL,
208211
show_dots = NULL,
212+
show_ci = NULL,
209213
maximum_dots = 2000,
210214
size_dot = 2,
211215
size_line = 0.8,
@@ -317,6 +321,16 @@ check_model.default <- function(
317321
)
318322
}
319323

324+
# if we have only categorical predictors, we don't show CI by default
325+
parameter_types <- .safe(parameters::parameters_type(x))
326+
if (
327+
!is.null(parameter_types) && all(parameter_types$Type %in% c("intercept", "factor"))
328+
) {
329+
show_ci = FALSE
330+
} else {
331+
show_ci = TRUE
332+
}
333+
320334
attr(assumptions_data, "panel") <- panel
321335
attr(assumptions_data, "dot_size") <- size_dot
322336
attr(assumptions_data, "line_size") <- size_line
@@ -327,6 +341,7 @@ check_model.default <- function(
327341
attr(assumptions_data, "alpha") <- alpha
328342
attr(assumptions_data, "dot_alpha") <- alpha_dot
329343
attr(assumptions_data, "show_dots") <- isTRUE(show_dots)
344+
attr(assumptions_data, "show_ci") <- isTRUE(show_ci)
330345
attr(assumptions_data, "detrend") <- detrend
331346
attr(assumptions_data, "colors") <- colors
332347
attr(assumptions_data, "theme") <- theme
@@ -370,6 +385,7 @@ check_model.stanreg <- function(
370385
type = "density",
371386
residual_type = NULL,
372387
show_dots = NULL,
388+
show_ci = NULL,
373389
maximum_dots = 2000,
374390
size_dot = 2,
375391
size_line = 0.8,
@@ -397,6 +413,7 @@ check_model.stanreg <- function(
397413
size_axis_title = size_axis_title,
398414
detrend = detrend,
399415
show_dots = show_dots,
416+
show_ci = show_ci,
400417
bandwidth = bandwidth,
401418
type = type,
402419
residual_type = residual_type,
@@ -421,6 +438,7 @@ check_model.model_fit <- function(
421438
type = "density",
422439
residual_type = NULL,
423440
show_dots = NULL,
441+
show_ci = NULL,
424442
maximum_dots = 2000,
425443
size_dot = 2,
426444
size_line = 0.8,
@@ -448,6 +466,7 @@ check_model.model_fit <- function(
448466
base_size = base_size,
449467
detrend = detrend,
450468
show_dots = show_dots,
469+
show_ci = show_ci,
451470
maximum_dots = maximum_dots,
452471
bandwidth = bandwidth,
453472
type = type,
@@ -468,6 +487,7 @@ check_model.performance_simres <- function(
468487
type = "density",
469488
residual_type = NULL,
470489
show_dots = NULL,
490+
show_ci = NULL,
471491
maximum_dots = 2000,
472492
size_dot = 2,
473493
size_line = 0.8,
@@ -495,6 +515,7 @@ check_model.performance_simres <- function(
495515
base_size = base_size,
496516
detrend = detrend,
497517
show_dots = show_dots,
518+
show_ci = show_ci,
498519
maximum_dots = maximum_dots,
499520
bandwidth = bandwidth,
500521
type = type,

man/check_model.Rd

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)