get_marginaleffects {modelbased}R Documentation

Easy marginaleffects

Description

Modelbased-like API to create marginaleffects objects. This is Work-in-progress.

Usage

get_marginaleffects(
  model,
  trend = NULL,
  by = NULL,
  fixed = NULL,
  at = NULL,
  ...
)

Arguments

model

A statistical model.

trend

A character indicating the name of the variable for which to compute the slopes.

by

The predictor variable(s) at which to evaluate the desired effect / mean / contrasts. Other predictors of the model that are not included here will be collapsed and "averaged" over (the effect will be estimated across them).

fixed

A character vector indicating the names of the predictors to be "fixed" (i.e., maintained), so that the estimation is made at these values.

at

Deprecated, use by instead.

...

Other arguments passed for instance to insight::get_datagrid().

Examples

if (require("marginaleffects")) {
  model <- lm(Sepal.Width ~ Species * Petal.Length, data = iris)

  get_marginaleffects(model, trend = "Petal.Length", by = "Species")
  get_marginaleffects(model, trend = "Petal.Length", by = "Petal.Length")
  get_marginaleffects(model, trend = "Petal.Length", by = c("Species", "Petal.Length"))
}

[Package modelbased version 0.8.8 Index]