Internal model-information extraction for resplot()
Source:R/resplot_methods.R
extract_model_info.Rdextract_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.
Supported model types
resplot() produces residual diagnostics for any model with an
extract_model_info() method. These are currently:
| Model class | Fitted by | Notes |
aov, lm | stats::aov(), stats::lm() | Fixed-effects linear models. |
aovlist | stats::aov() with an Error() term | Multi-stratum aov; each error stratum (except the intercept) is shown as a separate plot. |
lme | nlme::lme() | Linear mixed model. |
lmerMod | lme4::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. |
lmerModLmerTest | lmerTest::lmer() | As lmerMod. |
asreml | ASReml-R asreml() | Linear mixed model (commercial; not on CRAN). Residual strata are shown as separate plots. |
mmer, mmes | sommer mmer() / mmes() | Linear mixed model. |
art | ARTool::art() | Aligned rank transform model. |
afex_aov | afex aov_car() / aov_ez() / aov_4() | Factorial / repeated-measures ANOVA; a single diagnostic panel from the model residuals. |
glmmTMB | glmmTMB 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.