Visual check of model various assumptions (normality of residuals, normality of random effects, linear relationship, homogeneity of variance, multicollinearity).
check_model(x, ...)
# S3 method for default
check_model(
x,
dot_size = 2,
line_size = 0.8,
panel = TRUE,
check = "all",
alpha = 0.2,
dot_alpha = 0.8,
colors = c("#3aaf85", "#1b6ca8", "#cd201f"),
theme = "see::theme_lucid",
detrend = FALSE,
verbose = TRUE,
...
)
x  A model object. 

...  Currently not used. 
dot_size, line_size  Size of line and dotgeoms. 
panel  Logical, if 
check  Character vector, indicating which checks for should be performed
and plotted. May be one or more of

alpha, dot_alpha  The alpha level of the confidence bands and dotgeoms. Scalar from 0 to 1. 
colors  Character vector with color codes (hexformat). Must be of length 3. First color is usually used for reference lines, second color for dots, and third color for outliers or extreme values. 
theme  String, indicating the name of the plottheme. Must be in the
format 
detrend  Should QQ/PP plots be detrended? 
verbose  Toggle off warnings. 
The data frame that is used for plotting.
For Bayesian models from packages rstanarm or brms,
models will be "converted" to their frequentist counterpart, using
bayestestR::bayesian_as_frequentist
.
A more advanced modelcheck for Bayesian models will be implemented at a
later stage.
This function just prepares the data for plotting. To create the plots,
see needs to be installed. Furthermore, this function suppresses
all possible warnings. In case you observe suspicious plots, please refer
to the dedicated functions (like check_collinearity()
,
check_normality()
etc.) to get informative messages and warnings.
The plot Linearity checks the assumption of linear relationship.
However, the spread of dots also indicate possible heteroscedasticity (i.e.
nonconstant variance); hence, the alias "ncv"
for this plot.
Some caution is needed when interpreting these plots. Although these
plots are helpful to check model assumptions, they do not necessarily
indicate socalled "lack of fit", e.g. missed nonlinear relationships or
interactions. Thus, it is always recommended to also look at
effect plots, including partial residuals.
Plots that check the normality of residuals (QQplot) or the homogeneity of
variance use standardized Pearson's residuals for generalized linear models,
and standardized residuals for linear models. The plots for the normality of
residuals (with overlayed normal curve) and for the linearity assumption use
the default residuals for lm
and glm
(which are deviance
residuals for glm
).
if (FALSE) {
m < lm(mpg ~ wt + cyl + gear + disp, data = mtcars)
check_model(m)
if (require("lme4")) {
m < lmer(Reaction ~ Days + (Days  Subject), sleepstudy)
check_model(m, panel = FALSE)
}
if (require("rstanarm")) {
m < stan_glm(mpg ~ wt + gear, data = mtcars, chains = 2, iter = 200)
check_model(m)
}
}