Skip to content

Commit 6529bff

Browse files
authored
Merge branch 'main' into check_reliability
2 parents e5492c2 + 9b7e865 commit 6529bff

32 files changed

+165
-128
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.13.0.2
4+
Version: 0.13.0.3
55
Authors@R:
66
c(person(given = "Daniel",
77
family = "Lüdecke",

R/binned_residuals.R

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,19 @@ binned_residuals <- function(model,
8080
n_bins = NULL,
8181
show_dots = NULL,
8282
ci = 0.95,
83-
ci_type = c("exact", "gaussian", "boot"),
84-
residuals = c("deviance", "pearson", "response"),
83+
ci_type = "exact",
84+
residuals = "deviance",
8585
iterations = 1000,
8686
verbose = TRUE,
8787
...) {
88-
ci_type <- match.arg(ci_type)
89-
residuals <- match.arg(residuals)
88+
ci_type <- insight::validate_argument(
89+
ci_type,
90+
c("exact", "gaussian", "boot")
91+
)
92+
residuals <- insight::validate_argument(
93+
residuals,
94+
c("deviance", "pearson", "response")
95+
)
9096

9197
# for non-bernoulli models, `"exact"` doesn't work
9298
if (isFALSE(insight::model_info(model)$is_bernoulli)) {

R/check_collinearity.R

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -305,55 +305,70 @@ check_collinearity.betamfx <- check_collinearity.logitor
305305
#' @rdname check_collinearity
306306
#' @export
307307
check_collinearity.glmmTMB <- function(x,
308-
component = c("all", "conditional", "count", "zi", "zero_inflated"),
308+
component = "all",
309309
ci = 0.95,
310310
verbose = TRUE,
311311
...) {
312-
component <- match.arg(component)
312+
component <- insight::validate_argument(
313+
component,
314+
c("all", "conditional", "count", "zi", "zero_inflated")
315+
)
313316
.check_collinearity_zi_model(x, component, ci = ci, verbose = verbose)
314317
}
315318

316319

317320
#' @export
318321
check_collinearity.MixMod <- function(x,
319-
component = c("all", "conditional", "count", "zi", "zero_inflated"),
322+
component = "all",
320323
ci = 0.95,
321324
verbose = TRUE,
322325
...) {
323-
component <- match.arg(component)
326+
component <- insight::validate_argument(
327+
component,
328+
c("all", "conditional", "count", "zi", "zero_inflated")
329+
)
324330
.check_collinearity_zi_model(x, component, ci = ci, verbose = verbose)
325331
}
326332

327333

328334
#' @export
329335
check_collinearity.hurdle <- function(x,
330-
component = c("all", "conditional", "count", "zi", "zero_inflated"),
336+
component = "all",
331337
ci = 0.95,
332338
verbose = verbose,
333339
...) {
334-
component <- match.arg(component)
340+
component <- insight::validate_argument(
341+
component,
342+
c("all", "conditional", "count", "zi", "zero_inflated")
343+
)
335344
.check_collinearity_zi_model(x, component, ci = ci, verbose = verbose)
336345
}
337346

338347

339348
#' @export
340349
check_collinearity.zeroinfl <- function(x,
341-
component = c("all", "conditional", "count", "zi", "zero_inflated"),
350+
component = "all",
342351
ci = 0.95,
343352
verbose = verbose,
344353
...) {
345-
component <- match.arg(component)
354+
component <- insight::validate_argument(
355+
component,
356+
c("all", "conditional", "count", "zi", "zero_inflated")
357+
)
346358
.check_collinearity_zi_model(x, component, ci = ci, verbose = verbose)
347359
}
348360

349361

350362
#' @export
351363
check_collinearity.zerocount <- function(x,
352-
component = c("all", "conditional", "count", "zi", "zero_inflated"),
364+
component = "all",
353365
ci = 0.95,
354366
verbose = verbose,
355367
...) {
356-
component <- match.arg(component)
368+
component <- insight::validate_argument(
369+
component,
370+
c("all", "conditional", "count", "zi", "zero_inflated")
371+
)
357372
.check_collinearity_zi_model(x, component, ci = ci, verbose = verbose)
358373
}
359374

R/check_dag.R

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,14 +215,17 @@ check_dag <- function(...,
215215
exposure = NULL,
216216
adjusted = NULL,
217217
latent = NULL,
218-
effect = c("all", "total", "direct"),
218+
effect = "all",
219219
coords = NULL) {
220220
insight::check_if_installed(
221221
c("ggdag", "dagitty"),
222222
reason = "to check correct adjustments for identifying causal effects."
223223
)
224224

225-
effect <- match.arg(effect)
225+
effect <- insight::validate_argument(
226+
effect,
227+
c("all", "total", "direct")
228+
)
226229

227230
# retrieve formulas
228231
formulas <- list(...)

R/check_homogeneity.R

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,19 @@
3030
#' result <- check_homogeneity(model)
3131
#' plot(result)
3232
#' @export
33-
check_homogeneity <- function(x, method = c("bartlett", "fligner", "levene", "auto"), ...) {
33+
check_homogeneity <- function(x, method = "bartlett", ...) {
3434
UseMethod("check_homogeneity")
3535
}
3636

3737

3838
# default -------------------------
3939

4040
#' @export
41-
check_homogeneity.default <- function(x, method = c("bartlett", "fligner", "levene", "auto"), ...) {
42-
method <- match.arg(method)
41+
check_homogeneity.default <- function(x, method = "bartlett", ...) {
42+
method <- insight::validate_argument(
43+
method,
44+
c("bartlett", "fligner", "levene", "auto")
45+
)
4346

4447
resp <- insight::find_response(x)
4548
pred <- insight::find_predictors(x, component = "conditional", flatten = TRUE)

R/check_normality.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,9 @@ print.check_normality <- function(x, ...) {
189189

190190
#' @rdname check_normality
191191
#' @export
192-
check_normality.merMod <- function(x, effects = c("fixed", "random"), ...) {
192+
check_normality.merMod <- function(x, effects = "fixed", ...) {
193193
# args
194-
effects <- match.arg(effects)
194+
effects <- insight::validate_argument(effects, c("fixed", "random"))
195195
info <- insight::model_info(x)
196196

197197
# valid model?

R/check_outliers.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1489,8 +1489,8 @@ check_outliers.metabin <- check_outliers.metagen
14891489
#' @rdname check_outliers
14901490
#' @export
14911491
check_outliers.performance_simres <- function(x, type = "default", iterations = 100, alternative = "two.sided", ...) {
1492-
type <- match.arg(type, c("default", "binomial", "bootstrap"))
1493-
alternative <- match.arg(alternative, c("two.sided", "greater", "less"))
1492+
type <- insight::validate_argument(type, c("default", "binomial", "bootstrap"))
1493+
alternative <- insight::validate_argument(alternative, c("two.sided", "greater", "less"))
14941494

14951495
insight::check_if_installed("DHARMa")
14961496
result <- DHARMa::testOutliers(x, type = type, nBoot = iterations, alternative = alternative, plot = FALSE, ...)

R/check_overdispersion.R

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,11 @@ check_overdispersion.glmmTMB <- check_overdispersion.merMod
284284

285285
#' @rdname check_overdispersion
286286
#' @export
287-
check_overdispersion.performance_simres <- function(x, alternative = c("two.sided", "less", "greater"), ...) {
288-
alternative <- match.arg(alternative)
287+
check_overdispersion.performance_simres <- function(x, alternative = "two.sided", ...) {
288+
alternative <- insight::validate_argument(
289+
alternative,
290+
c("two.sided", "less", "greater")
291+
)
289292

290293
# check for special arguments - we may pass "object_name" from other methods
291294
dots <- list(...)

R/check_predictions.R

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,10 @@ check_predictions.default <- function(object,
126126
}
127127

128128
# args
129-
type <- match.arg(type, choices = c("density", "discrete_dots", "discrete_interval", "discrete_both"))
129+
type <- insight::validate_argument(
130+
type,
131+
c("density", "discrete_dots", "discrete_interval", "discrete_both")
132+
)
130133

131134
pp_check.lm(
132135
object,
@@ -161,7 +164,10 @@ check_predictions.stanreg <- function(object,
161164
}
162165

163166
# args
164-
type <- match.arg(type, choices = c("density", "discrete_dots", "discrete_interval", "discrete_both"))
167+
type <- insight::validate_argument(
168+
type,
169+
c("density", "discrete_dots", "discrete_interval", "discrete_both")
170+
)
165171

166172
# convert to type-argument for pp_check
167173
pp_type <- switch(type,

R/check_residuals.R

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
#' @param x An object returned by [`simulate_residuals()`] or
99
#' [`DHARMa::simulateResiduals()`].
1010
#' @param alternative A character string specifying the alternative hypothesis.
11-
#' See [`stats::ks.test()`] for details.
11+
#' Can be one of `"two.sided"`, `"less"`, or `"greater"`. See
12+
#' [`stats::ks.test()`] for details.
1213
#' @param ... Passed down to [`stats::ks.test()`].
1314
#'
1415
#' @details Uniformity of residuals is checked using a Kolmogorov-Smirnov test.
@@ -38,7 +39,7 @@ check_residuals <- function(x, ...) {
3839

3940
#' @rdname check_residuals
4041
#' @export
41-
check_residuals.default <- function(x, alternative = c("two.sided", "less", "greater"), ...) {
42+
check_residuals.default <- function(x, alternative = "two.sided", ...) {
4243
if (insight::is_model(x)) {
4344
check_residuals(simulate_residuals(x, ...), alternative = alternative)
4445
} else {
@@ -47,8 +48,11 @@ check_residuals.default <- function(x, alternative = c("two.sided", "less", "gre
4748
}
4849

4950
#' @export
50-
check_residuals.performance_simres <- function(x, alternative = c("two.sided", "less", "greater"), ...) {
51-
alternative <- match.arg(alternative)
51+
check_residuals.performance_simres <- function(x, alternative = "two.sided", ...) {
52+
alternative <- insight::validate_argument(
53+
alternative,
54+
c("two.sided", "less", "greater")
55+
)
5256
ts_test <- suppressWarnings(
5357
stats::ks.test(
5458
stats::residuals(x),

0 commit comments

Comments
 (0)