You are on page 1of 2

data <- policies_matrix

volume <- claims_matrix

#calculating n
n <- ncol(data)
Output: 5

#calculating N
N <- nrow(data)
Output: 4

#calculating Xij
X <- data/volume
Output:
[,1] [,2] [,3] [,4] [,5]

[1,] 19.19929 20.11532 27.87097 25.60058 30.40268

[2,] 38.08743 33.36898 31.61290 32.53968 27.08333

[3,] 22.20859 23.58114 22.37825 22.55401 22.84566

[4,] 20.90190 11.36701 16.68981 15.80851 17.33967

#calculating Xibar
Xibar <- rowSums(data)/rowSums(volume)
Output: 24.73667 32.48666 22.68814 16.28615

#calculating Pibar
Pi <- rowSums(volume)
Output: 307.6 93.7 617.9 262.8

#calculating Pbar
P <- sum(Pi)
Output: 1282

#calculating P*
Pstar <- sum(Pi*(1-Pi/P))/(N*n-1)
Output: 44.71887

#calculating E[m(theta)]
m <- sum(data)/P
Output: 22.58346

#calculating E[s^2(theta)]
s <- mean(rowSums(volume*(X-Xibar)^2)/(n-1))
Output: 620.7337

#calculating var[m(theta)]
v <- (sum(rowSums(volume*(X-m)^2))/(n*N-1)-s)/Pstar
Output: 22.5759

#calculating Zi
Zi <- Pi/(Pi+s/v)
Output: 0.9179475 0.7731316 0.9573976 0.9052847

#calculating premiums
Zi*Xibar+(1-Zi)*m
Output: 24.55999 30.23994 22.68368 16.88260

COMMENTS

You might also like