newdata |
Grid of predictor values at which we evaluate the slopes.
Warning: Please avoid modifying your dataset between fitting the model and calling a marginaleffects function. This can sometimes lead to unexpected results.
-
NULL (default): Unit-level slopes for each observed value in the dataset (empirical distribution). The dataset is retrieved using insight::get_data() , which tries to extract data from the environment. This may produce unexpected results if the original data frame has been altered since fitting the model.
-
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.
-
subset() call with a single argument to select a subset of the dataset used to fit the model, ex: newdata = subset(treatment == 1)
-
dplyr::filter() call with a single argument to select a subset of the dataset used to fit the model, ex: newdata = filter(treatment == 1)
string:
"mean": Slopes evaluated when each predictor is held at its mean or mode.
"median": Slopes evaluated when each predictor is held at its median or mode.
"balanced": Slopes evaluated on a balanced grid with every combination of categories and numeric variables held at their means.
"tukey": Slopes evaluated at Tukey's 5 numbers.
"grid": Slopes evaluated on a grid of representative numbers (Tukey's 5 numbers and unique values of categorical predictors).
|