README.md

LDTr

Introduction

A loss development triangle (LDT) is a table that shows changes in the values of a set of claims over time.

As an Actuary, utilizing loss development triangles is one of the first steps for an actuarial analysis. However, for efficiency reasons, the structure of the data is not stored in a triangular format which adds an additional layer of complexity.

The LDTr package is designed to simplify the use of this data structure by providing the following features:

Installation

The development version can be installed using:

# install.packages("devtools")
devtools::install_github("m-montero/LDTr")

Warning: This package is not at a stable state and is subject to major updates. Please use with caution.

Getting Started

After installing the package, load "LDTr". The "LDTr" package depends on both the "dplyr" and "tidyr" packages.

library(LDTr)

Sample Dataset

Run off triangle of incremental claims data in the traditional data format.

data(RAA,package="LDTr")
head(RAA, n = 20)
##    origin dev value
## 1    1981   1  5012
## 2    1982   1   106
## 3    1983   1  3410
## 4    1984   1  5655
## 5    1985   1  1092
## 6    1986   1  1513
## 7    1987   1   557
## 8    1988   1  1351
## 9    1989   1  3133
## 10   1990   1  2063
## 11   1981   2  3257
## 12   1982   2  4179
## 13   1983   2  5582
## 14   1984   2  5900
## 15   1985   2  8473
## 16   1986   2  4932
## 17   1987   2  3463
## 18   1988   2  5596
## 19   1989   2  2262
## 20   1990   2    NA

tbl_tri()

Transform the dataset to a triangle while maintaining the current structure of the data.

RAA %>% tbl_tri(type = "Incremental")
## # A triangle: 10 x 11
##  origin    1    2    3    4    5    6    7   8   9  10
##    1981 5012 3257 2638  898 1734 2642 1828 599  54 172
##    1982  106 4179 1111 5270 3116 1817 -103 673 535   *
##    1983 3410 5582 4881 2268 2594 3479  649 603   *   *
##    1984 5655 5900 4211 5500 2159 2658  984   *   *   *
##    1985 1092 8473 6271 6333 3786  225    *   *   *   *
##    1986 1513 4932 5257 1233 2917    *    *   *   *   *
##    1987  557 3463 6926 1368    *    *    *   *   *   *
##    1988 1351 5596 6165    *    *    *    *   *   *   *
##    1989 3133 2262    *    *    *    *    *   *   *   *
##    1990 2063    *    *    *    *    *    *   *   *   *
## #
## 
## # A tibble: 100 x 3
##    origin   dev TRI_INC
##     <int> <int>   <int>
## 1    1981     1    5012
## 2    1982     1     106
## 3    1983     1    3410
## 4    1984     1    5655
## 5    1985     1    1092
## 6    1986     1    1513
## 7    1987     1     557
## 8    1988     1    1351
## 9    1989     1    3133
## 10   1990     1    2063
## # ... with 90 more rows

transform()

Transform the dataset from an "Incremental" triangle to a "Cumulative" triangle.

RAA %>% tbl_tri(type = "Incremental") %>% transform(type = "Cumulative")
## # A triangle: 10 x 11
##  origin    1     2     3     4     5     6     7     8     9    10
##    1981 5012  8269 10907 11805 13539 16181 18009 18608 18662 18834
##    1982  106  4285  5396 10666 13782 15599 15496 16169 16704     *
##    1983 3410  8992 13873 16141 18735 22214 22863 23466     *     *
##    1984 5655 11555 15766 21266 23425 26083 27067     *     *     *
##    1985 1092  9565 15836 22169 25955 26180     *     *     *     *
##    1986 1513  6445 11702 12935 15852     *     *     *     *     *
##    1987  557  4020 10946 12314     *     *     *     *     *     *
##    1988 1351  6947 13112     *     *     *     *     *     *     *
##    1989 3133  5395     *     *     *     *     *     *     *     *
##    1990 2063     *     *     *     *     *     *     *     *     *
## #
## 
## # A tibble: 100 x 4
##    origin   dev TRI_CUM TRI_INC
##     <int> <int>   <int>   <int>
## 1    1981     1    5012    5012
## 2    1982     1     106     106
## 3    1983     1    3410    3410
## 4    1984     1    5655    5655
## 5    1985     1    1092    1092
## 6    1986     1    1513    1513
## 7    1987     1     557     557
## 8    1988     1    1351    1351
## 9    1989     1    3133    3133
## 10   1990     1    2063    2063
## # ... with 90 more rows

Transform the dataset from an "Incremental" triangle to a "Development" triangle.

RAA %>% tbl_tri(type = "Incremental") %>% transform(type = "Development")
## # A triangle: 10 x 10
##  origin 1-to-2 2-to-3 3-to-4 4-to-5 5-to-6 6-to-7 7-to-8 8-to-9 9-to-10
##    1981   1.65  1.319  1.082  1.147  1.195  1.113  1.033  1.003   1.009
##    1982 40.425  1.259  1.977  1.292  1.132  0.993  1.043  1.033       *
##    1983  2.637  1.543  1.163  1.161  1.186  1.029  1.026      *       *
##    1984  2.043  1.364  1.349  1.102  1.113  1.038      *      *       *
##    1985  8.759  1.656    1.4  1.171  1.009      *      *      *       *
##    1986   4.26  1.816  1.105  1.226      *      *      *      *       *
##    1987  7.217  2.723  1.125      *      *      *      *      *       *
##    1988  5.142  1.887      *      *      *      *      *      *       *
##    1989  1.722      *      *      *      *      *      *      *       *
##    1990      *      *      *      *      *      *      *      *       *
## #
## 
## # A tibble: 90 x 3
##    origin TRI_LINK TRI_DEV_FCT
##     <int>    <chr>       <dbl>
## 1    1981   1-to-2    1.649840
## 2    1981   2-to-3    1.319023
## 3    1981   3-to-4    1.082332
## 4    1981   4-to-5    1.146887
## 5    1981   5-to-6    1.195140
## 6    1981   6-to-7    1.112972
## 7    1981   7-to-8    1.033261
## 8    1981   8-to-9    1.002902
## 9    1981  9-to-10    1.009217
## 10   1982   1-to-2   40.424528
## # ... with 80 more rows

Transform the dataset from an "Incremental" triangle, to a "Cumulative" triangle, to finally a "Development" triangle.

RAA %>% tbl_tri(type = "Incremental") %>% transform(type = "Cumulative") %>% transform(type = "Development")
## # A triangle: 10 x 10
##  origin 1-to-2 2-to-3 3-to-4 4-to-5 5-to-6 6-to-7 7-to-8 8-to-9 9-to-10
##    1981   1.65  1.319  1.082  1.147  1.195  1.113  1.033  1.003   1.009
##    1982 40.425  1.259  1.977  1.292  1.132  0.993  1.043  1.033       *
##    1983  2.637  1.543  1.163  1.161  1.186  1.029  1.026      *       *
##    1984  2.043  1.364  1.349  1.102  1.113  1.038      *      *       *
##    1985  8.759  1.656    1.4  1.171  1.009      *      *      *       *
##    1986   4.26  1.816  1.105  1.226      *      *      *      *       *
##    1987  7.217  2.723  1.125      *      *      *      *      *       *
##    1988  5.142  1.887      *      *      *      *      *      *       *
##    1989  1.722      *      *      *      *      *      *      *       *
##    1990      *      *      *      *      *      *      *      *       *
## #
## 
## # A tibble: 90 x 3
##    origin TRI_LINK TRI_DEV_FCT
##     <int>    <chr>       <dbl>
## 1    1981   1-to-2    1.649840
## 2    1981   2-to-3    1.319023
## 3    1981   3-to-4    1.082332
## 4    1981   4-to-5    1.146887
## 5    1981   5-to-6    1.195140
## 6    1981   6-to-7    1.112972
## 7    1981   7-to-8    1.033261
## 8    1981   8-to-9    1.002902
## 9    1981  9-to-10    1.009217
## 10   1982   1-to-2   40.424528
## # ... with 80 more rows


m-montero/LDTr documentation built on May 21, 2019, 9:17 a.m.