rating_factors {insurancerating}R Documentation

Include reference group in regression output

Description

Extract coefficients in terms of the original levels of the coefficients rather than the coded variables.

Usage

rating_factors(
  ...,
  model_data = NULL,
  exposure = NULL,
  exponentiate = TRUE,
  signif_stars = FALSE,
  round_exposure = 0
)

Arguments

...

glm object(s) produced by glm()

model_data

data.frame used to create glm object(s), this should only be specified in case the exposure is desired in the output, default value is NULL

exposure

column in model_data with exposure, default value is NULL

exponentiate

logical indicating whether or not to exponentiate the coefficient estimates. Defaults to TRUE.

signif_stars

show significance stars for p-values (defaults to TRUE)

round_exposure

number of digits for exposure (defaults to 0)

Details

A fitted linear model has coefficients for the contrasts of the factor terms, usually one less in number than the number of levels. This function re-expresses the coefficients in the original coding. This function is adopted from dummy.coef(). Our adoption prints a data.frame as output.

Value

data.frame

Author(s)

Martin Haringa

Examples

df <- MTPL2 |>
dplyr::mutate(dplyr::across(c(area), as.factor)) |>
dplyr::mutate(dplyr::across(c(area), ~biggest_reference(., exposure)))

mod1 <- glm(nclaims ~ area + premium, offset = log(exposure),
family = poisson(), data = df)
mod2 <- glm(nclaims ~ area, offset = log(exposure), family = poisson(),
data = df)

rating_factors(mod1, mod2, model_data = df, exposure = exposure)


[Package insurancerating version 0.7.4 Index]