Reserving with the MBMCL package

After working on a bootstrapping framework for the Mack model, with a one-year point of view and with several triangles to bootstrap jointly, i decided to put some of my code into a litle package, mbmcl.

You can install it with :

We’ll also load some conveniance packages, namely magrittr/dplyr/purrr/tibble/tidyr.

library(magrittr)
library(dplyr)
library(purrr)
library(tibble)
library(tidyr)

Then load some triangle data, for exemple the ABC triangle from the ChainLadder package. For the purpose of this exposition, we need several triangles of same size, lets create dummy triangles, and look at mack’s results on them :

library(ChainLadder)
data("ABC")

random_triangle <- function(source_triangle){
  source_triangle %>% 
  cum2incr %>% 
  multiply_by(matrix(data=abs(rnorm(length(ABC),1,0.5)),nrow=dim(ABC)[1])) %>%
  incr2cum %>% 
    return
}

triangles <- list(A = random_triangle(ABC),B = random_triangle(ABC),C = random_triangle(ABC))
triangles %>% 
  map(MackChainLadder) %>% 
  map(summary) %>% 
  map("Totals") %>% 
  enframe %>%
  mutate(
    value = value %>%
      map(~mutate(.x,Output = row.names(.x)))
  ) %>%
  unnest() %>%
  spread(name,Totals)
## # A tibble: 6 x 4
##   Output                A            B            C
##   <chr>             <dbl>        <dbl>        <dbl>
## 1 CV(IBNR):         0.210        0.223        0.126
## 2 Dev:              0.680        0.637        0.743
## 3 IBNR:       5456795.     5289669.     3588052.   
## 4 Latest:    11573722.     9296604.    10354597.   
## 5 Mack S.E.:  1144986.     1180000.      453876.   
## 6 Ultimate:  17030517.    14586273.    13942649.

Ok theese 3 triangles are different enough for our purpose.

Now, let’s compute a Bootstrap of the Mack model on the first triangle. For that, we’ll use the BootMackChainLadder function from the package :

Model <- 
  BootMackChainLadder(
    Triangle = triangles[[1]],
    B = 100, # Number of bootstrap replicates
    distNy = "normal", # distribution of next-year residuals.
  )

Only the first argument (the input triangle) is required, but specifying the number of bootstrap replicates is better, and specifying the distribution for residuals can be usefull. Indeed, if we choose to resample residuals with a normal distribution, we can consider that we are in the normal, true-glm version of the classical quasi-glm model that is the mack model. On the other hand, specifying distNy = "residuals" will give you a bootstrap corresponding to the quasi-glm mack model.

Model
## This is a BootMackChainLadder model 
## 
## Detailed results by Origin years : 
##           Latest   Ultimates         IBNR       NyCum      NyInc
## 1977 1,023,122.1 1,023,122.1         0.00 1,023,122.1       0.00
## 1978 1,015,212.9 1,037,161.9    21,949.05 1,038,487.7  23,274.82
## 1979   977,144.2 1,014,318.7    37,174.49   992,808.7  15,664.54
## 1980 1,058,002.1 1,130,103.7    72,101.63 1,090,380.4  32,378.25
## 1981   900,540.7   999,769.9    99,229.15   939,922.7  39,382.02
## 1982 1,243,652.9 1,445,527.4   201,874.51 1,306,788.2  63,135.24
## 1983 1,097,410.1 1,351,973.1   254,563.04 1,159,284.5  61,874.46
## 1984 1,193,347.7 1,635,039.5   441,691.77 1,322,471.0 129,123.26
## 1985 1,649,159.8 2,575,045.1   925,885.29 1,888,222.4 239,062.63
## 1986 1,150,501.5 2,873,233.3 1,722,731.78 1,846,704.9 696,203.41
## 1987   265,628.3 1,945,222.8 1,679,594.42   772,330.0 506,701.65
##      NyUltimates       NyIBNR
## 1977   1,023,122         0.00
## 1978   1,038,488    23,274.82
## 1979   1,014,929    37,784.43
## 1980   1,132,584    74,582.38
## 1981   1,005,042   104,501.51
## 1982   1,453,507   209,854.07
## 1983   1,351,012   253,601.50
## 1984   1,632,511   439,162.93
## 1985   2,590,824   941,664.14
## 1986   2,890,580 1,740,078.53
## 1987   1,933,289 1,667,660.95
## 
##  Totals across origin years : 
##      Latest       Ultimates    IBNR         NyCum        NyInc       
## [1,] "11,573,722" "17,030,517" " 5,456,795" "13,380,523" " 1,806,800"
##      NyUltimates  NyIBNR      
## [1,] "17,065,888" " 5,492,165"
## NULL

Note that it gives the same This-year results as the classical mack model. Indeed, only the One-year part of this model is bootstraped.

If you want the comparaison with the MW formula, you could do something like this :

Num_replicates <- 10^seq(1,4,by=0.1)

Models <- map(Num_replicates,~BootMackChainLadder(Triangle = triangles[[1]],B=.x,distNy = "normal"))

Models %>% 
  map(CDR) %>% 
  map_dbl(~.x %>% pull() %>% rev %>% .[[1]]) %>%
  {plot(Num_replicates, .,type="b",main = "Bootstraped standard error of the total CDR function of the number \n of boostrap replicates (red = MW formula)")}

abline(col="red",h = triangles[[1]] %>% MackChainLadder %>% CDR %>% .[[2]] %>% rev %>% .[[1]])

This works for one triangle, but what if my claims are divided into several triangles, that i need to develop in a joint manner to understand the variability of the total reserves over a one-year period ?

Well, in this case, you could apply the formula proposed my Merz-Wüthrich in 2008 for the variability of the CDR in the Braun Model.

If you want a bootstrap, you could apply the proposition of Boumezoued et al in 2011, wich is exactly what does the default parameters of the MutliBootMackChainLadder function from the eponym package.

MBMCL <- MultiBootMackChainLadder(triangles,
                         B=100,
                         distNy = "normal") 

From this object, you can extract several informations, for exemple mean bootstrapped results :

mean(MBMCL)
## $ByOrigin
##           IBNRA      IBNRB      IBNRC   IBNR.Tot Ultimates.A Ultimates.B
## 1977       0.00       0.00       0.00       0.00   1023122.1    763724.2
## 1978   21949.05   27576.72    9510.94   59036.71   1037161.9   1112761.7
## 1979   37174.49   39218.26   20252.97   96645.72   1014318.7    872981.1
## 1980   72101.63   34594.93   70273.23  176969.79   1130103.7    600209.8
## 1981   99229.15  111624.95   98344.86  309198.96    999769.9   1170124.9
## 1982  201874.51  158465.54  107434.73  467774.78   1445527.4   1081910.6
## 1983  254563.04  159552.89  210437.44  624553.38   1351973.1    770380.4
## 1984  441691.77  430396.86  563043.32 1435131.95   1635039.5   1461424.8
## 1985  925885.29  841834.15  386668.50 2154387.93   2575045.1   1961630.1
## 1986 1722731.78 1308975.18 1616078.77 4647785.72   2873233.3   2095875.0
## 1987 1679594.42 2177429.93  506007.03 4363031.38   1945222.8   2695250.7
##      Ultimates.C Ultimates.Tot
## 1977   1055886.8       2842733
## 1978    862023.1       3011947
## 1979    965621.5       2852921
## 1980   1247949.2       2978263
## 1981   1249901.0       3419796
## 1982    830535.3       3357973
## 1983   1184484.8       3306838
## 1984   2180653.2       5277118
## 1985   1006804.4       5543480
## 1986   2712817.7       7681926
## 1987    645972.4       5286446
## 
## $Totals
##                    A        B        C      Tot
## Latest      11573722  9296604 10354597 31224924
## Ultimates   17030517 14586273 13942649 45559440
## IBNR         5456795  5289669  3588052 14334516
## NyCum       13385228 10796741 11590118 35772086
## NyInc        1811505  1500137  1235520  4547162
## NyUltimates 17038255 14598592 14029495 45666343
## NyIBNR       5464533  5301988  3674898 14441420

Or information about the One-year risk, for each triangle AND on the agregated portefolio

CDR(MBMCL)
## $ByOrigin
##          IBNR.A     IBNR.B     IBNR.C   IBNR.Tot CDR(1).SE.A CDR(1).SE.B
## 1977       0.00       0.00       0.00       0.00        0.00        0.00
## 1978   21949.05   27576.72    9510.94   59036.71    18636.20    58845.60
## 1979   37174.49   39218.26   20252.97   96645.72    13144.60    36537.47
## 1980   72101.63   34594.93   70273.23  176969.79    19593.93    23150.63
## 1981   99229.15  111624.95   98344.86  309198.96    29370.95    41803.66
## 1982  201874.51  158465.54  107434.73  467774.78    38229.40    49077.01
## 1983  254563.04  159552.89  210437.44  624553.38    42681.30    35229.77
## 1984  441691.77  430396.86  563043.32 1435131.95    72387.17    96380.79
## 1985  925885.29  841834.15  386668.50 2154387.93   144356.87   260148.30
## 1986 1722731.78 1308975.18 1616078.77 4647785.72   433449.99   485632.95
## 1987 1679594.42 2177429.93  506007.03 4363031.38   740344.89   564629.46
##      CDR(1).SE.C CDR(1).SE.Tot
## 1977       0.000          0.00
## 1978    1164.861      77944.16
## 1979    2494.427      48549.35
## 1980    8138.621      42928.53
## 1981   28600.817      62746.95
## 1982   25530.634      75259.15
## 1983   29177.414      82475.10
## 1984   60705.635     138445.02
## 1985   59762.021     358585.26
## 1986  227262.115     704947.71
## 1987  211321.663     994890.60
## 
## $Totals
##         IBNR CDR.1.S.E.
## A    5456795   922562.5
## B    5289669  1030422.0
## C    3588052   331849.2
## Tot 14334516  1552071.0

Finaly, the model gives you a bootstrapped joint distribution for the 3 Claim developement results, allowing, for exemple, to compute corelation between them :

Corel(MBMCL)
##            A           B          C
## A 1.00000000  0.09438357  0.4597817
## B 0.09438357  1.00000000 -0.1097606
## C 0.45978170 -0.10976064  1.0000000

You can also get a lot of information from str : every class exported by the package(mainly, the BootMackChainLadder and MultiBootMackChainLadder objects) are standard S3 classes containing all simulations and all informations about simulations that were done. Exploiting thoose objects is straightforward, it is just a matter of “where is the information i need ?”.

Other options are availiable in the functions to parametrise the bootstraps a little more : stabilisation of coefficients, Bornhuetter-fergusson, etc.. But thoose extension are not based on peer-reviewed academic work, so use them with caution and… read the code !

Related

comments powered by Disqus