tidy_all_effects: Marginal Predictions at the mean with 'effects::allEffects()'

View source: R/marginal_tidiers.R

tidy_all_effectsR Documentation

Marginal Predictions at the mean with effects::allEffects()

Description

[Experimental] Use effects::allEffects() to estimate marginal predictions and return a tibble tidied in a way that it could be used by broom.helpers functions. See vignette("functions-supported-by-effects", package = "effects") for a list of supported models.

Usage

tidy_all_effects(x, conf.int = TRUE, conf.level = 0.95, ...)

Arguments

x

(a model object, e.g. glm)
A model to be tidied.

conf.int

(logical)
Whether or not to include a confidence interval in the tidied output.

conf.level

(numeric)
The confidence level to use for the confidence interval (between 0 ans 1).

...

Additional parameters passed to effects::allEffects().

Details

By default, effects::allEffects() estimate marginal predictions at the mean at the observed means for continuous variables and weighting modalities of categorical variables according to their observed distribution in the original dataset. Marginal predictions are therefore computed at a sort of averaged situation / typical values for the other variables fixed in the model.

For more information, see vignette("marginal_tidiers", "broom.helpers").

Note

If the model contains interactions, effects::allEffects() will return marginal predictions for the different levels of the interactions.

See Also

effects::allEffects()

Other marginal_tieders: tidy_avg_comparisons(), tidy_avg_slopes(), tidy_ggpredict(), tidy_marginal_contrasts(), tidy_marginal_means(), tidy_marginal_predictions(), tidy_margins()

Examples


df <- Titanic |>
  dplyr::as_tibble() |>
  tidyr::uncount(n) |>
  dplyr::mutate(Survived = factor(Survived, c("No", "Yes")))
mod <- glm(
  Survived ~ Class + Age + Sex,
  data = df, family = binomial
)
tidy_all_effects(mod)
tidy_plus_plus(mod, tidy_fun = tidy_all_effects)


broom.helpers documentation built on Sept. 11, 2024, 6:31 p.m.