{"id":14067117,"url":"https://github.com/problemofpoints/reservetestr","last_synced_at":"2025-07-30T00:32:26.115Z","repository":{"id":217206870,"uuid":"113703721","full_name":"problemofpoints/reservetestr","owner":"problemofpoints","description":"Provides a Framework for Testing Loss Reserve Methods","archived":false,"fork":false,"pushed_at":"2019-12-27T19:02:29.000Z","size":4600,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-12-04T07:36:36.693Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://reservetestr.netlify.com","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/problemofpoints.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-12-09T21:50:38.000Z","updated_at":"2021-12-06T03:21:07.000Z","dependencies_parsed_at":"2024-01-15T02:29:58.283Z","dependency_job_id":"1247034f-e43a-42e9-8ba5-821683301357","html_url":"https://github.com/problemofpoints/reservetestr","commit_stats":null,"previous_names":["problemofpoints/reservetestr"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/problemofpoints/reservetestr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/problemofpoints%2Freservetestr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/problemofpoints%2Freservetestr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/problemofpoints%2Freservetestr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/problemofpoints%2Freservetestr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/problemofpoints","download_url":"https://codeload.github.com/problemofpoints/reservetestr/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/problemofpoints%2Freservetestr/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267785752,"owners_count":24144121,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-29T02:00:12.549Z","response_time":2574,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-13T07:05:26.494Z","updated_at":"2025-07-30T00:32:25.560Z","avatar_url":"https://github.com/problemofpoints.png","language":"R","funding_links":[],"categories":["R"],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n\u003c!-- badges: start --\u003e\n[![Travis build status](https://travis-ci.org/problemofpoints/reservetestr.svg?branch=master)](https://travis-ci.org/problemofpoints/reservetestr)\n[![AppVeyor build status](https://ci.appveyor.com/api/projects/status/github/problemofpoints/reservetestr?branch=master\u0026svg=true)](https://ci.appveyor.com/project/problemofpoints/reservetestr)\n[![lifecycle](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://www.tidyverse.org/lifecycle/#maturing)\n[![Coverage status](https://codecov.io/gh/problemofpoints/reservetestr/branch/master/graph/badge.svg)](https://codecov.io/github/problemofpoints/reservetestr?branch=master)\n\u003c!-- badges: end --\u003e\n\n```{r setup, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n\n```\n\n# reservetestr\n\nThe 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](http://www.casact.org/research/index.cfm?fa=loss_reserves_data) is provided.\n\n## Installation\n\nYou can install reservetestr from GitHub with:\n\n```{r gh-installation, eval = FALSE}\n# install.packages(\"devtools\")\ndevtools::install_github(\"problemofpoints/reservetestr\", upgrade_dependencies = FALSE)\n```\n\n## Example Usage\n\n```{r import-libraries, warning=FALSE}\nlibrary(reservetestr)\nsuppressPackageStartupMessages(library(ChainLadder))\nlibrary(dplyr)\nlibrary(tidyr)\nlibrary(purrr)\nlibrary(ggplot2)\n\nreservetestr::ggSetTheme()\n```\n\n## CAS Loss Reserve Database\n\nFrom the [CAS website](http://www.casact.org/research/index.cfm?fa=loss_reserves_data):\n\n\u003e \"Our goal is to prepare a clean and nice data set of loss triangles that could be used for claims reserving studies.\nThe data includes major personal and commercial lines of business from U.S. property casualty insurers.\nThe claims data comes from Schedule P - Analysis of Losses and Loss Expenses\nin the National Association of Insurance Commissioners (NAIC) database.\"\n\nBelow 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.\n\n```{r sample-data-train, fig.cap=\"Sampe Paid Loss Triangle - Training data\"}\ncas_loss_reserve_db %\u003e%\n  get_meyers_subset(edition = 2) %\u003e%\n  filter(line == \"ppauto\" \u0026 group_id == 388) %\u003e%\n  pluck(\"train_tri_set\", 1, \"paid\")\n```\n\nThe 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\".\n\n```{r subset-data, fig.cap=\"Summary of Triangles by Line\"}\ncas_db_subset \u003c- cas_loss_reserve_db %\u003e%\n  get_meyers_subset(edition = 2)\n```\n\nThe main function is `run_single_backtest` which, in this example, runs the `ChainLadder::MackChainLadder` method on each paid loss triangle. \n\n```{r backtest-mack, warning=FALSE, message=FALSE, echo=TRUE}\nmack_paid_results \u003c- run_single_backtest(cas_db_subset, \n                                         testr_MackChainLadder, \n                                         lines_to_include = \"comauto\",\n                                         loss_type_to_backtest = \"paid\", \n                                         method_label = \"mack_paid\")\n```\n\nThe output provided is the below. \n\n```{r mack-glimpse}\nglimpse(mack_paid_results)\n```\n\nWe 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.\n\nThat is not the case in this example, so for \"comauto\" the Mack method applied to paid data does not back-test well.\n\n```{r mack-exhibits-pp}\ncreate_pp_plot(mack_paid_results, by_line = TRUE)\n```\n\n## Future Enhancements\n\n- Add error metrics for deterministic methods\n- Create an object structure using S3 class system\n- Add more error handling\n- Add `testr_` functions for the other methods in `ChainLadder`\n- Add ability to test several methods at once\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fproblemofpoints%2Freservetestr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fproblemofpoints%2Freservetestr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fproblemofpoints%2Freservetestr/lists"}