Skip to content

Commit 38eb303

Browse files
committed
rd
1 parent f7ea9ac commit 38eb303

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+129
-80
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ Suggests:
159159
withr (>= 3.0.0)
160160
Encoding: UTF-8
161161
Language: en-US
162-
RoxygenNote: 7.3.2
162+
RoxygenNote: 7.3.3
163163
Roxygen: list(markdown = TRUE)
164164
Config/testthat/edition: 3
165165
Config/testthat/parallel: true

NAMESPACE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ S3method(as.data.frame,r2_nakagawa)
2828
S3method(as.double,check_outliers)
2929
S3method(as.double,item_omega)
3030
S3method(as.double,performance_roc)
31+
S3method(check_autocorrelation,DHARMa)
3132
S3method(check_autocorrelation,default)
33+
S3method(check_autocorrelation,performance_simres)
3234
S3method(check_collinearity,BFBayesFactor)
3335
S3method(check_collinearity,MixMod)
3436
S3method(check_collinearity,afex_aov)

R/check_autocorrelation.R

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,18 @@ check_autocorrelation.default <- function(x, nsim = 1000, ...) {
5656
}
5757

5858

59-
#' @rdname check_autocorrelation
6059
#' @export
6160
check_autocorrelation.performance_simres <- function(x, ...) {
6261
insight::check_if_installed("DHARMa")
63-
62+
6463
# Use DHARMa's temporal autocorrelation test
6564
# This requires the residuals to be ordered by time
6665
# DHARMa::testTemporalAutocorrelation expects a DHARMa object
6766
result <- DHARMa::testTemporalAutocorrelation(x, plot = FALSE, ...)
68-
67+
6968
# Extract p-value from the result
7069
p.val <- result$p.value
71-
70+
7271
class(p.val) <- c("check_autocorrelation", "see_check_autocorrelation", class(p.val))
7372
p.val
7473
}
@@ -81,7 +80,9 @@ check_autocorrelation.DHARMa <- check_autocorrelation.performance_simres
8180

8281
#' @export
8382
plot.check_autocorrelation <- function(x, ...) {
84-
insight::format_warning("There is currently no `plot()` method for `check_autocorrelation()`.")
83+
insight::format_warning(
84+
"There is currently no `plot()` method for `check_autocorrelation()`."
85+
)
8586
}
8687

8788

R/check_overdispersion.R

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ check_overdispersion <- function(x, ...) {
7878
check_overdispersion.default <- function(x, ...) {
7979
.is_model_valid(x)
8080
insight::format_error(
81-
paste0("`check_overdisperion()` not yet implemented for models of class `", class(x)[1], "`.")
81+
paste0(
82+
"`check_overdisperion()` not yet implemented for models of class `",
83+
class(x)[1],
84+
"`."
85+
)
8286
)
8387
}
8488

@@ -122,7 +126,9 @@ print.check_overdisp <- function(x, digits = 3, ...) {
122126
}
123127

124128
x$p_value <- pval <- round(x$p_value, digits = digits)
125-
if (x$p_value < 0.001) x$p_value <- "< 0.001"
129+
if (x$p_value < 0.001) {
130+
x$p_value <- "< 0.001"
131+
}
126132

127133
maxlen <- max(
128134
nchar(x$dispersion_ratio),
@@ -132,12 +138,27 @@ print.check_overdisp <- function(x, digits = 3, ...) {
132138

133139
insight::print_color("# Overdispersion test\n\n", "blue")
134140
if (is.null(x$chisq_statistic)) {
135-
cat(sprintf(" dispersion ratio = %s\n", format(x$dispersion_ratio, justify = "right", width = maxlen)))
136-
cat(sprintf(" p-value = %s\n\n", format(x$p_value, justify = "right", width = maxlen)))
141+
cat(sprintf(
142+
" dispersion ratio = %s\n",
143+
format(x$dispersion_ratio, justify = "right", width = maxlen)
144+
))
145+
cat(sprintf(
146+
" p-value = %s\n\n",
147+
format(x$p_value, justify = "right", width = maxlen)
148+
))
137149
} else {
138-
cat(sprintf(" dispersion ratio = %s\n", format(x$dispersion_ratio, justify = "right", width = maxlen)))
139-
cat(sprintf(" Pearson's Chi-Squared = %s\n", format(x$chisq_statistic, justify = "right", width = maxlen)))
140-
cat(sprintf(" p-value = %s\n\n", format(x$p_value, justify = "right", width = maxlen)))
150+
cat(sprintf(
151+
" dispersion ratio = %s\n",
152+
format(x$dispersion_ratio, justify = "right", width = maxlen)
153+
))
154+
cat(sprintf(
155+
" Pearson's Chi-Squared = %s\n",
156+
format(x$chisq_statistic, justify = "right", width = maxlen)
157+
))
158+
cat(sprintf(
159+
" p-value = %s\n\n",
160+
format(x$p_value, justify = "right", width = maxlen)
161+
))
141162
}
142163

143164
if (pval > 0.05) {
@@ -161,7 +182,10 @@ check_overdispersion.glm <- function(x, verbose = TRUE, ...) {
161182
obj_name <- insight::safe_deparse_symbol(substitute(x))
162183

163184
# for certain distributions, simulated residuals are more accurate
164-
use_simulated <- info$is_bernoulli || info$is_binomial || (!info$is_count && !info$is_binomial) || info$is_negbin
185+
use_simulated <- info$is_bernoulli ||
186+
info$is_binomial ||
187+
(!info$is_count && !info$is_binomial) ||
188+
info$is_negbin
165189

166190
# model classes not supported in DHARMa
167191
not_supported <- c("fixest", "glmx")
@@ -247,7 +271,13 @@ check_overdispersion.merMod <- function(x, ...) {
247271

248272
# for certain distributions, simulated residuals are more accurate
249273
# Note: now including Poisson models for mixed models (see #595, #643)
250-
use_simulated <- info$family == "genpois" || info$is_zero_inflated || info$is_bernoulli || info$is_binomial || (!info$is_count && !info$is_binomial) || info$is_negbin || info$is_poisson # nolint
274+
use_simulated <- info$family == "genpois" ||
275+
info$is_zero_inflated ||
276+
info$is_bernoulli ||
277+
info$is_binomial ||
278+
(!info$is_count && !info$is_binomial) ||
279+
info$is_negbin ||
280+
info$is_poisson
251281

252282
if (use_simulated) {
253283
return(check_overdispersion(simulate_residuals(x, ...), object_name = obj_name, ...))

R/check_zeroinflation.R

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,11 @@ check_zeroinflation.default <- function(x, tolerance = 0.05, ...) {
9191
# for models with zero-inflation component, negative binomial families,
9292
# or Poisson mixed models, we use simulate_residuals()
9393
# Note: now including Poisson mixed models (see #595, #643)
94-
use_simulated <- model_info$is_zero_inflated || model_info$is_negbin || model_info$family == "genpois" || (model_info$is_mixed && model_info$is_poisson) # nolint
95-
94+
use_simulated <- model_info$is_zero_inflated ||
95+
model_info$is_negbin ||
96+
model_info$family == "genpois" ||
97+
(model_info$is_mixed && model_info$is_poisson)
98+
9699
if (!inherits(x, not_supported) && use_simulated) {
97100
if (missing(tolerance)) {
98101
tolerance <- 0.1
@@ -120,17 +123,23 @@ check_zeroinflation.default <- function(x, tolerance = 0.05, ...) {
120123

121124
#' @rdname check_zeroinflation
122125
#' @export
123-
check_zeroinflation.performance_simres <- function(x,
124-
tolerance = 0.1,
125-
alternative = "two.sided",
126-
...) {
126+
check_zeroinflation.performance_simres <- function(
127+
x,
128+
tolerance = 0.1,
129+
alternative = "two.sided",
130+
...
131+
) {
127132
alternative <- insight::validate_argument(
128133
alternative,
129134
c("two.sided", "less", "greater")
130135
)
131136

132137
# compute test results
133-
result <- .simres_statistics(x, statistic_fun = function(i) sum(i == 0), alternative = alternative)
138+
result <- .simres_statistics(
139+
x,
140+
statistic_fun = function(i) sum(i == 0),
141+
alternative = alternative
142+
)
134143

135144
structure(
136145
class = "check_zi",

man/binned_residuals.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/check_autocorrelation.Rd

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

man/check_collinearity.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/check_convergence.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/check_dag.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)