35
35
# ' tries to guess whether performance will be poor due to a very large model
36
36
# ' and thus automatically shows or hides dots.
37
37
# ' @param verbose If `FALSE` (default), suppress most warning messages.
38
- # ' @param ... Currently not used.
38
+ # ' @param ... Arguments passed down to the individual check functions, especially
39
+ # ' to `check_predictions()` and `binned_residuals()`.
39
40
# ' @inheritParams check_predictions
40
41
# '
41
42
# ' @return The data frame that is used for plotting.
@@ -185,11 +186,11 @@ check_model.default <- function(x,
185
186
ca <- tryCatch(
186
187
{
187
188
if (minfo $ is_bayesian ) {
188
- suppressWarnings(.check_assumptions_stan(x ))
189
+ suppressWarnings(.check_assumptions_stan(x , ... ))
189
190
} else if (minfo $ is_linear ) {
190
- suppressWarnings(.check_assumptions_linear(x , minfo , verbose ))
191
+ suppressWarnings(.check_assumptions_linear(x , minfo , verbose , ... ))
191
192
} else {
192
- suppressWarnings(.check_assumptions_glm(x , minfo , verbose ))
193
+ suppressWarnings(.check_assumptions_glm(x , minfo , verbose , ... ))
193
194
}
194
195
},
195
196
error = function (e ) {
@@ -202,7 +203,7 @@ check_model.default <- function(x,
202
203
}
203
204
204
205
# try to find sensible default for "type" argument
205
- suggest_dots <- (minfo $ is_bernoulli || minfo $ is_count || minfo $ is_ordinal || minfo $ is_categorical || minfo $ is_multinomial )
206
+ suggest_dots <- (minfo $ is_bernoulli || minfo $ is_count || minfo $ is_ordinal || minfo $ is_categorical || minfo $ is_multinomial ) # nolint
206
207
if (missing(type ) && suggest_dots ) {
207
208
type <- " discrete_interval"
208
209
}
@@ -330,7 +331,7 @@ check_model.model_fit <- function(x,
330
331
331
332
# compile plots for checks of linear models ------------------------
332
333
333
- .check_assumptions_linear <- function (model , model_info , verbose = TRUE ) {
334
+ .check_assumptions_linear <- function (model , model_info , verbose = TRUE , ... ) {
334
335
dat <- list ()
335
336
336
337
dat $ VIF <- .diag_vif(model , verbose = verbose )
@@ -340,13 +341,13 @@ check_model.model_fit <- function(x,
340
341
dat $ NCV <- .diag_ncv(model , verbose = verbose )
341
342
dat $ HOMOGENEITY <- .diag_homogeneity(model , verbose = verbose )
342
343
dat $ OUTLIERS <- check_outliers(model , method = " cook" )
343
- if (! is.null(dat $ OUTLIERS )) {
344
- threshold <- attributes(dat $ OUTLIERS )$ threshold $ cook
345
- } else {
344
+ if (is.null(dat $ OUTLIERS )) {
346
345
threshold <- NULL
346
+ } else {
347
+ threshold <- attributes(dat $ OUTLIERS )$ threshold $ cook
347
348
}
348
349
dat $ INFLUENTIAL <- .influential_obs(model , threshold = threshold )
349
- dat $ PP_CHECK <- .safe(check_predictions(model ))
350
+ dat $ PP_CHECK <- .safe(check_predictions(model , ... ))
350
351
351
352
dat <- insight :: compact_list(dat )
352
353
class(dat ) <- c(" check_model" , " see_check_model" )
@@ -357,23 +358,23 @@ check_model.model_fit <- function(x,
357
358
358
359
# compile plots for checks of generalized linear models ------------------------
359
360
360
- .check_assumptions_glm <- function (model , model_info , verbose = TRUE ) {
361
+ .check_assumptions_glm <- function (model , model_info , verbose = TRUE , ... ) {
361
362
dat <- list ()
362
363
363
364
dat $ VIF <- .diag_vif(model , verbose = verbose )
364
365
dat $ QQ <- .diag_qq(model , verbose = verbose )
365
366
dat $ HOMOGENEITY <- .diag_homogeneity(model , verbose = verbose )
366
367
dat $ REQQ <- .diag_reqq(model , level = 0.95 , model_info = model_info , verbose = verbose )
367
368
dat $ OUTLIERS <- check_outliers(model , method = " cook" )
368
- if (! is.null(dat $ OUTLIERS )) {
369
- threshold <- attributes(dat $ OUTLIERS )$ threshold $ cook
370
- } else {
369
+ if (is.null(dat $ OUTLIERS )) {
371
370
threshold <- NULL
371
+ } else {
372
+ threshold <- attributes(dat $ OUTLIERS )$ threshold $ cook
372
373
}
373
374
dat $ INFLUENTIAL <- .influential_obs(model , threshold = threshold )
374
- dat $ PP_CHECK <- .safe(check_predictions(model ))
375
+ dat $ PP_CHECK <- .safe(check_predictions(model , ... ))
375
376
if (isTRUE(model_info $ is_binomial )) {
376
- dat $ BINNED_RESID <- binned_residuals(model )
377
+ dat $ BINNED_RESID <- binned_residuals(model , ... )
377
378
}
378
379
if (isTRUE(model_info $ is_count )) {
379
380
dat $ OVERDISPERSION <- .diag_overdispersion(model )
@@ -388,7 +389,7 @@ check_model.model_fit <- function(x,
388
389
389
390
# compile plots for checks of Bayesian models ------------------------
390
391
391
- .check_assumptions_stan <- function (model ) {
392
+ .check_assumptions_stan <- function (model , ... ) {
392
393
if (inherits(model , " brmsfit" )) {
393
394
# check if brms can be loaded
394
395
0 commit comments