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

View source: R/get_predict.R

get_predictR Documentation

Get predicted values from a model object (internal function)

Description

Get predicted values from a model object (internal function)

Usage

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

## Default S3 method:
get_predict(model, newdata = insight::get_data(model), type = "response", ...)

## S3 method for class 'polr'
get_predict(model, newdata = insight::get_data(model), type = "probs", ...)

## S3 method for class 'glmmPQL'
get_predict(model, newdata = insight::get_data(model), type = "response", ...)

## S3 method for class 'MCMCglmm'
get_predict(model, newdata, type = "response", ndraws = 1000, ...)

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

## S3 method for class 'glimML'
get_predict(model, newdata = insight::get_data(model), type = "response", ...)

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

## S3 method for class 'bife'
get_predict(model, newdata = insight::get_data(model), type = "response", ...)

## S3 method for class 'biglm'
get_predict(model, newdata = insight::get_data(model), type = "response", ...)

## S3 method for class 'multinom'
get_predict(model, newdata = insight::get_data(model), type = "probs", ...)

## S3 method for class 'brmultinom'
get_predict(model, newdata = insight::get_data(model), type = "probs", ...)

## S3 method for class 'brmsfit'
get_predict(model, newdata = insight::get_data(model), type = "response", ...)

## S3 method for class 'crch'
get_predict(model, newdata = NULL, type = "location", ...)

## S3 method for class 'fixest'
get_predict(model, newdata = insight::get_data(model), type = "response", ...)

## S3 method for class 'gamlss'
get_predict(model, newdata = insight::get_data(model), type = "response", ...)

## S3 method for class 'glmmTMB'
get_predict(model, newdata = insight::get_data(model), type = "response", ...)

## S3 method for class 'inferences_simulation'
get_predict(model, newdata, ...)

## S3 method for class 'merMod'
get_predict(model, newdata = insight::get_data(model), type = "response", ...)

## S3 method for class 'lmerModLmerTest'
get_predict(model, newdata = insight::get_data(model), type = "response", ...)

## S3 method for class 'lmerMod'
get_predict(model, newdata = insight::get_data(model), type = "response", ...)

## S3 method for class 'mblogit'
get_predict(model, newdata = insight::get_data(model), type = "response", ...)

## S3 method for class 'mhurdle'
get_predict(model, newdata = insight::get_data(model), type = "response", ...)

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

## S3 method for class 'Learner'
get_predict(model, newdata, type = NULL, ...)

## S3 method for class 'clm'
get_predict(model, newdata = insight::get_data(model), type = "prob", ...)

## S3 method for class 'rq'
get_predict(model, newdata = insight::get_data(model), type = NULL, ...)

## S3 method for class 'rms'
get_predict(model, newdata = insight::get_data(model), type = NULL, ...)

## S3 method for class 'orm'
get_predict(model, newdata = insight::get_data(model), type = NULL, ...)

## S3 method for class 'lrm'
get_predict(model, newdata = insight::get_data(model), type = NULL, ...)

## S3 method for class 'ols'
get_predict(model, newdata = insight::get_data(model), type = NULL, ...)

## S3 method for class 'rlmerMod'
get_predict(model, newdata = insight::get_data(model), type = "response", ...)

## S3 method for class 'stanreg'
get_predict(model, newdata = insight::get_data(model), type = "response", ...)

## S3 method for class 'lm'
get_predict(model, newdata = insight::get_data(model), type = "response", ...)

## S3 method for class 'glm'
get_predict(model, newdata = insight::get_data(model), type = "response", ...)

## S3 method for class 'svyolr'
get_predict(model, newdata = insight::get_data(model), type = "probs", ...)

## S3 method for class 'coxph'
get_predict(model, newdata = insight::get_data(model), type = "lp", ...)

## S3 method for class 'model_fit'
get_predict(model, newdata, type = NULL, ...)

## S3 method for class 'workflow'
get_predict(model, newdata, type = NULL, ...)

## S3 method for class 'tobit1'
get_predict(model, newdata = insight::get_data(model), type = "response", ...)

Arguments

model

Model object

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.

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

type

string indicates the type (scale) of the predictions used to compute contrasts or slopes. 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 first entry in the error message is used by default.

...

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.

Value

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


marginaleffects documentation built on Oct. 20, 2023, 1:07 a.m.