Travis build status AppVeyor build status lifecycle Coverage status

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

reservetestr

The goal of reservetestr is to provide a framework for testing loss reserve methods. Specifically, an interface to test methods against the Casualty Actuarial Society (CAS) Loss Reserve Database is provided.

Installation

You can install reservetestr from GitHub with:

# install.packages("devtools")
devtools::install_github("problemofpoints/reservetestr", upgrade_dependencies = FALSE)

Example Usage

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

reservetestr::ggSetTheme()

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(edition = 2) %>%
  filter(line == "ppauto" & group_id == 388) %>%
  pluck("train_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. For this example, we will only use "comauto".

cas_db_subset <- cas_loss_reserve_db %>%
  get_meyers_subset(edition = 2)

The main function is run_single_backtest which, in this example, runs the ChainLadder::MackChainLadder method on each paid loss triangle.

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)

Future Enhancements



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