Loss reserving has a new, silly name

January 18, 2013
By

(This article was first published on PirateGrunt » R, and kindly contributed to R-bloggers)

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 his blog: PirateGrunt » R.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.