Skip to contents

Add model predictions and confidence bounds to a data frame.

Usage

add_prediction(data, ..., var = NULL, conf_int = FALSE, alpha = 0.1)

Arguments

data

a data frame of new data.

...

one or more objects of class glm.

var

the name of the output column(s), defaults to NULL

conf_int

determines whether confidence intervals will be shown. Defaults to conf_int = FALSE.

alpha

a real number between 0 and 1. Controls the confidence level of the interval estimates (defaults to 0.10, representing 90 percent confidence interval).

Value

data.frame

Examples

mod1 <- glm(nclaims ~ age_policyholder, data = MTPL,
    offset = log(exposure), family = poisson())
mtpl_pred <- add_prediction(MTPL, mod1)

# Include confidence bounds
mtpl_pred_ci <- add_prediction(MTPL, mod1, conf_int = TRUE)