Loss reserving has a new, silly name

[This article was first published on PirateGrunt » R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

I started using Git some time ago, but mostly for local work files. Today, I finally sync’ed up a repository for loss reserving analysis. It may be found here: https://github.com/PirateGrunt/MRMR

MRMR stands for Multivariate Regression Model for Reserves. When pronounced “Mister Mister” it also sounds like a thankfully forgotten American soft pop band from the ’80s (“Kyrie”, “Broken Wings”, etc.). It may also bring to mind MCMC, a subject that I’m trying to master in my spare time.

Current capabilities are:

  • Fetch NAIC data from the CAS research site.
  • Prepare a design matrix to fit a linear model.
  • Fit a weighted OLS regression to a loss triangle.
  • Write some basic diagnostic graphs to assess quality of the model.

This was some of the first R code that I wrote about a year ago and it’s been a while since I’ve looked at it. I expect I’ll be making loads of changes over the next few weeks. UPDATE: I tried to run the projection code this afternoon and got some incorrect results. At present, the projection function is pants. I hope to have it sorted out by the end of the weekend.

If you’d like to contribute, please let me know. I couldn’t possibly compete with ChainLadder. This is more just for fun and a convenient way to store and share code.

Here’s the demo script and a picture of the output.

source("https://raw.github.com/PirateGrunt/MRMR/master/RegressionSupport.r")
source("https://raw.github.com/PirateGrunt/MRMR/master/NAIC.R")
source("https://raw.github.com/PirateGrunt/MRMR/master/ReservingVisualization.R")
source("https://raw.github.com/PirateGrunt/MRMR/master/Triangle.R")

df = GetNAICData("wkcomp_pos.csv")
bigCompany = as.character(df[which(df$CumulativePaid == max(df$CumulativePaid)),"GroupName"])

df.BigCo = subset(df, GroupName == bigCompany)

df.UpperTriangle = subset(df.BigCo, DevelopmentYear <=1997)

tri = Triangle(TriangleData = df.UpperTriangle
               , TriangleName = bigCompany
               , LossPeriodType = "accident"
               , LossPeriodInterval = years(1)
               , DevelopmentInterval = years(1)
               , LossPeriodColumn = "LossPeriodStart"
               , DevelopmentColumn = "DevelopmentLag")

tri@TriangleName
tri

is(tri, "Triangle")
is.Triangle(tri)

plt = ShowTriangle(tri@TriangleData, bigCompany)

plot(tri)
head(LatestDiagonal(tri))
length(LatestDiagonal(tri)[,1])

plt = ShowTriangle(tri@TriangleData, bigCompany, Cumulative=FALSE)
#Note the apparent calendar year impact in 1996. This is invisible in the cumulative display.

AllstateCumulativePaid AllstateIncrementalPaid


To leave a comment for the author, please follow the link and comment on their blog: PirateGrunt » R.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)