I am going to use the Chainladder package, and apply its function mackchainladder()
I have a data with many cumulative payments triangles in the Excel, formatted like the following:
ID A DY1 DY2 DY3 DY4 DY5 DY6 DY7 DY8 DY9 DY10
27 1 1526 2860 3575 3544 3700 3714 3714 3681 3669 3595
27 2 1717 3619 3706 3687 3547 3511 4306 4235 4231
27 3 5042 9957 12912 14249 15801 15659 15766 15811
27 4 8399 15946 19155 20120 20645 20357 20517
27 5 6494 11274 13220 13907 14383 14435
27 6 7340 13426 16916 18420 18605
27 7 11004 20474 26251 28964
27 8 13107 23065 26150
27 9 17250 23922
27 10 18833
35 1 90751 130298 147618 159509 165517 169048 170988 171730 171854 172295
35 2 105370 152668 174635 189384 196637 200010 202436 203752 204294
35 3 123692 181088 207566 225943 235993 243255 245759 247297
35 4 142717 206614 236415 255642 265007 269450 272050
35 5 167997 235772 267384 286297 294015 297560
35 6 169744 237253 270713 288991 299322
35 7 204752 279957 317459 342275
35 8 231249 318056 359736
35 9 257927 358768
35 10 300881
You can find data and examples of chain-ladder package here:
http://code.google.com/p/chainladder/wiki/Examples
sample chainladder output
library(ChainLadder)
M <- MackChainLadder(RAA, est.sigma="Mack")
M
MackChainLadder(Triangle = RAA, est.sigma = "Mack")
Latest Dev.To.Date Ultimate IBNR Mack.S.E CV
1981 18,834 1.000 18,834 0 0 NaN
1982 16,704 0.991 16,858 154 206 1.339
1983 23,466 0.974 24,083 617 623 1.010
1984 27,067 0.943 28,703 1,636 747 0.457
1985 26,180 0.905 28,927 2,747 1,469 0.535
1986 15,852 0.813 19,501 3,649 2,002 0.549
1987 12,314 0.694 17,749 5,435 2,209 0.406
1988 13,112 0.546 24,019 10,907 5,358 0.491
1989 5,395 0.336 16,045 10,650 6,333 0.595
1990 2,063 0.112 18,402 16,339 24,566 1.503
Totals
Latest: 160,987.00
Ultimate: 213,122.23
IBNR: 52,135.23
Mack S.E.: 26,909.01
CV: 0.52
I have thousands of IDs (companies).
I want to apply the R Chain-Ladder method (mackchainladder) to each triangle, and obtain the IBNR and SD of IBNR. However, I don't know how to do apply the chain-ladder to each of those companies, and how to get the results in a table, looks like this:
ID IBNR Mack_S.E.
11 11111 2222
24 33333 4444 (I made up those numbers)
Can I use gapply()? Then how can I the table for my results? I am new to R, any comments are welcome.