SlideShare una empresa de Scribd logo
1 de 23
Descargar para leer sin conexión
R for Car
Insurance
Product
Claudio G. Giancaterino
29/11/2016
Zurich R User Group - Meetup
Motor Third Party Liability
Pricing
By the Insurance contract, economic risk is transferred
from the policyholder to the Insurer
Theoretical Approach
 P=E(X)=E(N)*E(Z)
 P=Risk Premium
 X=Global Loss
 E(N)=claim frequency
 E(Z)=claim severity
 Hp:
 1) cost of claims are i.i.d.
 2) indipendence between number of claims
and cost of claims
From Technical Tariff to
Commercial Tariff
Tariff variables
 P=Pcoll*Yh*Xi*Zj=Technical Tariff
risk coefficients statistical models are employed
 Pt=P*(1+λ)/(1-H)=Commercial Tariff
 λ=Safety Loading Rate
 H=Loading Rate
 P is adjusted by tariff requirement
Dataset “ausprivauto0405”
within CASdatasets R
package
 Statistics
> str(ausprivauto0405)
'data.frame': 67856 obs. of 9 variables:
$ Exposure: num 0.304 0.649 0.569 0.318 0.649 ...
$ VehValue: num 1.06 1.03 3.26 4.14 0.72 2.01 1.6 1.47 0.52
$ VehAge: Factor w/ 4 levels "old cars","oldest cars",..: 1 3 3 3 2
$ VehBody: Factor w/ 13 levels "Bus","Convertible",..: 5 5 13 11 5
$ Gender: Factor w/ 2 levels "Female","Male": 1 1 1 1 1 2 2 2 1
$ DrivAge: Factor w/ 6 levels "old people","older work. people",..: 5 2 5 5
$ ClaimOcc: int 0 0 0 0 0 0 0 0 0 0 ...
$ ClaimNb: int 0 0 0 0 0 0 0 0 0 0 ...
$ ClaimAmount: num 0 0 0 0 0 0 0 0 0 0 ...
> table(VehAge,useNA="always")
VehAge
old cars oldest cars young cars youngest cars <NA>
20064 18948 16587 12257 0
> table(DrivAge,useNA="always")
DrivAge
old people older work. people oldest people working people
10736 16189 6547 15767
young people youngest people <NA>
12875 5742 0
> table(VehBody,useNA="always")
VehBody
Bus Convertible Coupe Hardtop
48 81 780 1579
Hatchback Minibus Motorized caravan Panel van
18915 717 127 752
Roadster Sedan Station wagon Truck
27 22233 16261 1750
Utility <NA>
4586 0
> library(Amelia)
> missmap(ausprivauto0405)
#mean frequency#
> MClaims<-with(rc, sum(ClaimNb)/sum(Exposure))
> MClaims
[1] 0.5471511
 
#mean severity#
> MACost<-with(rc, sum(ClaimAmount)/sum(ClaimNb))
> MACost
[1] 287.822
 
#mean risk premium#
> MPremium<-with(rc, sum(ClaimAmount)/sum(Exposure))
> MPremium
[1] 157.4821
> actuallosses<-with(rc.f, sum(ClaimAmount))
> actuallosses
[1] 9342125
> library(ggplot2)
> ggplot(rc, aes(x = AgeCar))+geom_histogram(stat="bin", bins=30)
> ggplot(rc, aes(x = BodyCar))+geom_histogram(stat="bin", bins=30)
> ggplot(rc, aes(x = AgeDriver))+geom_histogram(stat="bin", bins=30)
> ggplot(rc, aes(x = VehValue))+geom_histogram(stat="bin", bins=30
> boxplot(rc$AgeCar,rc$BodyCar,rc$VehValue,rc$AgeDriver,
+ xlab="AgeCar BodyCar VehValue AgeDriver")
Cluster Analysis by k-means
#Prepare Data
> rc.stand<-scale(rc[-1]) # To standardize the variables
#Determine number of clusters
> nk = 2:10
> WSS = sapply(nk, function(k) {
+ kmeans(rc.stand, centers=k)$tot.withinss
+ })
> plot(nk, WSS, type="l", xlab="Number of Clusters",
+ ylab="Within groups sum of squares")
#k-means with k = 7 solutions
> k.means.fit <- kmeans(rc.stand, 7)
2 4 6 8 10
6000080000100000120000140000
Number of Clusters
Withingroupssumofsquares
Generalized Linear Models
(GLM)Yi~EF(b(θi);Φ/ωi) g(μi)=ηi ηi=Σjxijβj
Random Component Link Systematic Component
Linear Models are extended in
two directions:
Probability distribution:
Output variables are stochastically
independent with the same exponential
family distribution.
Expected value:
There is a link function between
expected value of outputs and covariates
that could be different from linear
regression.
GLM Analysis
Univariate Approach
#stochastic risk premium with GLM approach#
> PRSModglm1<-glm(RiskPremium1~AgeCar+BodyCar+VehValue+AgeDriver,
+ weights=Exposure, data=rc.f, family=gaussian(link=log))
> GLMSRiskPremium1<-predict(PRSModglm1,data=rc.f,type="response")
Multivariate Approach
#stochastic risk premium with GLM approach#
> PRSModglm2<-glm(RiskPremium2~AgeCar*BodyCar*VehValue*AgeDriver,
+ weights=Exposure, data=rc, family=gaussian(link=log))
> GLMSRiskPremium2<-predict(PRSModglm2,data=rc,type="response")
Generalized NonLinear
Models (GNM)
Yi~EF(b(θi);Φ/ωi) g(μi)=ηi(xij;βj) ηi=Σjxijβj
Random Component Link Systematic Component
Generalized Linear Models are extended
in the link function where the
systematic component is non linear
in the parameters βj.
It can be considered an extension of
nonlinear least squares model, where the
variance of the output depend on the mean.
Difficult are in starting values, they are
generated randomly for non linear
parameters and using a GLM fit for linear
parameters.
GNM Analysis
Univariate Approach
> library(gnm)
#stochastic risk premium with GNM approach#
> PRSModgnm1<-gnm(RiskPremium1~AgeCar+BodyCar+VehValue+AgeDriver,
+ weights=Exposure, data=rc.f, family=Gamma(link=log))
> GNMSRiskPremium1<-predict(PRSModgnm1,data=rc.f,type="response")
Multivariate Approach
> #stochastic risk premium with GNM approach#
> PRSModgnm2<-gnm(RiskPremium2~VehValue*AgeDriver*AgeCar*BodyCar,
+ weights=Exposure, data=rc, family=Gamma(link=log))
> GNMSRiskPremium2<-predict(PRSModgnm2,data=rc,type="response")
Generalized Additive
Models (GAM)
Yi~EF(b(θi);Φ/ωi) g(μi)=ηi ηi= Σpxipβip+Σjfj(xij)
Random Component Link Systematic Component
Generalized additive models extend
generalized linear models in the predictor:
systematic component is made up by one
parametric part and one non parametric part
built by the sum of unknown “smoothing”
functions of the covariates.
For the estimators are used splines,
functions made up by combination of
little polynomial segment joined in knots.
GAM Analysis
Univariate Approach
> library(mgcv)
#stochastic risk premium with GAM approach#
> PRSModgam1<-gam(RiskPremiumgam1~s(AgeCar, bs="cc", k=4)
+ +s(BodyCar, bs="cc", k=12)+s(VehValue, bs="cc", k=30)
+ +s(AgeDriver, bs="cc", k=6), weights=Exposure, data=rc,
+ family=Gamma(link=log))
> GAMSRiskPremium1<-predict(PRSModgam1,data=rc,type="response")
Multivariate Approach
> #stochastic risk premium with GAM approach#
> PRSModgam2<gam(RiskPremiumgam2~te(BodyCar,VehValue,AgeDriver,AgeCar,
+ k=4),weights=Exposure, data=rc, family="Gamma"(link=log))
> GAMSRiskPremium2<-predict(PRSModgam2,data=rc,type="response")
> rc$GAMSRiskPremium2<-with(rc, GAMSRiskPremium2)
Mean
commercial
tariff
Tariff
requirement
Loss Ratio
Residuals
degrees of
freedom
Expected
Losses
Actual
Losses
Explained
Deviance
Risk
coefficients
Uni- GLM 234,4587 1,000490 1,447822 27.501 9.337.547 9.342.125 96,96% 20
Variate GNM 234,4647 1,000476 1,447785 27.501 9.337.683 9.342.125 96,96% 20
Analysis GAM 232,8702 1,001729 1,457698 27.476 9.325.999 9.342.125 96,20% 45
Multi-
GLM 234,6486 0,9981246 1,446650 27.505 9.359.678 9.342.125 87,64% 16
Variate
GNM 234,6165 0,9979703 1,446848 27.505 9.361.125 9.342.125 87,04% 16
Analysis
GAM 248,5732 0,8596438 1,365612 27.265 10.867.438 9.342.125 84,80% 256
Results
GLM vs GAM vs GNM
Approaches
GLM GAM GNM
Strengths: -User-friendly -Flexible to fit data -Afford some
-Faster elaboration -Realistic values elaboration
-Usually low level of excluded by GLM
residual deviance
-More risk coefficients -Better values
despite GLM
Weakness: -Poor flexibility -Complex to realize -Complex to use
to fit data
-Usually higher
values of residual
deviance
-Overestimed values
References
 C.G. Giancaterino - GLM, GNM and GAM Approaches on MTPL Pricing -
Journal of Mathematics and Statistical Science – 08/2016
http://www.ss-pub.org/journals/jmss/vol-2/vol-2-issue-8-august-2016/
 X.Marechal & S. Mahy – Advanced Non Life Pricing – EAA Seminar
 N. Savelli & G.P. Clemente – Lezioni di Matematica Attuariale delle
Assicurazioni Danni – Educatt
Many Thanks for your Attention!!!
Contact:
Claudio G. Giancaterino
c.giancaterino@gmail.com

Más contenido relacionado

La actualidad más candente

MITCOE 2011-12 conm-submission
MITCOE 2011-12 conm-submissionMITCOE 2011-12 conm-submission
MITCOE 2011-12 conm-submissionAshutosh Katti
 
Design of a novel controller to increase the frequency response of an aerospace
Design of a novel controller to increase the frequency response of an aerospaceDesign of a novel controller to increase the frequency response of an aerospace
Design of a novel controller to increase the frequency response of an aerospaceIAEME Publication
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexityparamita30
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexityparamita30
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexityparamita30
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexityparamita30
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexityparamita30
 
HMPC for Upper Stage Attitude Control
HMPC for Upper Stage Attitude ControlHMPC for Upper Stage Attitude Control
HMPC for Upper Stage Attitude ControlPantelis Sopasakis
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexityparamita30
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexityparamita30
 
Curve fitting and Optimization
Curve fitting and OptimizationCurve fitting and Optimization
Curve fitting and OptimizationSyahrul Senin
 
(Full MatLab Code) Image compression DCT
(Full MatLab Code) Image compression DCT(Full MatLab Code) Image compression DCT
(Full MatLab Code) Image compression DCTChaudhary Sarimurrab
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexityparamita30
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexityparamita30
 

La actualidad más candente (20)

MITCOE 2011-12 conm-submission
MITCOE 2011-12 conm-submissionMITCOE 2011-12 conm-submission
MITCOE 2011-12 conm-submission
 
Critical Path Method
Critical Path MethodCritical Path Method
Critical Path Method
 
Design of a novel controller to increase the frequency response of an aerospace
Design of a novel controller to increase the frequency response of an aerospaceDesign of a novel controller to increase the frequency response of an aerospace
Design of a novel controller to increase the frequency response of an aerospace
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexity
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexity
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexity
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexity
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexity
 
HMPC for Upper Stage Attitude Control
HMPC for Upper Stage Attitude ControlHMPC for Upper Stage Attitude Control
HMPC for Upper Stage Attitude Control
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexity
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexity
 
Curve fitting and Optimization
Curve fitting and OptimizationCurve fitting and Optimization
Curve fitting and Optimization
 
(Full MatLab Code) Image compression DCT
(Full MatLab Code) Image compression DCT(Full MatLab Code) Image compression DCT
(Full MatLab Code) Image compression DCT
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexity
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexity
 
Topic 4.1
Topic 4.1Topic 4.1
Topic 4.1
 
Topic 2
Topic 2Topic 2
Topic 2
 
Ceske budevice
Ceske budeviceCeske budevice
Ceske budevice
 
Topic 1.2
Topic 1.2Topic 1.2
Topic 1.2
 
04 Algorithms
04 Algorithms04 Algorithms
04 Algorithms
 

Similar a How to use R in different professions: R for Car Insurance Product (Speaker: Claudio Giancaterino)

R/Finance 2009 Chicago
R/Finance 2009 ChicagoR/Finance 2009 Chicago
R/Finance 2009 Chicagogyollin
 
Introducing R package ESG at Rmetrics Paris 2014 conference
Introducing R package ESG at Rmetrics Paris 2014 conferenceIntroducing R package ESG at Rmetrics Paris 2014 conference
Introducing R package ESG at Rmetrics Paris 2014 conferenceThierry Moudiki
 
Relevance of Particle Swarm Optimization Technique for the Solution of Econom...
Relevance of Particle Swarm Optimization Technique for the Solution of Econom...Relevance of Particle Swarm Optimization Technique for the Solution of Econom...
Relevance of Particle Swarm Optimization Technique for the Solution of Econom...IRJET Journal
 
Economic Dispatch of Generated Power Using Modified Lambda-Iteration Method
Economic Dispatch of Generated Power Using Modified Lambda-Iteration MethodEconomic Dispatch of Generated Power Using Modified Lambda-Iteration Method
Economic Dispatch of Generated Power Using Modified Lambda-Iteration MethodIOSR Journals
 
Generalized Nonlinear Models in R
Generalized Nonlinear Models in RGeneralized Nonlinear Models in R
Generalized Nonlinear Models in Rhtstatistics
 
Efficient equity portfolios using mean variance optimisation in R
Efficient equity portfolios using mean variance optimisation in REfficient equity portfolios using mean variance optimisation in R
Efficient equity portfolios using mean variance optimisation in RGregg Barrett
 
COMBINED ECONOMIC AND EMISSION DISPATCH WITH AND WITHOUT CONSIDERING TRANSMIS...
COMBINED ECONOMIC AND EMISSION DISPATCH WITH AND WITHOUT CONSIDERING TRANSMIS...COMBINED ECONOMIC AND EMISSION DISPATCH WITH AND WITHOUT CONSIDERING TRANSMIS...
COMBINED ECONOMIC AND EMISSION DISPATCH WITH AND WITHOUT CONSIDERING TRANSMIS...cscpconf
 
Distributed solution of stochastic optimal control problem on GPUs
Distributed solution of stochastic optimal control problem on GPUsDistributed solution of stochastic optimal control problem on GPUs
Distributed solution of stochastic optimal control problem on GPUsPantelis Sopasakis
 
Consider a 4-Link robot manipulator shown below. Use the forward kine.pdf
Consider a 4-Link robot manipulator shown below. Use the forward kine.pdfConsider a 4-Link robot manipulator shown below. Use the forward kine.pdf
Consider a 4-Link robot manipulator shown below. Use the forward kine.pdfmeerobertsonheyde608
 
Automated Sensing System for Monitoring Road Surface Condition Using Fog Comp...
Automated Sensing System for Monitoring Road Surface Condition Using Fog Comp...Automated Sensing System for Monitoring Road Surface Condition Using Fog Comp...
Automated Sensing System for Monitoring Road Surface Condition Using Fog Comp...IJAEMSJORNAL
 
R Programming: Mathematical Functions In R
R Programming: Mathematical Functions In RR Programming: Mathematical Functions In R
R Programming: Mathematical Functions In RRsquared Academy
 
MH prediction modeling and validation in r (2) classification 190709
MH prediction modeling and validation in r (2) classification 190709MH prediction modeling and validation in r (2) classification 190709
MH prediction modeling and validation in r (2) classification 190709Min-hyung Kim
 
6.3.2 CLIMADA model demo
6.3.2 CLIMADA model demo6.3.2 CLIMADA model demo
6.3.2 CLIMADA model demoNAP Events
 
BIometrics- plotting DET and EER curve using Matlab
BIometrics- plotting DET and EER curve using MatlabBIometrics- plotting DET and EER curve using Matlab
BIometrics- plotting DET and EER curve using MatlabShiv Koppad
 
presentation
presentationpresentation
presentation3ashmawy
 

Similar a How to use R in different professions: R for Car Insurance Product (Speaker: Claudio Giancaterino) (20)

R logistic regression
R   logistic regressionR   logistic regression
R logistic regression
 
R/Finance 2009 Chicago
R/Finance 2009 ChicagoR/Finance 2009 Chicago
R/Finance 2009 Chicago
 
Introducing R package ESG at Rmetrics Paris 2014 conference
Introducing R package ESG at Rmetrics Paris 2014 conferenceIntroducing R package ESG at Rmetrics Paris 2014 conference
Introducing R package ESG at Rmetrics Paris 2014 conference
 
Risk modeling prortfolio diversification 4.0
Risk modeling prortfolio diversification 4.0Risk modeling prortfolio diversification 4.0
Risk modeling prortfolio diversification 4.0
 
Relevance of Particle Swarm Optimization Technique for the Solution of Econom...
Relevance of Particle Swarm Optimization Technique for the Solution of Econom...Relevance of Particle Swarm Optimization Technique for the Solution of Econom...
Relevance of Particle Swarm Optimization Technique for the Solution of Econom...
 
Economic Dispatch of Generated Power Using Modified Lambda-Iteration Method
Economic Dispatch of Generated Power Using Modified Lambda-Iteration MethodEconomic Dispatch of Generated Power Using Modified Lambda-Iteration Method
Economic Dispatch of Generated Power Using Modified Lambda-Iteration Method
 
Generalized Nonlinear Models in R
Generalized Nonlinear Models in RGeneralized Nonlinear Models in R
Generalized Nonlinear Models in R
 
Efficient equity portfolios using mean variance optimisation in R
Efficient equity portfolios using mean variance optimisation in REfficient equity portfolios using mean variance optimisation in R
Efficient equity portfolios using mean variance optimisation in R
 
COMBINED ECONOMIC AND EMISSION DISPATCH WITH AND WITHOUT CONSIDERING TRANSMIS...
COMBINED ECONOMIC AND EMISSION DISPATCH WITH AND WITHOUT CONSIDERING TRANSMIS...COMBINED ECONOMIC AND EMISSION DISPATCH WITH AND WITHOUT CONSIDERING TRANSMIS...
COMBINED ECONOMIC AND EMISSION DISPATCH WITH AND WITHOUT CONSIDERING TRANSMIS...
 
Distributed solution of stochastic optimal control problem on GPUs
Distributed solution of stochastic optimal control problem on GPUsDistributed solution of stochastic optimal control problem on GPUs
Distributed solution of stochastic optimal control problem on GPUs
 
Consider a 4-Link robot manipulator shown below. Use the forward kine.pdf
Consider a 4-Link robot manipulator shown below. Use the forward kine.pdfConsider a 4-Link robot manipulator shown below. Use the forward kine.pdf
Consider a 4-Link robot manipulator shown below. Use the forward kine.pdf
 
Automated Sensing System for Monitoring Road Surface Condition Using Fog Comp...
Automated Sensing System for Monitoring Road Surface Condition Using Fog Comp...Automated Sensing System for Monitoring Road Surface Condition Using Fog Comp...
Automated Sensing System for Monitoring Road Surface Condition Using Fog Comp...
 
R Programming: Mathematical Functions In R
R Programming: Mathematical Functions In RR Programming: Mathematical Functions In R
R Programming: Mathematical Functions In R
 
report_2_v2
report_2_v2report_2_v2
report_2_v2
 
MUMS: Transition & SPUQ Workshop - Practical Bayesian Optimization for Urban ...
MUMS: Transition & SPUQ Workshop - Practical Bayesian Optimization for Urban ...MUMS: Transition & SPUQ Workshop - Practical Bayesian Optimization for Urban ...
MUMS: Transition & SPUQ Workshop - Practical Bayesian Optimization for Urban ...
 
MH prediction modeling and validation in r (2) classification 190709
MH prediction modeling and validation in r (2) classification 190709MH prediction modeling and validation in r (2) classification 190709
MH prediction modeling and validation in r (2) classification 190709
 
6.3.2 CLIMADA model demo
6.3.2 CLIMADA model demo6.3.2 CLIMADA model demo
6.3.2 CLIMADA model demo
 
BIometrics- plotting DET and EER curve using Matlab
BIometrics- plotting DET and EER curve using MatlabBIometrics- plotting DET and EER curve using Matlab
BIometrics- plotting DET and EER curve using Matlab
 
presentation
presentationpresentation
presentation
 
Article 1
Article 1Article 1
Article 1
 

Más de Zurich_R_User_Group

Anomaly detection - database integrated
Anomaly detection - database integratedAnomaly detection - database integrated
Anomaly detection - database integratedZurich_R_User_Group
 
R at Sanitas - Workflow, Problems and Solutions
R at Sanitas - Workflow, Problems and SolutionsR at Sanitas - Workflow, Problems and Solutions
R at Sanitas - Workflow, Problems and SolutionsZurich_R_User_Group
 
Visualizing the frequency of transit delays using QGIS and the Leaflet javasc...
Visualizing the frequency of transit delays using QGIS and the Leaflet javasc...Visualizing the frequency of transit delays using QGIS and the Leaflet javasc...
Visualizing the frequency of transit delays using QGIS and the Leaflet javasc...Zurich_R_User_Group
 
Introduction to Renjin, the alternative engine for R
Introduction to Renjin, the alternative engine for R Introduction to Renjin, the alternative engine for R
Introduction to Renjin, the alternative engine for R Zurich_R_User_Group
 
How to use R in different professions: R In Finance (Speaker: Gabriel Foix, M...
How to use R in different professions: R In Finance (Speaker: Gabriel Foix, M...How to use R in different professions: R In Finance (Speaker: Gabriel Foix, M...
How to use R in different professions: R In Finance (Speaker: Gabriel Foix, M...Zurich_R_User_Group
 
Where South America is Swinging to the Right: An R-Driven Data Journalism Pr...
Where South America is Swinging to the Right:  An R-Driven Data Journalism Pr...Where South America is Swinging to the Right:  An R-Driven Data Journalism Pr...
Where South America is Swinging to the Right: An R-Driven Data Journalism Pr...Zurich_R_User_Group
 
Visualization Challenge: Mapping Health During Travel
Visualization Challenge: Mapping Health During TravelVisualization Challenge: Mapping Health During Travel
Visualization Challenge: Mapping Health During TravelZurich_R_User_Group
 
Zurich R User group: Desc tools
Zurich R User group: Desc tools Zurich R User group: Desc tools
Zurich R User group: Desc tools Zurich_R_User_Group
 
January 2016 Meetup: Speeding up (big) data manipulation with data.table package
January 2016 Meetup: Speeding up (big) data manipulation with data.table packageJanuary 2016 Meetup: Speeding up (big) data manipulation with data.table package
January 2016 Meetup: Speeding up (big) data manipulation with data.table packageZurich_R_User_Group
 
December 2015 Meetup - Shiny: Make Your R Code Interactive - Craig Wang
December 2015 Meetup - Shiny: Make Your R Code Interactive - Craig WangDecember 2015 Meetup - Shiny: Make Your R Code Interactive - Craig Wang
December 2015 Meetup - Shiny: Make Your R Code Interactive - Craig WangZurich_R_User_Group
 

Más de Zurich_R_User_Group (11)

Anomaly detection - database integrated
Anomaly detection - database integratedAnomaly detection - database integrated
Anomaly detection - database integrated
 
R at Sanitas - Workflow, Problems and Solutions
R at Sanitas - Workflow, Problems and SolutionsR at Sanitas - Workflow, Problems and Solutions
R at Sanitas - Workflow, Problems and Solutions
 
Modeling Bus Bunching
Modeling Bus BunchingModeling Bus Bunching
Modeling Bus Bunching
 
Visualizing the frequency of transit delays using QGIS and the Leaflet javasc...
Visualizing the frequency of transit delays using QGIS and the Leaflet javasc...Visualizing the frequency of transit delays using QGIS and the Leaflet javasc...
Visualizing the frequency of transit delays using QGIS and the Leaflet javasc...
 
Introduction to Renjin, the alternative engine for R
Introduction to Renjin, the alternative engine for R Introduction to Renjin, the alternative engine for R
Introduction to Renjin, the alternative engine for R
 
How to use R in different professions: R In Finance (Speaker: Gabriel Foix, M...
How to use R in different professions: R In Finance (Speaker: Gabriel Foix, M...How to use R in different professions: R In Finance (Speaker: Gabriel Foix, M...
How to use R in different professions: R In Finance (Speaker: Gabriel Foix, M...
 
Where South America is Swinging to the Right: An R-Driven Data Journalism Pr...
Where South America is Swinging to the Right:  An R-Driven Data Journalism Pr...Where South America is Swinging to the Right:  An R-Driven Data Journalism Pr...
Where South America is Swinging to the Right: An R-Driven Data Journalism Pr...
 
Visualization Challenge: Mapping Health During Travel
Visualization Challenge: Mapping Health During TravelVisualization Challenge: Mapping Health During Travel
Visualization Challenge: Mapping Health During Travel
 
Zurich R User group: Desc tools
Zurich R User group: Desc tools Zurich R User group: Desc tools
Zurich R User group: Desc tools
 
January 2016 Meetup: Speeding up (big) data manipulation with data.table package
January 2016 Meetup: Speeding up (big) data manipulation with data.table packageJanuary 2016 Meetup: Speeding up (big) data manipulation with data.table package
January 2016 Meetup: Speeding up (big) data manipulation with data.table package
 
December 2015 Meetup - Shiny: Make Your R Code Interactive - Craig Wang
December 2015 Meetup - Shiny: Make Your R Code Interactive - Craig WangDecember 2015 Meetup - Shiny: Make Your R Code Interactive - Craig Wang
December 2015 Meetup - Shiny: Make Your R Code Interactive - Craig Wang
 

Último

AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...chiefasafspells
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburgmasabamasaba
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxAnnaArtyushina1
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2
 

Último (20)

AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 

How to use R in different professions: R for Car Insurance Product (Speaker: Claudio Giancaterino)

  • 1. R for Car Insurance Product Claudio G. Giancaterino 29/11/2016 Zurich R User Group - Meetup
  • 2. Motor Third Party Liability Pricing By the Insurance contract, economic risk is transferred from the policyholder to the Insurer
  • 3. Theoretical Approach  P=E(X)=E(N)*E(Z)  P=Risk Premium  X=Global Loss  E(N)=claim frequency  E(Z)=claim severity  Hp:  1) cost of claims are i.i.d.  2) indipendence between number of claims and cost of claims
  • 4. From Technical Tariff to Commercial Tariff Tariff variables  P=Pcoll*Yh*Xi*Zj=Technical Tariff risk coefficients statistical models are employed  Pt=P*(1+λ)/(1-H)=Commercial Tariff  λ=Safety Loading Rate  H=Loading Rate  P is adjusted by tariff requirement
  • 5. Dataset “ausprivauto0405” within CASdatasets R package  Statistics > str(ausprivauto0405) 'data.frame': 67856 obs. of 9 variables: $ Exposure: num 0.304 0.649 0.569 0.318 0.649 ... $ VehValue: num 1.06 1.03 3.26 4.14 0.72 2.01 1.6 1.47 0.52 $ VehAge: Factor w/ 4 levels "old cars","oldest cars",..: 1 3 3 3 2 $ VehBody: Factor w/ 13 levels "Bus","Convertible",..: 5 5 13 11 5 $ Gender: Factor w/ 2 levels "Female","Male": 1 1 1 1 1 2 2 2 1 $ DrivAge: Factor w/ 6 levels "old people","older work. people",..: 5 2 5 5 $ ClaimOcc: int 0 0 0 0 0 0 0 0 0 0 ... $ ClaimNb: int 0 0 0 0 0 0 0 0 0 0 ... $ ClaimAmount: num 0 0 0 0 0 0 0 0 0 0 ...
  • 6. > table(VehAge,useNA="always") VehAge old cars oldest cars young cars youngest cars <NA> 20064 18948 16587 12257 0 > table(DrivAge,useNA="always") DrivAge old people older work. people oldest people working people 10736 16189 6547 15767 young people youngest people <NA> 12875 5742 0 > table(VehBody,useNA="always") VehBody Bus Convertible Coupe Hardtop 48 81 780 1579 Hatchback Minibus Motorized caravan Panel van 18915 717 127 752 Roadster Sedan Station wagon Truck 27 22233 16261 1750 Utility <NA> 4586 0
  • 8. #mean frequency# > MClaims<-with(rc, sum(ClaimNb)/sum(Exposure)) > MClaims [1] 0.5471511   #mean severity# > MACost<-with(rc, sum(ClaimAmount)/sum(ClaimNb)) > MACost [1] 287.822   #mean risk premium# > MPremium<-with(rc, sum(ClaimAmount)/sum(Exposure)) > MPremium [1] 157.4821 > actuallosses<-with(rc.f, sum(ClaimAmount)) > actuallosses [1] 9342125
  • 9. > library(ggplot2) > ggplot(rc, aes(x = AgeCar))+geom_histogram(stat="bin", bins=30) > ggplot(rc, aes(x = BodyCar))+geom_histogram(stat="bin", bins=30) > ggplot(rc, aes(x = AgeDriver))+geom_histogram(stat="bin", bins=30) > ggplot(rc, aes(x = VehValue))+geom_histogram(stat="bin", bins=30
  • 10.
  • 12. Cluster Analysis by k-means #Prepare Data > rc.stand<-scale(rc[-1]) # To standardize the variables #Determine number of clusters > nk = 2:10 > WSS = sapply(nk, function(k) { + kmeans(rc.stand, centers=k)$tot.withinss + }) > plot(nk, WSS, type="l", xlab="Number of Clusters", + ylab="Within groups sum of squares") #k-means with k = 7 solutions > k.means.fit <- kmeans(rc.stand, 7)
  • 13. 2 4 6 8 10 6000080000100000120000140000 Number of Clusters Withingroupssumofsquares
  • 14. Generalized Linear Models (GLM)Yi~EF(b(θi);Φ/ωi) g(μi)=ηi ηi=Σjxijβj Random Component Link Systematic Component Linear Models are extended in two directions: Probability distribution: Output variables are stochastically independent with the same exponential family distribution. Expected value: There is a link function between expected value of outputs and covariates that could be different from linear regression.
  • 15. GLM Analysis Univariate Approach #stochastic risk premium with GLM approach# > PRSModglm1<-glm(RiskPremium1~AgeCar+BodyCar+VehValue+AgeDriver, + weights=Exposure, data=rc.f, family=gaussian(link=log)) > GLMSRiskPremium1<-predict(PRSModglm1,data=rc.f,type="response") Multivariate Approach #stochastic risk premium with GLM approach# > PRSModglm2<-glm(RiskPremium2~AgeCar*BodyCar*VehValue*AgeDriver, + weights=Exposure, data=rc, family=gaussian(link=log)) > GLMSRiskPremium2<-predict(PRSModglm2,data=rc,type="response")
  • 16. Generalized NonLinear Models (GNM) Yi~EF(b(θi);Φ/ωi) g(μi)=ηi(xij;βj) ηi=Σjxijβj Random Component Link Systematic Component Generalized Linear Models are extended in the link function where the systematic component is non linear in the parameters βj. It can be considered an extension of nonlinear least squares model, where the variance of the output depend on the mean. Difficult are in starting values, they are generated randomly for non linear parameters and using a GLM fit for linear parameters.
  • 17. GNM Analysis Univariate Approach > library(gnm) #stochastic risk premium with GNM approach# > PRSModgnm1<-gnm(RiskPremium1~AgeCar+BodyCar+VehValue+AgeDriver, + weights=Exposure, data=rc.f, family=Gamma(link=log)) > GNMSRiskPremium1<-predict(PRSModgnm1,data=rc.f,type="response") Multivariate Approach > #stochastic risk premium with GNM approach# > PRSModgnm2<-gnm(RiskPremium2~VehValue*AgeDriver*AgeCar*BodyCar, + weights=Exposure, data=rc, family=Gamma(link=log)) > GNMSRiskPremium2<-predict(PRSModgnm2,data=rc,type="response")
  • 18. Generalized Additive Models (GAM) Yi~EF(b(θi);Φ/ωi) g(μi)=ηi ηi= Σpxipβip+Σjfj(xij) Random Component Link Systematic Component Generalized additive models extend generalized linear models in the predictor: systematic component is made up by one parametric part and one non parametric part built by the sum of unknown “smoothing” functions of the covariates. For the estimators are used splines, functions made up by combination of little polynomial segment joined in knots.
  • 19. GAM Analysis Univariate Approach > library(mgcv) #stochastic risk premium with GAM approach# > PRSModgam1<-gam(RiskPremiumgam1~s(AgeCar, bs="cc", k=4) + +s(BodyCar, bs="cc", k=12)+s(VehValue, bs="cc", k=30) + +s(AgeDriver, bs="cc", k=6), weights=Exposure, data=rc, + family=Gamma(link=log)) > GAMSRiskPremium1<-predict(PRSModgam1,data=rc,type="response") Multivariate Approach > #stochastic risk premium with GAM approach# > PRSModgam2<gam(RiskPremiumgam2~te(BodyCar,VehValue,AgeDriver,AgeCar, + k=4),weights=Exposure, data=rc, family="Gamma"(link=log)) > GAMSRiskPremium2<-predict(PRSModgam2,data=rc,type="response") > rc$GAMSRiskPremium2<-with(rc, GAMSRiskPremium2)
  • 20. Mean commercial tariff Tariff requirement Loss Ratio Residuals degrees of freedom Expected Losses Actual Losses Explained Deviance Risk coefficients Uni- GLM 234,4587 1,000490 1,447822 27.501 9.337.547 9.342.125 96,96% 20 Variate GNM 234,4647 1,000476 1,447785 27.501 9.337.683 9.342.125 96,96% 20 Analysis GAM 232,8702 1,001729 1,457698 27.476 9.325.999 9.342.125 96,20% 45 Multi- GLM 234,6486 0,9981246 1,446650 27.505 9.359.678 9.342.125 87,64% 16 Variate GNM 234,6165 0,9979703 1,446848 27.505 9.361.125 9.342.125 87,04% 16 Analysis GAM 248,5732 0,8596438 1,365612 27.265 10.867.438 9.342.125 84,80% 256 Results
  • 21. GLM vs GAM vs GNM Approaches GLM GAM GNM Strengths: -User-friendly -Flexible to fit data -Afford some -Faster elaboration -Realistic values elaboration -Usually low level of excluded by GLM residual deviance -More risk coefficients -Better values despite GLM Weakness: -Poor flexibility -Complex to realize -Complex to use to fit data -Usually higher values of residual deviance -Overestimed values
  • 22. References  C.G. Giancaterino - GLM, GNM and GAM Approaches on MTPL Pricing - Journal of Mathematics and Statistical Science – 08/2016 http://www.ss-pub.org/journals/jmss/vol-2/vol-2-issue-8-august-2016/  X.Marechal & S. Mahy – Advanced Non Life Pricing – EAA Seminar  N. Savelli & G.P. Clemente – Lezioni di Matematica Attuariale delle Assicurazioni Danni – Educatt
  • 23. Many Thanks for your Attention!!! Contact: Claudio G. Giancaterino c.giancaterino@gmail.com