Empirical Bayes estimation for model 1 and 2

Here is some example code on how to estimate claim amounts etc. using Bayesian Credibility Theory for the 2 different models.

model 1:

dat =c()
totclam=matrix(dat,n,N)
totclam

n =ncol(totclam)
Expmth = mean(rowMeans(totclam))
Expsth = mean(apply(totclam,1,var))
v = var(rowMeans(totclam))-mean(apply(totclam,1,var))/n
z=n/(n+Expsth/v)
premium = z*rowMeans(totclam)+(1-z)*Expmth

model 2:

dat =c()
datp=c()
totclam=matrix(dat,n,N)
volume=matrix(datp,n,N)
n =ncol(totclam)
N=nrow(totclam)
X=totclam/volume
Xibar=rowSums(totclam)/rowSums(volume)
Pi=rowSums(volume)
P=sum(Pi)
Pstar=sum(Pi*(1-Pi/P))/(Nn-1)
m=sum(totclam)/P
s=mean(rowSums(volume
(X-Xibar)^2)/(n-1))
v=(sum(rowSums(volume*(X-m)^2))/(nN-1)-s)/Pstar
Zi=Pi/(Pi+s/v)
premium=Zi
Xibar+(1-Zi)*m

Enjoy!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.