get_averages | R Documentation |
Calculate average estimates by taking the (group-wise) mean of all the unit-level
estimates computed by the predictions()
, comparisons()
, or slopes()
functions.
Warning: It is generally faster and safer to use the by
argument of one of
the three functions listed above. Alternatively, one can call it in one step:
avg_slopes(model)
slopes(model, by = TRUE)
Proceeding in two steps by assigning the unit-level estimates is typically slower, because all estimates must be computed twice.
Note that the tidy()
and summary()
methods are slower wrappers around avg_*()
functions.
get_averages(x, by = TRUE, ...)
x |
Object produced by the |
by |
Character vector of variable names over which to compute group-wise average estimates. When |
... |
All additional arguments are passed to the original fitting
function to override the original call options: |
Standard errors are estimated using the delta method. See the marginaleffects
website for details.
In Bayesian models (e.g., brms
), estimates are aggregated applying the
median (or mean) function twice. First, we apply it to all
marginal effects for each posterior draw, thereby estimating one Average (or
Median) Marginal Effect per iteration of the MCMC chain. Second, we
calculate the mean and the quantile
function to the results of Step 1 to
obtain the Average Marginal Effect and its associated interval.
A data.frame
of estimates and uncertainty estimates
## Not run:
mod <- lm(mpg ~ factor(gear), data = mtcars)
contr <- comparisons(mod, variables = list(gear = "sequential"))
tidy(contr)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.