anchor.predictions: Generate Predictions for a Model

View source: R/helper_estimates.R

anchor.predictionsR Documentation

Generate Predictions for a Model

Description

Generate Predictions for a Model

Usage

anchor.predictions(model, reference, shutup = F)

Arguments

model

The fitted model object to generate predictions

reference

A vector (or single value) containing the name of the variable(s) the user wishes to generate predictions for. For categorical variables, the function will generate predictions for every level of the categorical variable. For numeric variables, the function will generate predictions at +1 and -1 standard deviations away from the mean.

shutup

The function will give a notice if you don't specify predictions for variables that are in the model. This argument tell it to shut up.

Details

This function is simply an easy-to-use wrapper for the predict function. With some models (e.g., logistic regression), the metrics are not very intuitive. The anchor.predictions model generates the actual predicted values, depending on what the user specifies.

Value

A data frame containing the predicted values (along with the values of the predictor variables used to estimate the prediction)

A data frame containing predictions

Author(s)

Dustin Fife

Examples

data(exercise_data)
linear.model = lm(weight.loss~health + gender, data= exercise_data)
# generate predictions for males/females
anchor.predictions(linear.model, "gender")
# generate predictions for health (+/- 1 sd from the mean)
anchor.predictions(linear.model, "health")
# fit a logistic regression model
data(tablesaw.injury)
glm.mod = glm(injury~safety + attention + gender, data= tablesaw.injury, family=binomial)
anchor.predictions(glm.mod, "attention")
anchor.predictions(glm.mod, c("safety", "gender"))

dustinfife/flexplot documentation built on Sept. 23, 2024, 9:01 p.m.