knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

library(reservetestr)
suppressPackageStartupMessages(library(ChainLadder))
library(dplyr)
library(tidyr)
library(purrr)
library(ggplot2)


ggSetTheme()

This vignette shows how to use the reservetestr package to back-test the Mack Method on the CAS Loss Reserve database.

CAS Loss Reserve Database

From the CAS website:

"Our goal is to prepare a clean and nice data set of loss triangles that could be used for claims reserving studies. The data includes major personal and commercial lines of business from U.S. property casualty insurers. The claims data comes from Schedule P - Analysis of Losses and Loss Expenses in the National Association of Insurance Commissioners (NAIC) database."

Below is an example paid loss triangle from the database. The first triangle is the upper triangle used to fit the model. The second triangle is the actual lower right of the triangle used for model validation / testing.

cas_loss_reserve_db %>%
  get_meyers_subset() %>%
  filter(line == "ppauto" & group_id == 388) %>%
  pluck("train_tri_set", 1, "paid")
cas_loss_reserve_db %>%
  get_meyers_subset() %>%
  filter(line == "ppauto" & group_id == 388) %>%
  pluck("test_tri_set", 1, "paid")

The back-testing results use a subset of the full database, resulting in 50 triangles across four lines of business - comauto, othliab, ppauto, wkcomp.

cas_db_subset <- cas_loss_reserve_db %>%
  get_meyers_subset()

cas_db_subset %>%
  group_by(line) %>%
  summarise(`# of Companies` = n()) %>%
  knitr::kable()

Back-testing

Now we can run the Mack method on our triangle training data and back-test its accuracy. We use the implementation of the Mack method in the ChainLadder package, MackChainLadder, applied to the comauto line of business.

mack_paid_results <- run_single_backtest(cas_db_subset, 
                                         testr_MackChainLadder, 
                                         lines_to_include = "comauto",
                                         loss_type_to_backtest = "paid", 
                                         method_label = "mack_paid")

The output provided is the below.

glimpse(mack_paid_results)

We can create a p-p plot to visually access the accuracy of our estimates. If our method was perfect, we would expect to see the dots fall along the 45 degree line - indicating that our implied percentiles are perfectly uniform.

That is not the case in this example, so for "comauto" the Mack method applied to paid data does not back-test well.

create_pp_plot(mack_paid_results, by_line = TRUE)

We can also graph the histogram of our implied percentiles to check whether they are uniformily distributed.

create_histogram_plot(mack_paid_results, by_line = TRUE, bin_number = 10)


problemofpoints/reservetestr documentation built on Jan. 3, 2020, 9:12 a.m.