### Non-Life Insurance: Mathematics and Statistics
### Exercise Sheet 13
### Exercise 4
### Load the required packages
library(readxl)
library(ChainLadder)
### Download the data from the link indicated on the exercise sheet
### Store the data under the name "Exercise13Data.xls" in the same folder as this R code
### Load the data
data <- read_excel("Exercise13Data.xls", sheet = "Data_1", range = "B22:K31", col_names = FALSE)
### Bring the data in the appropriate triangular form and label the axes
tri <- as.triangle(as.matrix(data))
dimnames(tri)=list(origin=1:nrow(tri),dev=1:ncol(tri))
### Calculate the CL reserves and the corresponding mseps
M <- MackChainLadder(tri, est.sigma = "Mack")
### CL reserves and Mack's square-rooted mseps (including illustrations)
M
plot(M)
plot(M, lattice = TRUE)
### CL reserves, MW's square-rooted mseps and Mack's square-rooted mseps
CDR(M)
### Mack's square-rooted mseps in % of the reserves
round(CDR(M)[,3] / CDR(M)[,1],3) * 100
### MW's square-rooted mseps in % of Mack's square-rooted mseps
round(CDR(M)[,2] / CDR(M)[,3],2) * 100
### Full uncertainty picture
CDR(M, dev="all")