if (FALSE) {
library(marginaleffects)
library(magrittr)
set.seed(1024)
mod <- lm(Sepal.Length ~ Sepal.Width * Species, data = iris)
# bootstrap
avg_predictions(mod, by = "Species") %>%
    inferences(method = "boot")
avg_predictions(mod, by = "Species") %>%
    inferences(method = "rsample")
# Fractional (bayesian) bootstrap
avg_slopes(mod, by = "Species") %>%
    inferences(method = "fwb") %>%
    get_draws("rvar") %>%
    data.frame()
# Simulation-based inference
slopes(mod) %>%
    inferences(method = "simulation") %>%
    head()
}
Run the code above in your browser using DataLab