mages / ChainLadder

Claims reserving models in R
https://mages.github.io/ChainLadder/
75 stars 62 forks source link

Mack model #31

Closed lahotirichie closed 7 years ago

lahotirichie commented 7 years ago

When getting the plot of Chain ladder developments by origin period it is throwing an error saying In expand.grid(origin = as.numeric(dimnames(.FullTriangle)$origin), : NAs introduced by coercion. Suggestions on resolving?

filemock3 <-file.choose() mock3 <- read.csv(filemock3, header = FALSE) mock3 <- as.triangle(as.matrix(mock3)) mock3 dev origin V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 1 573 1392 1736 2035 2259 2360 2349 2311 2324 2324 2324 2 710 1600 1889 2026 2077 2093 2105 2105 2107 2110 NA 3 919 1947 2237 2372 2458 2460 2464 2463 2463 NA NA 4 1459 3488 4325 4623 4717 4728 4734 4738 NA NA NA 5 2145 6824 8875 9777 10093 10128 10131 NA NA NA NA 6 3976 11049 13727 14736 14960 15077 NA NA NA NA NA 7 6747 15757 18463 19713 20110 NA NA NA NA NA NA 8 6019 13139 15679 16952 NA NA NA NA NA NA NA 9 5360 12320 14707 NA NA NA NA NA NA NA NA 10 6012 12641 NA NA NA NA NA NA NA NA NA 11 6603 NA NA NA NA NA NA NA NA NA NA mock3mack <- MackChainLadder(mock3, est.sigma = "Mack") mock3mack MackChainLadder(Triangle = mock3, est.sigma = "Mack")

Latest Dev.To.Date Ultimate IBNR Mack.S.E CV(IBNR) 1 2,324 1.000 2,324 0.00 0.000 NaN 2 2,110 1.000 2,110 0.00 0.977 Inf 3 2,463 0.999 2,465 1.67 3.129 1.876 4 4,738 0.997 4,752 13.55 13.965 1.031 5 10,131 1.000 10,129 -1.55 62.252 -40.085 6 15,077 1.000 15,084 7.38 89.183 12.078 7 20,110 0.992 20,275 165.02 186.541 1.130 8 16,952 0.967 17,521 569.46 306.574 0.538 9 14,707 0.896 16,405 1,698.44 389.187 0.229 10 12,641 0.741 17,050 4,409.25 646.818 0.147 11 6,603 0.314 21,046 14,443.33 2,244.681 0.155

          Totals

Latest: 107,856.00 Dev: 0.84 Ultimate: 129,162.55 IBNR: 21,306.55 Mack.S.E 2,548.62 CV(IBNR): 0.12

plot(mock3mack) plot(mock3mack, lattice=TRUE) Warning message: In expand.grid(origin = as.numeric(dimnames(.FullTriangle)$origin), : NAs introduced by coercion

mages commented 7 years ago

I guess the warning is caused by the second origin year, which has no IBNR. Please attach the CSV file, which makes it much easier to reproduce your issue.

lahotirichie commented 7 years ago

Hi Markus,

I have attached the file herewith. Mock2.xlsx

mages commented 7 years ago

The issue arises as the column names of your triangles are characters V1 ... V11. If you change those to numerics it will work, e.g:

colnames(mock3) <- 1:11
plot(MackChainLadder(mock3, est.sigma = "Mack"), lattice = TRUE)

rplot

lahotirichie commented 7 years ago

That works. Thanks!