emm()
is a convenient shortcut to compute the estimated
marginal mean, resp. the marginal effect of the model's response
variable, with all independent variables held constant (at
their typical_value
).
emm(model, ci.lvl = 0.95, type = c("fe", "re"), typical = "mean", ...)
model | A fitted model object, or a list of model objects. Any model
that supports common methods like |
---|---|
ci.lvl | Numeric, the level of the confidence intervals. For |
type | Character, only applies for mixed effects models. Indicates
whether predicted values should be conditioned on random effects
( |
typical | Character vector, naming the function to be applied to the
covariates over which the effect is "averaged". The default is "mean".
See |
... | Further arguments passed down to |
A tibble with the marginal effect of the response (predicted
)
and the confidence intervals conf.low
and conf.high
.
For polr
-objects, the marginal effect for each level of the
response variable is returned.
For linear models, the predicted value is the estimated marginal mean. Else, the predicted value is on the scale of the inverse of link function.
data(efc) fit <- lm(barthtot ~ c12hour + neg_c_7 + c161sex + c172code, data = efc) emm(fit)#> # A tibble: 1 x 3 #> predicted conf.low conf.high #> <dbl> <dbl> <dbl> #> 1 64.8 63.1 66.4# Example from ?MASS::polr library(MASS) options(contrasts = c("contr.treatment", "contr.poly")) house.plr <- polr(Sat ~ Infl + Type + Cont, weights = Freq, data = housing) emm(house.plr)#> predicted response.level #> 1 0.3784493 Low #> 2 0.2876752 Medium #> 3 0.3338755 High