terms() gives the terms object of the fixed effects of a model fitted by
pglmm() or pglmm_compare(), and model.matrix() its design matrix of the
fixed effects. They are used, with vcov() and
fixef(), by packages such as emmeans,
marginaleffects and effects, which work with pglmm() models (see Details).
Usage
# S3 method for class 'communityPGLMM'
terms(x, fixed.only = TRUE, ...)
# S3 method for class 'communityPGLMM'
model.matrix(object, ...)Arguments
- x, object
A model fitted by
pglmm()orpglmm_compare().- fixed.only
Only
TRUE(the fixed effects) is available.- ...
Ignored.
Value
terms(): a terms object; model.matrix(): the design matrix of the
fixed effects, with one row per observation used in the fit.
Details
Estimated marginal means and contrasts with emmeans::emmeans(), marginal
effects and predictions with the marginaleffects package (e.g.
marginaleffects::avg_slopes(), marginaleffects::predictions()), and
effect plots with effects::Effect() and effects::allEffects() work with
models fitted with bayes = FALSE. They use the fixed effects and their
covariance matrix, with the random effects at zero, as for lme4 models;
with marginaleffects, use re.form = NA for predictions without the random
effects (the default, re.form = NULL, gives predictions conditional on the
estimated random effects for the levels in the data). Degrees of freedom are
asymptotic (z tests), as with glmmTMB().
marginaleffects accepts only the model classes it knows: until it knows
those of phyr, set options(marginaleffects_model_classes = "communityPGLMM")
before using it with pglmm() models.
Other packages that work with these models, through coef(), vcov(),
terms(), model.matrix(), logLik(), nobs() and update(): Wald tests
of the terms with car::Anova() and of linear hypotheses with
car::linearHypothesis(); multiple comparisons with multcomp::glht();
likelihood ratio tests with lmtest::lrtest(); model selection and
averaging with MuMIn::dredge() (with options(na.action = "na.fail")),
MuMIn::model.sel() and MuMIn::model.avg(), which keep the random terms
of the global model in all the submodels; and plots of predictions with
ggeffects through emmeans (ggeffects::predict_response(fit, "x", margin = "marginalmeans") or ggeffects::ggemmeans()).
