| ggeffect {ggeffects} | R Documentation |
ggeffect() computes marginal effects of model terms. It internally
calls Effect and puts the result into tidy data
frames.
ggeffect(model, terms, ci.lvl = 0.95, x.as.factor = FALSE, ...)
model |
A fitted model object, or a list of model objects. Any model that is supported by the effects-package should work. |
terms |
Character vector with the names of those terms from |
ci.lvl |
Numeric, the level of the confidence intervals. For |
x.as.factor |
Logical, if |
... |
Further arguments passed down to |
The results of ggeffect() and ggpredict() are usually (almost)
identical. It's just that ggpredict() calls predict(), while
ggeffect() calls Effect to compute marginal
effects at the mean. However, results may differ when using factors inside
the formula: in such cases, Effect() takes the "mean" value of factors
(i.e. computes a kind of "average" value, which represents the proportions
of each factor's category), while ggpredict() uses the base
(reference) level when holding these predictors at a constant value.
A tibble (with ggeffects class attribute) with consistent data columns:
xthe values of the model predictor to which the effect pertains, used as x-position in plots.
predictedthe predicted values, used as y-position in plots.
conf.lowthe lower bound of the confidence interval for the predicted values.
conf.highthe upper bound of the confidence interval for the predicted values.
groupthe grouping level from the second term in terms, used as grouping-aesthetics in plots.
facetthe grouping level from the third term in terms, used to indicate facets in plots.
data(efc)
fit <- lm(barthtot ~ c12hour + neg_c_7 + c161sex + c172code, data = efc)
ggeffect(fit, terms = "c12hour")
mydf <- ggeffect(fit, terms = c("c12hour", "c161sex"))
plot(mydf)