我正在使用泊松过程计算使用 8 种不同的索赔率(提出索赔的概率)向保单持有人收取的保费。使用此代码的值是:568.48 625.44 684.34 732.58 772.40 802.90 832.46 851.66 这些值与我在 Excel 中得到的正确值和理论上计算的值不同:517.4 550.26 601.14 650.96 705.86 757.4 4 796.1 任何人都可以尝试正确的 R 代码 8296 来获得这些值。 ?
a <- array(0:0,dim=c(21,5000)) # over time period t=21, 5000 policy holders
d<-array(1:5)
e<-array(1:5) # five discount levels used
p<-array(1:8) # premium charged for 8 separate claim rates
z=0
e[1]=1 # discount 0%
e[2]=.8 # discount 20%
e[3]=.7 # discount 30%
e[4]=.6 # discount 40%
e[5]=.5 # discount 50%
for (l in seq(0.1,0.8,.1)){ # claim rates 0.1,0.2,0.3...0.8
for (j in 1:20){
for (i in 1:5000) {
b<-min(2,rpois(1,l))
if (b==2) {a[j+1,i]=0} # b is the number of claims made, if 2 or more, drop down to 0% discount
if (b==0) {a[j+1,i]=min(5,a[j,i]+1)} # if 0 claims made, go to next level of discount
if (b==1) {a[j+1,i]=max(0,a[j,i]-1)} # if 1 claim made, drop back one discount level
}
}
for (k in 1:5){
d[k]=1000*e[k]*(length(subset(a[5,],a[5,]==k-1))/5000)
}
z=z+1;p[z]=sum(d)
}
p # premium charged at each claim rate 0.1,0.2, ... , 0.8