R: Get marginal effects for all model predictors

ggalleffects {ggeffects} | R Documentation

## Get marginal effects for all model predictors

### Description

`ggalleffects()` computes marginal effects of model terms. It internally calls `allEffects` and puts the result into tidy data frames.

### Usage

    ggalleffects(model, terms = NULL, ci.lvl = 0.95, ...)

### Arguments

`model` | A fitted model object, or a list of model objects. Any model that is supported by the effects-package should work.
`terms` | Character vector with term names of selected variables from `model`, which should be used to compute marginal effects. If `terms = NULL`, marginal effects for all model terms are returned.
`ci.lvl` | Numeric, the level of the confidence intervals. For `ggpredict()`, use `ci.lvl = NA`, if confidence intervals should not be calculated (for instance, due to computation time).
`...` | Further arguments passed down to `allEffects`.

### Value

A list of tibbles (with `ggeffects` class attribute) with consistent data columns. The list contains one tibble per model term. Columns are:

`x`

  the values of the model predictor to which the effect pertains, used as x-position in plots.

`predicted`

  the predicted values, used as y-position in plots.

`conf.low`

  the lower bound of the confidence interval for the predicted values.

`conf.high`

  the upper bound of the confidence interval for the predicted values.

### Note

Interaction effects are not included in the return value, i.e. `ggalleffects()` does not compute marginal effects for interaction terms. Use `gginteraction` to create tidy data frames especially for interaction terms.

### Examples

    data(efc)
    fit <- lm(barthtot ~ c12hour + neg_c_7 + c161sex + c172code, data = efc)
    ggalleffects(fit)

    library(ggplot2)
    fit <- lm(barthtot ~ c12hour + neg_c_7 + c160age, data = efc)
    mydf <- get_complete_df(ggalleffects(fit))

    ggplot(mydf, aes(x, predicted)) +
      geom_line() +
      facet_wrap(~group, scale = "free_x", ncol = 1)

[Package ggeffects version 0.4.0 Index]