99# ' If `check_model()` doesn't work as expected, try setting `verbose = TRUE` to
1010# ' get hints about possible problems.
1111# '
12- # ' @param x A model object.
12+ # ' @param model A model object.
1313# ' @param size_dot,size_line Size of line and dot-geoms.
1414# ' @param base_size,size_title,size_axis_title Base font size for axis and plot titles.
1515# ' @param panel Logical, if `TRUE`, plots are arranged as panels; else,
5656# ' @param verbose If `FALSE` (default), suppress most warning messages.
5757# ' @param ... Arguments passed down to the individual check functions, especially
5858# ' to `check_predictions()` and `binned_residuals()`.
59+ # ' @param x Deprecated, please use `model` instead.
60+ # '
5961# ' @inheritParams check_predictions
6062# '
6163# ' @return The data frame that is used for plotting.
191193# ' check_model(m, panel = FALSE)
192194# ' }
193195# ' @export
194- check_model <- function (x , ... ) {
196+ check_model <- function (model = NULL , ... ) {
195197 UseMethod(" check_model" )
196198}
197199
@@ -201,7 +203,7 @@ check_model <- function(x, ...) {
201203# ' @rdname check_model
202204# ' @export
203205check_model.default <- function (
204- x ,
206+ model = NULL ,
205207 panel = TRUE ,
206208 check = " all" ,
207209 detrend = TRUE ,
@@ -221,14 +223,23 @@ check_model.default <- function(
221223 colors = c(" #3aaf85" , " #1b6ca8" , " #cd201f" ),
222224 theme = see :: theme_lucid(),
223225 verbose = FALSE ,
226+ x = NULL ,
224227 ...
225228) {
229+ # # TODO remove deprecation warning later
230+ if (! is.null(x ) && is.null(model )) {
231+ insight :: format_warning(
232+ " Argument `x` is deprecated; please use `model` instead."
233+ )
234+ model <- x
235+ }
236+
226237 # check model formula
227238 if (verbose ) {
228- insight :: formula_ok(x )
239+ insight :: formula_ok(model )
229240 }
230241
231- minfo <- insight :: model_info(x , verbose = FALSE )
242+ minfo <- insight :: model_info(model , verbose = FALSE )
232243
233244 # set default for residual_type
234245 if (is.null(residual_type )) {
@@ -250,10 +261,10 @@ check_model.default <- function(
250261
251262 assumptions_data <- tryCatch(
252263 if (minfo $ is_bayesian ) {
253- suppressWarnings(.check_assumptions_stan(x , ... ))
264+ suppressWarnings(.check_assumptions_stan(model , ... ))
254265 } else if (minfo $ is_linear ) {
255266 suppressWarnings(.check_assumptions_linear(
256- x ,
267+ model ,
257268 minfo ,
258269 check ,
259270 residual_type ,
@@ -262,7 +273,7 @@ check_model.default <- function(
262273 ))
263274 } else {
264275 suppressWarnings(.check_assumptions_glm(
265- x ,
276+ model ,
266277 minfo ,
267278 check ,
268279 residual_type ,
@@ -283,7 +294,7 @@ check_model.default <- function(
283294 paste(" `check_model()` returned following error:" , cleaned_string ),
284295 paste0(
285296 " \n If the error message does not help identifying your problem, another reason why `check_model()` failed might be that models of class `" ,
286- class(x )[1 ],
297+ class(model )[1 ],
287298 " ` are not yet supported."
288299 ) # nolint
289300 )
@@ -293,7 +304,7 @@ check_model.default <- function(
293304 if (is.null(assumptions_data $ QQ ) && residual_type == " simulated" ) {
294305 insight :: format_alert(paste0(
295306 " Cannot simulate residuals for models of class `" ,
296- class(x )[1 ],
307+ class(model )[1 ],
297308 " `. Please try `check_model(..., residual_type = \" normal\" )` instead."
298309 ))
299310 }
@@ -309,7 +320,7 @@ check_model.default <- function(
309320 }
310321
311322 # set default for show_dots, based on "model size"
312- n <- .safe(insight :: n_obs(x ))
323+ n <- .safe(insight :: n_obs(model ))
313324 if (is.null(show_dots )) {
314325 show_dots <- is.null(n ) || n < = 1e5
315326 }
@@ -322,7 +333,7 @@ check_model.default <- function(
322333 }
323334
324335 # if we have only categorical predictors, we don't show CI by default
325- parameter_types <- .safe(parameters :: parameters_type(x ))
336+ parameter_types <- .safe(parameters :: parameters_type(model ))
326337 if (
327338 ! is.null(parameter_types ) && all(parameter_types $ Type %in% c(" intercept" , " factor" ))
328339 ) {
@@ -350,7 +361,7 @@ check_model.default <- function(
350361 attr(assumptions_data , " bandwidth" ) <- bandwidth
351362 attr(assumptions_data , " type" ) <- type
352363 attr(assumptions_data , " maximum_dots" ) <- maximum_dots
353- attr(assumptions_data , " model_class" ) <- class(x )[1 ]
364+ attr(assumptions_data , " model_class" ) <- class(model )[1 ]
354365 assumptions_data
355366}
356367
@@ -377,7 +388,7 @@ plot.check_model <- function(x, ...) {
377388
378389# ' @export
379390check_model.stanreg <- function (
380- x ,
391+ model = NULL ,
381392 panel = TRUE ,
382393 check = " all" ,
383394 detrend = TRUE ,
@@ -397,10 +408,19 @@ check_model.stanreg <- function(
397408 colors = c(" #3aaf85" , " #1b6ca8" , " #cd201f" ),
398409 theme = see :: theme_lucid(),
399410 verbose = FALSE ,
411+ x = NULL ,
400412 ...
401413) {
414+ # # TODO remove deprecation warning later
415+ if (! is.null(x ) && is.null(model )) {
416+ insight :: format_warning(
417+ " Argument `x` is deprecated; please use `model` instead."
418+ )
419+ model <- x
420+ }
421+
402422 check_model(
403- bayestestR :: bayesian_as_frequentist(x ),
423+ model = .safe( bayestestR :: bayesian_as_frequentist(model ) ),
404424 size_dot = size_dot ,
405425 size_line = size_line ,
406426 panel = panel ,
@@ -430,7 +450,7 @@ check_model.brmsfit <- check_model.stanreg
430450
431451# ' @export
432452check_model.model_fit <- function (
433- x ,
453+ model = NULL ,
434454 panel = TRUE ,
435455 check = " all" ,
436456 detrend = TRUE ,
@@ -450,10 +470,19 @@ check_model.model_fit <- function(
450470 colors = c(" #3aaf85" , " #1b6ca8" , " #cd201f" ),
451471 theme = see :: theme_lucid(),
452472 verbose = FALSE ,
473+ x = NULL ,
453474 ...
454475) {
476+ # # TODO remove deprecation warning later
477+ if (! is.null(x ) && is.null(model )) {
478+ insight :: format_warning(
479+ " Argument `x` is deprecated; please use `model` instead."
480+ )
481+ model <- x
482+ }
483+
455484 check_model(
456- x $ fit ,
485+ model $ fit ,
457486 size_dot = size_dot ,
458487 size_line = size_line ,
459488 panel = panel ,
@@ -479,7 +508,7 @@ check_model.model_fit <- function(
479508
480509# ' @export
481510check_model.performance_simres <- function (
482- x ,
511+ model = NULL ,
483512 panel = TRUE ,
484513 check = " all" ,
485514 detrend = TRUE ,
@@ -499,10 +528,19 @@ check_model.performance_simres <- function(
499528 colors = c(" #3aaf85" , " #1b6ca8" , " #cd201f" ),
500529 theme = see :: theme_lucid(),
501530 verbose = FALSE ,
531+ x = NULL ,
502532 ...
503533) {
534+ # # TODO remove deprecation warning later
535+ if (! is.null(x ) && is.null(model )) {
536+ insight :: format_warning(
537+ " Argument `x` is deprecated; please use `model` instead."
538+ )
539+ model <- x
540+ }
541+
504542 check_model(
505- x $ fittedModel ,
543+ model $ fittedModel ,
506544 size_dot = size_dot ,
507545 size_line = size_line ,
508546 panel = panel ,
0 commit comments