Skip to contents

get_predictions() is the internal generic that multiple_comparisons(), pairwise_comparisons() and reference_comparisons() use to obtain the predicted means, the standard-error-of-differences (SED) matrix and the degrees of freedom 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 get_predictions() method.

Usage

get_predictions(model.obj, classify, pred.obj = NULL, ...)

Arguments

model.obj

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

classify

Name of the predictor variable(s) as a string.

pred.obj

Optional precomputed prediction object (asreml only; otherwise predictions are computed internally).

...

Additional arguments passed to the class-specific method (e.g. ASReml-R predict() arguments).

Value

A list with elements predictions, sed, df, ylab and aliased_names (and emmeans_grid for emmeans-backed engines).

Supported model types

The comparison functions (multiple_comparisons(), pairwise_comparisons() and reference_comparisons()) work with any model for which a get_predictions() method is defined. These are currently:

Model classFitted byNotes
aov, lmstats::aov(), stats::lm()Fixed-effects linear models.
aovliststats::aov() with an Error() termMulti-stratum aov; gives comparison-specific (matrix) degrees of freedom.
lmenlme::lme()Linear mixed model.
lmerModlme4::lmer(), lme4breeding::lmebreed()Linear mixed model. lmebreed() (relationship-based) models also carry class lmerMod; comparisons target the fixed-effect means with Kenward-Roger degrees of freedom, and correctly reflect the relationship structure (validated against ASReml-R).
lmerModLmerTestlmerTest::lmer()As lmerMod, with Satterthwaite degrees of freedom.
asremlASReml-R asreml()Linear mixed model (commercial; not on CRAN).
afex_aovafex aov_car() / aov_ez() / aov_4()Factorial / repeated-measures ANOVA; gives comparison-specific (matrix) degrees of freedom.
glmmTMBglmmTMB glmmTMB()Generalized linear mixed model. Predictions are on the link scale with asymptotic (infinite) degrees of freedom; supply trans to back-transform.
mmessommer mmes()Linear mixed model, via sommer's native predict(). SED from the prediction covariance; asymptotic (infinite) degrees of freedom (sommer provides none).

ARTool (art) models are supported by resplot() but not by the comparison functions: the aligned rank transform makes mean-based comparisons inappropriate. Use ARTool::art.con() for contrasts on ART models instead.

sommer mmer models (the legacy interface) are supported by resplot() but not by the comparison functions: current sommer provides no predict() method for mmer. Refit with sommer::mmes() to use the comparison functions.

To add a new engine, write a get_predictions.<class>() method returning a list with elements predictions, sed, df, ylab and aliased_names (plus emmeans_grid for engines backed by emmeans::emmeans()), and add a row to the table above.