get_marginaleffects: Easy marginaleffects

View source: R/get_marginaleffects.R

get_marginaleffectsR Documentation

Easy marginaleffects

Description

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

Usage

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

Arguments

model

A statistical model.

trend

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

at

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.

...

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", at = "Species")
  get_marginaleffects(model, trend = "Petal.Length", at = "Petal.Length")
  get_marginaleffects(model, trend = "Petal.Length", at = c("Species", "Petal.Length"))
}

easystats/estimate documentation built on April 30, 2024, 5:12 p.m.