首页 > 其他分享 >R语言广义线性模型索赔频率预测:过度分散、风险暴露数和树状图可视化|附代码数据

R语言广义线性模型索赔频率预测:过度分散、风险暴露数和树状图可视化|附代码数据

时间:2022-10-23 10:38:29浏览次数:65  
标签:24 树状 average 40 索赔 可视化 65 variance Class

在精算科学和保险费率制定中,考虑到风险敞口可能是一场噩梦。不知何故,简单的结果是因为计算起来更加复杂,只是因为我们必须考虑到暴露是一个异构变量这一事实。

保险费率制定中的风险敞口可以看作是审查数据的问题(在我的数据集中,风险敞口始终小于1,因为观察结果是合同,而不是保单持有人),利息变量是未观察到的变量,因为我们必须为保险合同定价一年(整年)的保险期。因此,我们必须对保险索赔的年度频率进行建模。

在我们的数据集中,我们考虑索赔总数与总风险承担比率。例如,如果我们考虑泊松过程

考虑以下数据集,

>  nombre=rbind(nombre1,nombre2)>  baseFREQ = merge(contrat,nombre)

在这里,我们确实有两个感兴趣的变量,即每张合约的敞口,




>  E <- baseFREQ$exposition


和(观察到的)索赔数量(在该时间段内)




>  Y <- baseFREQ$nbre


无需协变量,可以计算每个合同的平均(每年)索赔数量以及相关的方差


> (mean=weighted.mean(Y/E,E))[1] 0.07279295> (variance=sum((Y-mean*E)^2)/sum(E))[1] 0.08778567


看起来方差(略)大于平均值(我们将在几周后看到如何更正式地对其进行测试)。


可以在保单持有人居住的地区添加协变量,例如人口密度


Density, zone 11 average = 0.07962411  variance = 0.08711477Density, zone 21 average = 0.05294927  variance = 0.07378567Density, zone 22 average = 0.09330982  variance = 0.09582698Density, zone 23 average = 0.06918033  variance = 0.07641805Density, zone 24 average = 0.06004009  variance = 0.06293811Density, zone 25 average = 0.06577788  variance = 0.06726093Density, zone 26 average = 0.0688496   variance = 0.07126078Density, zone 31 average = 0.07725273  variance = 0.09067Density, zone 41 average = 0.03649222  variance = 0.03914317Density, zone 42 average = 0.08333333  variance = 0.1004027Density, zone 43 average = 0.07304602  variance = 0.07209618Density, zone 52 average = 0.06893741  variance = 0.07178091Density, zone 53 average = 0.07725661  variance = 0.07811935Density, zone 54 average = 0.07816105  variance = 0.08947993Density, zone 72 average = 0.08579731  variance = 0.09693305Density, zone 73 average = 0.04943033  variance = 0.04835521Density, zone 74 average = 0.1188611   variance = 0.1221675Density, zone 82 average = 0.09345635  variance = 0.09917425Density, zone 83 average = 0.04299708  variance = 0.05259835Density, zone 91 average = 0.07468126  variance = 0.3045718Density, zone 93 average = 0.08197912  variance = 0.09350102Density, zone 94 average = 0.03140971  variance = 0.04672329


可以可视化该信息




> plot(meani,variancei,cex=sqrt(Ei),col="grey",pch=19, > points(meani,variancei,cex=sqrt(Ei))


 


R语言广义线性模型索赔频率预测:过度分散、风险暴露数和树状图可视化|附代码数据_数据集

圆圈的大小与组的大小有关(面积与组内的总暴露量成正比)。第一个对角线对应于泊松模型,即方差应等于均值。也可以考虑其他协变量

R语言广义线性模型索赔频率预测:过度分散、风险暴露数和树状图可视化|附代码数据_r语言_02

汽车品牌

R语言广义线性模型索赔频率预测:过度分散、风险暴露数和树状图可视化|附代码数据_数据集_03

也可以将驾驶员的年龄视为分类变量



R语言广义线性模型索赔频率预测:过度分散、风险暴露数和树状图可视化|附代码数据_开发语言_04

让我们更仔细地看一下不同年龄段的人,

R语言广义线性模型索赔频率预测:过度分散、风险暴露数和树状图可视化|附代码数据_r语言_05

在右边,我们可以观察到年轻的(没有经验的)驾驶员。那是预料之中的。但是有些类别  低于  第一个对角线:期望的频率很大,但方差不大。也就是说,我们  可以肯定的  是,年轻的驾驶员会发生更多的车祸。相反,它不是一个异类:年轻的驾驶员可以看作是一个相对同质的类,发生车祸的频率很高。

使用原始数据集(在这里,我仅使用具有50,000个客户的子集),我们获得了以下图形:

R语言广义线性模型索赔频率预测:过度分散、风险暴露数和树状图可视化|附代码数据_开发语言_06

由于圈正在从18岁下降到25岁,因此具有明显的经验影响。

同时我们可以发现有可能将曝光量视为标准变量,并查看系数实际上是否等于1。如果没有任何协变量,





Call:glm(formula = Y ~ log(E), family = poisson("log"))

Deviance Residuals:Min 1Q Median 3Q Max-0.3988 -0.3388 -0.2786 -0.1981 12.9036

Coefficients:Estimate Std. Error z value Pr(>|z|)(Intercept) -2.83045 0.02822 -100.31 <2e-16 ***log(E) 0.53950 0.02905 18.57 <2e-16 ***---Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for poisson family taken to be 1)

Null deviance: 12931 on 49999 degrees of freedomResidual deviance: 12475 on 49998 degrees of freedomAIC: 16150

Number of Fisher Scoring iterations: 6

也就是说,该参数显然严格小于1。它与重要性均不相关,




Linear hypothesis test

Hypothesis:log(E) = 1

Model 1: restricted modelModel 2: Y ~ log(E)

Res.Df Df Chisq Pr(>Chisq)1 499992 49998 1 251.19 < 2.2e-16 ***---Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

我也没有考虑协变量,



Deviance Residuals:Min       1Q   Median       3Q      Max-0.7114  -0.3200  -0.2637  -0.1896  12.7104

Coefficients:Estimate Std. Error z value Pr(>|z|)(Intercept) -14.07321 181.04892 -0.078 0.938042log(exposition) 0.56781 0.03029 18.744 < 2e-16 ***carburantE -0.17979 0.04630 -3.883 0.000103 ***as.factor(ageconducteur)19 12.18354 181.04915 0.067 0.946348as.factor(ageconducteur)20 12.48752 181.04902 0.069 0.945011

因此,假设暴露是此处的外生变量可能是一个过强的假设。

接下来我们开始讨论建模索赔频率时的过度分散。在前面,我讨论了具有不同暴露程度的经验方差的计算。但是我只使用一个因素来计算类。当然,可以使用更多的因素。例如,使用因子的笛卡尔积



Class D A (17,24]  average = 0.06274415  variance = 0.06174966Class D A (24,40]  average = 0.07271905  variance = 0.07675049Class D A (40,65]  average = 0.05432262  variance = 0.06556844Class D A (65,101] average = 0.03026999  variance = 0.02960885Class D B (17,24]  average = 0.2383109   variance = 0.2442396Class D B (24,40]  average = 0.06662015  variance = 0.07121064Class D B (40,65]  average = 0.05551854  variance = 0.05543831Class D B (65,101] average = 0.0556386   variance = 0.0540786Class D C (17,24]  average = 0.1524552   variance = 0.1592623Class D C (24,40]  average = 0.0795852   variance = 0.09091435Class D C (40,65]  average = 0.07554481  variance = 0.08263404Class D C (65,101] average = 0.06936605  variance = 0.06684982Class D D (17,24]  average = 0.1584052   variance = 0.1552583Class D D (24,40]  average = 0.1079038   variance = 0.121747Class D D (40,65]  average = 0.06989518  variance = 0.07780811Class D D (65,101] average = 0.0470501   variance = 0.04575461Class D E (17,24]  average = 0.2007164   variance = 0.2647663Class D E (24,40]  average = 0.1121569   variance = 0.1172205Class D E (40,65]  average = 0.106563    variance = 0.1068348Class D E (65,101] average = 0.1572701   variance = 0.2126338Class D F (17,24]  average = 0.2314815   variance = 0.1616788Class D F (24,40]  average = 0.1690485   variance = 0.1443094Class D F (40,65]  average = 0.08496827  variance = 0.07914423Class D F (65,101] average = 0.1547769   variance = 0.1442915Class E A (17,24]  average = 0.1275345   variance = 0.1171678Class E A (24,40]  average = 0.04523504  variance = 0.04741449Class E A (40,65]  average = 0.05402834  variance = 0.05427582Class E A (65,101] average = 0.04176129  variance = 0.04539265Class E B (17,24]  average = 0.1114712   variance = 0.1059153Class E B (24,40]  average = 0.04211314  variance = 0.04068724Class E B (40,65]  average = 0.04987117  variance = 0.05096601Class E B (65,101] average = 0.03123003  variance = 0.03041192Class E C (17,24]  average = 0.1256302   variance = 0.1310862Class E C (24,40]  average = 0.05118006  variance = 0.05122782Class E C (40,65]  average = 0.05394576  variance = 0.05594004Class E C (65,101] average = 0.04570239  variance = 0.04422991Class E D (17,24]  average = 0.1777142   variance = 0.1917696Class E D (24,40]  average = 0.06293331  variance = 0.06738658Class E D (40,65]  average = 0.08532688  variance = 0.2378571Class E D (65,101] average = 0.05442916  variance = 0.05724951Class E E (17,24]  average = 0.1826558   variance = 0.2085505Class E E (24,40]  average = 0.07804062  variance = 0.09637156Class E E (40,65]  average = 0.08191469  variance = 0.08791804Class E E (65,101] average = 0.1017367   variance = 0.1141004Class E F (17,24]  average = 0           variance = 0Class E F (24,40]  average = 0.07731177  variance = 0.07415932Class E F (40,65]  average = 0.1081142   variance = 0.1074324Class E F (65,101] average = 0.09071118  variance = 0.1170159

同样,可以将方差与平均值作图,



> plot(vm,vv,cex=sqrt(ve),col="grey",pch=19,+ xlab="Empirical average",ylab="Empirical variance")> points(vm,vv,cex=sqrt(ve))> abline(a=0,b=1,lty=2)

R语言广义线性模型索赔频率预测:过度分散、风险暴露数和树状图可视化|附代码数据_开发语言_07


标签:24,树状,average,40,索赔,可视化,65,variance,Class
From: https://blog.51cto.com/tecdat/5787168

相关文章