Method to raise model-specific warnings and errors
# S3 method for glimML
sanitize_model_specific(model, ...)# S3 method for betareg
sanitize_model_specific(model, ...)
sanitize_model_specific(model, ...)
# S3 method for default
sanitize_model_specific(
model,
vcov = NULL,
calling_function = "marginaleffects",
...
)
# S3 method for brmsfit
sanitize_model_specific(model, ...)
# S3 method for bart
sanitize_model_specific(model, ...)
# S3 method for glmmTMB
sanitize_model_specific(model, vcov = TRUE, re.form, ...)
# S3 method for merMod
sanitize_model_specific(model, re.form, ...)
# S3 method for mblogit
sanitize_model_specific(model, calling_function = "marginaleffects", ...)
# S3 method for mlogit
sanitize_model_specific(model, ...)
# S3 method for clm
sanitize_model_specific(model, ...)
# S3 method for plm
sanitize_model_specific(model, ...)
# S3 method for plm
sanitize_model_specific(model, ...)
# S3 method for rqs
sanitize_model_specific(model, ...)
# S3 method for svyolr
sanitize_model_specific(model, wts = FALSE, by = FALSE, ...)
# S3 method for svyglm
sanitize_model_specific(model, wts = FALSE, by = FALSE, ...)
A warning, an error, or nothing
Model object
Additional arguments are passed to the predict()
method
supplied by the modeling package.These arguments are particularly useful
for mixed-effects or bayesian models (see the online vignettes on the
marginaleffects
website). Available arguments can vary from model to
model, depending on the range of supported arguments by each modeling
package. See the "Model-Specific Arguments" section of the
?slopes
documentation for a non-exhaustive list of available
arguments.
Type of uncertainty estimates to report (e.g., for robust standard errors). Acceptable values:
FALSE: Do not compute standard errors. This can speed up computation considerably.
TRUE: Unit-level standard errors using the default vcov(model)
variance-covariance matrix.
String which indicates the kind of uncertainty estimates to return.
Heteroskedasticity-consistent: "HC"
, "HC0"
, "HC1"
, "HC2"
, "HC3"
, "HC4"
, "HC4m"
, "HC5"
. See ?sandwich::vcovHC
Heteroskedasticity and autocorrelation consistent: "HAC"
Mixed-Models degrees of freedom: "satterthwaite", "kenward-roger"
Other: "NeweyWest"
, "KernHAC"
, "OPG"
. See the sandwich
package documentation.
One-sided formula which indicates the name of cluster variables (e.g., ~unit_id
). This formula is passed to the cluster
argument of the sandwich::vcovCL
function.
Square covariance matrix
Function which returns a covariance matrix (e.g., stats::vcov(model)
)
logical, string or numeric: weights to use when computing average predictions, contrasts or slopes. These weights only affect the averaging in avg_*()
or with the by
argument, and not unit-level estimates. See ?weighted.mean
string: column name of the weights variable in newdata
. When supplying a column name to wts
, it is recommended to supply the original data (including the weights variable) explicitly to newdata
.
numeric: vector of length equal to the number of rows in the original data or in newdata
(if supplied).
FALSE: Equal weights.
TRUE: Extract weights from the fitted object with insight::find_weights()
and use them when taking weighted averages of estimates. Warning: newdata=datagrid()
returns a single average weight, which is equivalent to using wts=FALSE
Aggregate unit-level estimates (aka, marginalize, average over). Valid inputs:
FALSE
: return the original unit-level estimates.
TRUE
: aggregate estimates for each term.
Character vector of column names in newdata
or in the data frame produced by calling the function without the by
argument.
Data frame with a by
column of group labels, and merging columns shared by newdata
or the data frame produced by calling the same function without the by
argument.
See examples below.
For more complex aggregations, you can use the FUN
argument of the hypotheses()
function. See that function's documentation and the Hypothesis Test vignettes on the marginaleffects
website.