rating_table: Build rating tables from fitted pricing models

View source: R/model_rating_table.R

rating_tableR Documentation

Build rating tables from fitted pricing models

Description

rating_table() extracts model coefficients in tariff-table form. It adds the reference level for factor variables, can exponentiate GLM coefficients into relativities, and can add exposure by risk-factor level when the model data are available.

In pricing work, this function is useful after fitting or refining a GLM. It turns model output into a table that is easier to inspect, compare and use in tariff notes. When exponentiate = TRUE, coefficients are shown as relativities. This is often the most practical scale for multiplicative GLM tariffs, because each level is expressed relative to the reference level.

rating_table() is intended for fitted models:

  • plain glm objects

  • models obtained after refit()

  • models obtained after refit_glm()

For pre-refit objects (rating_refinement, restricted, smooth) use print(), summary() and autoplot() instead.

Usage

rating_table(
  ...,
  model_data = NULL,
  exposure = TRUE,
  exposure_output = NULL,
  exponentiate = TRUE,
  significance = FALSE,
  round_exposure = 0,
  exposure_name = NULL,
  signif_stars = NULL
)

Arguments

...

glm object(s) produced by glm(), refit() or refit_glm()

model_data

Optional data.frame used to create the model(s). If NULL, the function tries to use model$data for each supplied model.

exposure

Logical or character. If TRUE (default), exposure is added if it can be inferred from the model. If FALSE, no exposure is added. If a character string is supplied, it is interpreted as the exposure column name.

exposure_output

Optional name for the exposure column in the output. If NULL, the original exposure column name is used.

exponentiate

Logical. If TRUE (default), coefficients are exponentiated and shown as relativities. If FALSE, coefficients are shown on the model scale.

significance

Logical; if TRUE, show significance stars for p-values.

round_exposure

number of digits for exposure (defaults to 0)

exposure_name

Deprecated. Use exposure_output instead.

signif_stars

Deprecated. Use significance instead.

Details

A rating_table contains one row per model term level. For factor variables, the reference level is added explicitly with relativity 1 when exponentiate = TRUE, or coefficient 0 when exponentiate = FALSE.

If exposure is supplied or can be inferred from the model data, exposure is aggregated by risk-factor level. This helps to assess whether fitted relativities are supported by enough portfolio volume.

Multiple models can be supplied to compare fitted effects side by side. This is useful when comparing unrestricted and refined models, or frequency, severity and pure premium models built on the same rating factors.

Value

Object of class "rating_table" and legacy class "riskfactor".

See Also

as_gt() for a grouped presentation table and autoplot.rating_table() for a graphical comparison of fitted effects.

Examples

df <- MTPL
df$zip <- as.factor(df$zip)

freq <- glm(
  nclaims ~ bm + zip + offset(log(exposure)),
  family = poisson(),
  data = df
)

# Inspect fitted relativities by risk-factor level
rating_table(freq, model_data = df, exposure = "exposure")

# Keep coefficients on the model scale instead of exponentiating
rating_table(
  freq,
  model_data = df,
  exposure = "exposure",
  exponentiate = FALSE
)

# Add significance indicators when reviewing model terms
rating_table(
  freq,
  model_data = df,
  exposure = "exposure",
  significance = TRUE
)

# Compare two fitted models side by side
freq_simple <- glm(
  nclaims ~ bm + offset(log(exposure)),
  family = poisson(),
  data = df
)

rating_table(
  freq_simple,
  freq,
  model_data = df,
  exposure = FALSE
)


insurancerating documentation built on July 30, 2026, 5:09 p.m.