# Hello - About me

• Name: Markus Gesmann
• Profession: Mathematician, working as an analyst at Lloyd’s
• Maintainer and co-author of two R packages:
• ChainLadder: Statistical methods for the calculation of outstanding claims reserves in general insurance
• Used by actuaries around the world for reserving and teaching
• googleVis: Interface between R and the Google Visualisation API
• Used for data visualisation on www.lloyds.com (1), (2)
• Founder and co-organise of the Cologne R user group
• Blogger: mages’ blog

# Agenda

• My motivation for using R
• Brief history of R and its way into insurance
• Three R examples
• R for actuaries: Where to start?
• How I created this presentation with R
• Conclusions and discussion

# Why I started using R

• I started in insurance in 2003, fresh out of university
• I had used a variety of software, tools and languages already
• But I had no experience with spreadsheets
• I was surprised how people worked in insurance
• I was really surprised what colleagues did with spreadsheets
• I looked for alternative data analysis tools
• All the cool kids were talking about R
• I wanted to be cool as well

# Why R in insurance?

• Why Excel, SAS, SQL, SPSS, Minitab, …?
• John D. Cook: Why and how people use R
• Because it gets the job done!

# Typical use cases for R in insurance

• Data transformation
• Data analysis
• Statistical modelling
• Prototyping / ad-hoc work
• End user computing
• Background statistical engine for applications, e.g. pricing spreadsheet
• Reporting and reproducible analysis, e.g. MI, Solvency II documentation
• Learning statistical and actuarial skills

# Three R examples

• Reserving: Mack and Bootstrap chain-ladder
• Automated reporting: Create PowerPoint slide with R output
• Extracting data from a web page: Display earth quakes of the last 30 days

# Reserving: Mack chain-ladder

library(ChainLadder) ## load ChainLadder functions
data(GenIns) ## Famous Taylor / Ashe triangle
## For the purpose of the presentation we change the data slightly

# Display earth quake information of last 30 days

library(googleVis)
## Create a geo chart with the Google Chart API
G <- gvisGeoChart(eq, "loc", "DEPTH km", "MAG",
options=list(displayMode="Markers",
colorAxis="{colors:['purple', 'red', 'orange', 'grey']}",
backgroundColor="lightblue"), chartid="EQ")
plot(G)

# R packages for actuaries on CRAN

• actuar: Loss distributions modelling, risk theory (including ruin theory), simulation of compound hierarchical models and credibility theory
• ChainLadder: Reserving methods in R
• copula: Multivariate Dependence with Copulas
• cplm: Monte Carlo EM algorithms and Bayesian methods for fitting Tweedie compound Poisson linear models
• evir: Extreme Values in R
• fitdistrplus: Help to fit of a parametric distribution to non-censored or censored data
• lifecontingencies: Package to perform actuarial evaluation of life contingencies
• lossDev: A Bayesian time series loss development model
• mondate: R package to keep track of dates in terms of months

# How I created this presentation with RStudio, knitr, pandoc and slidy

• knitr is a package by Yihui Xie that brings literate programming to a new level
• It allows to create content really quickly, without worrying to much about layout and R formatting
• RStudio integrated knitr into its IDE, which allows to knit Rmd-files by the push of a button into markdown
• Markdown output can be converted into several other file formats, such as html, with pandoc
• slidy is one of the options to create interactive html-slides with pandoc
• For more details see my recent blog post and source code of this talk.

Rscript -e "library(knitr); knit('Using_R_in_Insurance_GIRO_2012.Rmd')"
pandoc -s -S -i -t slidy --mathjax Using_R_in_Insurance_GIRO_2012.md
-o Using_R_in_Insurance_GIRO_2012.html


# Conclusions

• R comes with lots of functions for actuarial work
• It provides an ideal framework for end user computing
• R can automate the production of reproducible reports and presentations
• The momentum behind R has grown significantly over the last 5 years
• Today R is often known by graduates - open up to their ideas
• Many other software products developed R interfaces
• New business models have evolved and will evolve

# If you liked this presentation …

… you may also like:

# Questions?

• Idea: R in Insurance Workshop - Interest?
• Contact: markus dot gesmann at gmail dot com

# R version and packages used for this presentation

sessionInfo()
## R version 2.15.1 (2012-06-22)
## Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
##
## locale:
## [1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8
##
## attached base packages:
## [1] splines   methods   stats     graphics  grDevices utils     datasets
## [8] base
##
## other attached packages:
##  [1] XML_3.9-4           tm_0.5-7.1          wordcloud_2.2
##  [4] RColorBrewer_1.0-5  Rcpp_0.9.13         googleVis_0.2.18
##  [7] RJSONIO_0.98-1      ChainLadder_0.1.5-3 tweedie_2.1.1
## [10] statmod_1.4.15      cplm_0.6-4          lme4_0.999999-0
## [13] ggplot2_0.9.2.1     coda_0.15-2         biglm_0.8
## [16] DBI_0.2-5           actuar_1.1-4        RUnit_0.4.26
## [19] systemfit_1.1-12    lmtest_0.9-30       zoo_1.7-7
## [22] car_2.0-13          nnet_7.3-4          MASS_7.3-21
## [25] Matrix_1.0-9        lattice_0.20-10     Hmisc_3.9-3
## [28] survival_2.36-14    knitr_0.8
##
## loaded via a namespace (and not attached):
##  [1] amer_0.6.10      cluster_1.14.2   colorspace_1.1-1 dichromat_1.2-4
##  [5] digest_0.5.2     evaluate_0.4.2   formatR_0.6      grid_2.15.1
##  [9] gtable_0.1.1     labeling_0.1     memoise_0.1      minqa_1.2.1
## [13] munsell_0.4      nlme_3.1-104     plyr_1.7.1       proto_0.3-9.2
## [17] reshape2_1.2.1   scales_0.2.2     slam_0.1-25      stats4_2.15.1
## [21] stringr_0.6.1    tools_2.15.1