We want to create pdf and html reports using the ChainLadder package reserve projection functions. Many of the ChainLadder functions return complicated objects stored as lists. The exhibit package grabs the most important data for presentation from these objects and converts it into a matrix or data frame that is easy to understand and easy to display in an html or pdf report.

Examples

# load packages
library(ChainLadder)
library(exhibit)
library(xtable)
options(xtable.comment = FALSE)
options(xtable.type = "html")

We are going to use the RAA object provided by the ChainLadder package. RAA is an S3 object of class triangle from the ChainLadder package. It looks like a nice triangle when it is printed to the R console. Additionally the results from the MackChainLadder function look nice when printed to the R console:

RAA

MackChainLadder(RAA)

but if you try to make a table out of the triangle you end up with this

out <- xtable(RAA)
print(out,
  format.args = list(big.mark = ",")      
)

This is because ChainLadder stores more information than is shown in the R console in its classes. The classes returned from projection methodologies can store a lot of information and can be hard to navigate. Take a look at the structure of the class returned from the MackChainLadder() function:

out <- MackChainLadder(RAA)
str(out)

ChainLadder uses generic functions to print and summarize its classes to the R console. This is nice if you are only printing your results to the R console, but we want to quickly display the results in an html or pdf report. To do this we use the exhibit() function to grab only the information we want from the respective ChainLadder class and return it as a 2-dimensional matrix or data frame.

Here are a few examples:

out <- exhibit(RAA)
out <- xtable(out)
print(out,
  format.args = list(big.mark = ",")
)
RAA_mack <- MackChainLadder(RAA)
RAA_mack_out <- exhibit(RAA_mack)
RAA_mack_out <- xtable(RAA_mack_out,
                  digits = c(0, 0, 2, 0, 0, 0)
                )
print(RAA_mack_out,
  format.args = list(big.mark = ",")     
)


merlinoa/exhibit documentation built on May 22, 2019, 6:52 p.m.