View source: R/model_rating_factors.R
rating_factors | R Documentation |
Extract coefficients in terms of the original levels of the coefficients rather than the coded variables.
rating_factors( ..., model_data = NULL, exposure = NULL, exponentiate = TRUE, signif_stars = TRUE, round_exposure = 0 )
... |
glm object(s) produced by |
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 |
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) |
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.
data.frame
Martin Haringa
library(dplyr) df <- MTPL2 %>% mutate(across(c(area), as.factor)) %>% mutate(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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.