get_model_matrix {marginaleffects}R Documentation

Get a named model matrix

Description

Get a named model matrix

Usage

get_model_matrix(model, newdata)

## Default S3 method:
get_model_matrix(object, newdata)

Arguments

model

Model object

newdata

Grid of predictor values at which we evaluate the slopes.

  • NULL (default): Unit-level slopes for each observed value in the original dataset.

  • data frame: Unit-level slopes for each row of the newdata data frame.

  • datagrid() call to specify a custom grid of regressors. For example:

    • newdata = datagrid(cyl = c(4, 6)): cyl variable equal to 4 and 6 and other regressors fixed at their means or modes.

    • See the Examples section and the datagrid() documentation.

  • string:

    • "mean": Marginal Effects at the Mean. Slopes when each predictor is held at its mean or mode.

    • "median": Marginal Effects at the Median. Slopes when each predictor is held at its median or mode.

    • "marginalmeans": Marginal Effects at Marginal Means. See Details section below.

    • "tukey": Marginal Effects at Tukey's 5 numbers.

    • "grid": Marginal Effects on a grid of representative numbers (Tukey's 5 numbers and unique values of categorical predictors).


[Package marginaleffects version 0.11.1 Index]