GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - MHaringa/insurancerating: Actuarial building blocks for insurance pricing, tariff refinement and model validation in R

BranchesTags
Open more actions menu

Latest commit

 

History

341 Commits
341 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
R
R
 
 
data
data
 
 
inst
inst
 
 
man
man
 
 
pkgdown
pkgdown
 
 
tests
tests
 
 
vignettes
vignettes
 
 
.Rbuildignore
.Rbuildignore
 
 
.gitignore
.gitignore
 
 
DESCRIPTION
DESCRIPTION
 
 
NAMESPACE
NAMESPACE
 
 
NEWS.md
NEWS.md
 
 
README.Rmd
README.Rmd
 
 
README.md
README.md
 
 
_pkgdown.yml
_pkgdown.yml
 
 
cran-comments.md
cran-comments.md
 
 
insurancerating.Rproj
insurancerating.Rproj
 
 
logo.png
logo.png
 
 
logo_favicon.png
logo_favicon.png
 
 

Repository files navigation

insurancerating

CRAN Status Downloads

insurancerating provides actuarial building blocks for insurance pricing in R. Use them alongside standard modelling functions such as glm() to analyse portfolio experience, interpret fitted effects, turn them into implementable tariffs and validate predictions. The package also supports risk-factor structuring, large-loss treatment and preparation of large portfolios.

The building blocks can be used independently or combined to suit the portfolio. The examples illustrate choices, not a prescribed methodology.

Installation

Install the CRAN version, or install the development version from GitHub:

install.packages("insurancerating")

# install.packages("remotes")
remotes::install_github("MHaringa/insurancerating")

Explore portfolio experience

factor_analysis() summarises observed experience and the exposure supporting each level of a rating factor. These unadjusted portfolio patterns are useful before modelling, but should not be interpreted as conditional tariff relativities. Compare an apparent difference with the exposure and claim count behind it.

library(insurancerating)

portfolio <- as.data.frame(MTPL)
portfolio$zip <- factor(portfolio$zip)

zip_analysis <- factor_analysis(
  portfolio,
  risk_factors = "zip",
  claim_count = "nclaims",
  exposure = "exposure",
  claim_amount = "amount"
)

autoplot(
  zip_analysis,
  metrics = c("frequency", "average_severity", "risk_premium")
)

Factor analysis plot showing claim frequency, average severity and risk premium by ZIP code.

From model to refined tariff

An age-band GLM estimates one relativity per band. Here we use age decades where practical and pool ages 80 and above. A spline smooths the fitted effects, which are then translated into new tariff bands.

age_breaks <- c(18, 29, 39, 49, 59, 69, 79, 95)
portfolio$age_band <- cut(portfolio$age_policyholder, age_breaks,
                          include.lowest = TRUE)

frequency_model <- glm(
  nclaims ~ age_band + offset(log(exposure)),
  family = poisson(),
  data = portfolio
)

tariff_breaks <- c(18, 24, 30, 40, 55, 70, 79, 95)
proposal <- frequency_model |>
  prepare_refinement(data = portfolio) |>
  add_smoothing(
    "age_band", "age_policyholder",
    breaks = tariff_breaks, smoothing = "spline", k = 6, weights = "exposure"
  )

tariff <- refit(proposal, intercept_only = TRUE)
autoplot(proposal)

Original GLM relativities, a dashed spline and new tariff bands. All three rise at the oldest ages.

The blue steps are the original GLM estimates. The dashed curve is the smoothing proposal; the orange steps are the resulting tariff bands.

In this sample, the fitted frequency rises from 9.1 to 12.3 claims per 100 policy-years between ages 70–79 and 80+. The oldest band contains 36 claims, so treat the rise as a feature of this example rather than a general age effect.

refit() holds those band effects fixed and re-estimates the base claim rate, so their relativities do not move again. See the refinement example for how to inspect the fitted result.

What does insurancerating help with?

Pricing task Main tools
Explore portfolio experience factor_analysis(), outlier_histogram()
Structure continuous risk factors risk_factor_gam(), derive_tariff_segments()
Interpret fitted model effects rating_table(), add_factor_experience()
Refine tariff structures prepare_refinement(), add_smoothing(), add_restriction(), refit()
Validate fit, calibration and risk ranking model_performance(), calibration_analysis(), discrimination_analysis(), validate_performance()
Treat large losses assess_excess_threshold(), redistribute_excess_loss()
Reduce portfolio data locally rating_grid(), merge_date_ranges()
Reduce portfolios in a database rating_grid_db(), merge_date_ranges_db()

Where should I start?

  • Getting Started Follow one portfolio through risk-factor analysis, modelling, technical risk premium, interpretation, validation and refinement.

  • Pricing workflow and package building blocks See how the main actuarial pricing tasks and package components fit together.

  • Motor insurance case study Compare a fitted frequency model and candidate tariffs on a multi-year synthetic portfolio, including individual impact and a held-out year.

  • Refinement building blocks Translate estimated model effects into an explicit, reviewable and implementable tariff structure.

  • Model validation Assess model fit, stability and tariff plausibility, compare observed with expected claims, and evaluate predictions on later periods. Start with the quick start.

  • Large Portfolios Reduce production-sized portfolios with model-point aggregation and database-backed workflows.

Project information

  • Package website
  • CRAN package
  • Issue tracker
  • Citation information is available with citation("insurancerating").
  • The package is distributed under the GPL (>= 2) licence.

About

Actuarial building blocks for insurance pricing, tariff refinement and model validation in R

mharinga.github.io/insurancerating/

Topics

actuarialactuarial-scienceglminsuranceinsurance-pricingmodel-validationnon-life-insurancepricingrr-packagerisk-modellingtarriff

Resources

Readme
Activity

Stars

98 stars

Watchers

6 watching

Forks

22 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.