Introduction to Reserving in R:
In our last two blogs we discussed how to combine reserve estimates, as well as how to start integrating Machine Learning (ML) into your process. Hopefully the reader found these interesting and useful. If you have any comments, questions, or just looking for advice, please feel free to contact us.
With that, to provide a more solid foundation, and give the reader real tools to deploy (instead of just talk), I plan on releasing the code used in our prior articles over the next weeks/months.
For the first release, we will start with the basics (triangle based methods). Other posts that follow will go over the steps to setup data for ML models, ways to run data through the ML models, and end with an excel package that will allow every Actuary to use ML in excel (without having to work in R). This will serve as the carrot at the end of the stick!
Since most Actuaries are comfortable in excel, the idea was to create an interface that would allow them to perform all their reserving functions (including some basic ML models) without having to learn how to code in R, Python, or other languages.
However, prior to letting the cat out of the bag, I would like to go over the code piece by piece so the user has a better understanding of the model. I have no intentions of providing a black box. I want the user to at least grasp some of the basic concepts prior to using the file.
Starting with the basics:
As noted above, we will start by tackling the basics (traditional triangle based method). For this specific example we will be covering the Paid Per Member Per Month (Paid PMPM) method. Although this can be done efficiently in excel, this will give the reader an understanding of the logic used in R.
Let’s begin – Suppose we have a matrix called “data” that contains the three basic features (see below):
|Incurred Month||Processed Month||Paid Claim PMPM|
We will then create a loop that cycles through all rows within the data.
+ sum(data[data$Incmo==data$Incmo[i] & data$Lag <= min(data$Lag[i],runout),]$Paid)}