sanitize_model_specific.glimML  R Documentation 
Method to raise modelspecific warnings and errors
Description
Method to raise modelspecific warnings and errors
Usage
## S3 method for class 'glimML'
sanitize_model_specific(model, ...)
## S3 method for class 'betareg'
sanitize_model_specific(model, ...)
sanitize_model_specific(model, ...)
## Default S3 method:
sanitize_model_specific(
model,
vcov = NULL,
calling_function = "marginaleffects",
...
)
## S3 method for class 'brmsfit'
sanitize_model_specific(model, ...)
## S3 method for class 'bart'
sanitize_model_specific(model, ...)
## S3 method for class 'glmmTMB'
sanitize_model_specific(model, vcov = TRUE, re.form = NULL, ...)
## S3 method for class 'merMod'
sanitize_model_specific(model, re.form = NULL, ...)
## S3 method for class 'mblogit'
sanitize_model_specific(model, calling_function = "marginaleffects", ...)
## S3 method for class 'mlogit'
sanitize_model_specific(model, newdata, ...)
## S3 method for class 'clm'
sanitize_model_specific(model, ...)
## S3 method for class 'plm'
sanitize_model_specific(model, ...)
## S3 method for class 'plm'
sanitize_model_specific(model, ...)
## S3 method for class 'rqs'
sanitize_model_specific(model, ...)
## S3 method for class 'svyolr'
sanitize_model_specific(model, wts = FALSE, by = FALSE, ...)
## S3 method for class 'svyglm'
sanitize_model_specific(model, wts = FALSE, by = FALSE, ...)
Arguments
model 
Model object

... 
Additional arguments are passed to the predict() method
supplied by the modeling package.These arguments are particularly useful
for mixedeffects 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 "ModelSpecific Arguments" section of the
?slopes documentation for a nonexhaustive list of available
arguments.

vcov 
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: Unitlevel standard errors using the default vcov(model) variancecovariance matrix.
String which indicates the kind of uncertainty estimates to return.
Heteroskedasticityconsistent: "HC" , "HC0" , "HC1" , "HC2" , "HC3" , "HC4" , "HC4m" , "HC5" . See ?sandwich::vcovHC
Heteroskedasticity and autocorrelation consistent: "HAC"
MixedModels degrees of freedom: "satterthwaite", "kenwardroger"
Other: "NeweyWest" , "KernHAC" , "OPG" . See the sandwich package documentation.
Onesided 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) )

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): Unitlevel 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": 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).

wts 
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 unitlevel 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

by 
Aggregate unitlevel estimates (aka, marginalize, average over). Valid inputs:

FALSE : return the original unitlevel 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.

Value
A warning, an error, or nothing