glm_predict: GLM Predict

Description Usage Arguments Value Examples

View source: R/glm_predict.R

Description

Create a Generalised Linear Model (glm) from a dataset and a given set of variables, then make predictions from the model, either on the original data or a new dataset.

Usage

1
2
3
4
5
6
7
8
9
glm_predict(
  model,
  target,
  pos_class = 1,
  neg_class = 0,
  threshold = 0.5,
  newdata = NULL,
  ...
)

Arguments

model

Fitted glm model object

target

Target name (must be present as a column in the model object). This is the y variable when creating a glm.

pos_class

Positive class label. default=1. Like the y value in glm, this must be between 0 and 1.

neg_class

Negative class label. default=0. Like the y value in glm, this must be between 0 and 1.

threshold

Probability threshold for predicting positive class. Must be between 0 and 1 (exclusive). default=0.5.

newdata

New data to make predictions on. By default, glm_predict predicts on the original data used to create the model. default=NULL.

...

Other parameters to be passed into the augment function for making predictions.

Value

Augment object with a column .prediction that contains the predicted class for each example.

Examples

1
2
3
4
require(dplyr)
cancer_model <- glm(malignant ~ texture_mean, data=cancer_clean, family="quasibinomial")
glm_predict(cancer_model, "malignant")
glm_predict(cancer_model, "malignant", threshold=0.8)

janetxinli/glmPredict documentation built on Jan. 1, 2021, 4:28 a.m.