Skip to contents

extract_model_info() is the internal generic that resplot() uses to pull the residuals, fitted values and (optionally) the model call from a fitted model. It dispatches on the class of model.obj. It is not exported and is not called directly by users; support for a new model engine is added by writing a new extract_model_info() method.

Usage

extract_model_info(model.obj, call = FALSE)

Arguments

model.obj

A fitted model object of a supported class (see Supported model types below).

call

Logical; whether to extract the model call for display.

Value

A list with elements facet, facet_name, resids, fits, k and model_call.

Supported model types

resplot() produces residual diagnostics for any model with an extract_model_info() method. These are currently:

Model classFitted byNotes
aov, lmstats::aov(), stats::lm()Fixed-effects linear models.
aovliststats::aov() with an Error() termMulti-stratum aov; each error stratum (except the intercept) is shown as a separate plot.
lmenlme::lme()Linear mixed model.
lmerModlme4::lmer(), lme4breeding::lmebreed()Linear mixed model. lmebreed() (relationship-based) models also carry class lmerMod; their residuals/fitted values are on the response scale, so the diagnostics are valid.
lmerModLmerTestlmerTest::lmer()As lmerMod.
asremlASReml-R asreml()Linear mixed model (commercial; not on CRAN). Residual strata are shown as separate plots.
mmer, mmessommer mmer() / mmes()Linear mixed model.
artARTool::art()Aligned rank transform model.
afex_aovafex aov_car() / aov_ez() / aov_4()Factorial / repeated-measures ANOVA; a single diagnostic panel from the model residuals.
glmmTMBglmmTMB glmmTMB()Gaussian family only. Non-Gaussian families error with a pointer to DHARMa::simulateResiduals(), since a normal Q-Q plot is not a valid diagnostic for them.

This set differs slightly from the comparison functions (see get_predictions()): resplot() additionally supports ARTool (art) models and sommer's legacy mmer interface. Neither is available for the comparison functions — ART uses aligned ranks (use ARTool::art.con()), and current sommer provides no predict() for mmer (refit with sommer::mmes()).

To add a new engine, write an extract_model_info.<class>() method returning a list with elements facet, facet_name, resids, fits, k and model_call, and add a row to the table above.

See also