Learn R Programming

marginaleffects (version 0.8.1)

get_predict: Get predicted values from a model object (internal function)

Description

Get predicted values from a model object (internal function)

Usage

get_predict(model, newdata, vcov, conf_level, type, ...)

# S3 method for default get_predict( model, newdata = insight::get_data(model), vcov = FALSE, conf_level = 0.95, type = "response", ... )

# S3 method for polr get_predict( model, newdata = insight::get_data(model), vcov = FALSE, conf_level = 0.95, type = "probs", ... )

# S3 method for glmmPQL get_predict( model, newdata = insight::get_data(model), vcov = FALSE, conf_level = 0.95, type = "response", ... )

# S3 method for afex_aov get_predict(model, newdata = NULL, ...)

# S3 method for glimML get_predict( model, newdata = insight::get_data(model), vcov = FALSE, conf_level = 0.95, type = "response", ... )

# S3 method for betareg get_predict(model, newdata, ...)

# S3 method for bife get_predict( model, newdata = insight::get_data(model), vcov = FALSE, conf_level = 0.95, type = "response", ... )

# S3 method for biglm get_predict( model, newdata = insight::get_data(model), vcov = FALSE, conf_level = 0.95, type = "response", ... )

# S3 method for multinom get_predict( model, newdata = insight::get_data(model), vcov = FALSE, conf_level = 0.95, type = "probs", ... )

# S3 method for brmultinom get_predict( model, newdata = insight::get_data(model), vcov = FALSE, conf_level = 0.95, type = "probs", ... )

# S3 method for brmsfit get_predict( model, newdata = insight::get_data(model), vcov = FALSE, conf_level = 0.95, type = "response", ... )

# S3 method for crch get_predict( model, newdata = NULL, vcov = FALSE, conf_level = 0.95, type = "location", ... )

# S3 method for fixest get_predict( model, newdata = insight::get_data(model), vcov = FALSE, conf_level = 0.95, type = "response", ... )

# S3 method for gamlss get_predict( model, newdata = insight::get_data(model), vcov = FALSE, conf_level = 0.95, type = "response", ... )

# S3 method for glmmTMB get_predict( model, newdata = insight::get_data(model), vcov = FALSE, conf_level = 0.95, type = "response", ... )

# S3 method for merMod get_predict( model, newdata = insight::get_data(model), vcov = FALSE, conf_level = 0.95, type = "response", ... )

# S3 method for lmerModLmerTest get_predict( model, newdata = insight::get_data(model), vcov = FALSE, conf_level = 0.95, type = "response", ... )

# S3 method for lmerMod get_predict( model, newdata = insight::get_data(model), vcov = FALSE, conf_level = 0.95, type = "response", ... )

# S3 method for mblogit get_predict( model, newdata = insight::get_data(model), vcov = FALSE, conf_level = 0.95, type = "response", ... )

# S3 method for mhurdle get_predict( model, newdata = insight::get_data(model), vcov = NULL, conf_level = 0.95, type = "response", ... )

# S3 method for mlogit get_predict(model, newdata, ...)

# S3 method for clm get_predict( model, newdata = insight::get_data(model), vcov = FALSE, conf_level = 0.95, type = "response", ... )

# S3 method for rq get_predict( model, newdata = insight::get_data(model), vcov = NULL, conf_level = 0.95, type = NULL, ... )

# S3 method for rlmerMod get_predict( model, newdata = insight::get_data(model), vcov = FALSE, conf_level = 0.95, type = "response", ... )

# S3 method for stanreg get_predict( model, newdata = insight::get_data(model), vcov = FALSE, conf_level = 0.95, type = "response", ... )

# S3 method for coxph get_predict( model, newdata = insight::get_data(model), vcov = FALSE, conf_level = 0.95, type = "lp", ... )

# S3 method for tobit1 get_predict( model, newdata = insight::get_data(model), vcov = NULL, conf_level = 0.95, type = "response", ... )

Value

A data.frame of predicted values with a number of rows equal to the number of rows in newdata and columns "rowid" and "predicted". A "group" column is added for multivariate models or models with categorical outcomes.

Arguments

model

Model object

newdata

NULL, data frame, string, or datagrid() call. Determines the predictor values for which to compute marginal effects.

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

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

  • string:

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

    • "median": Marginal Effects at the Median. Marginal effects 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).

  • 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.

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: 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))

conf_level

numeric value between 0 and 1. Confidence level to use to build a confidence interval.

type

string indicates the type (scale) of the predictions used to compute marginal effects or contrasts. This can differ based on the model type, but will typically be a string such as: "response", "link", "probs", or "zero". When an unsupported string is entered, the model-specific list of acceptable values is returned in an error message. When type is NULL, the default value is used. This default is the first model-related row in the marginaleffects:::type_dictionary dataframe.

...

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 ?marginaleffects documentation for a non-exhaustive list of available arguments.