A worked example follows to serve as motivation for the use case.

TODO

library(eltr)

raw_elt <-example_elt

Calculate ELT parameters and modify raw ELT table

elt <- create_elt(raw_elt, ann_rate="rate", mu="mean", sdev_i = "sdevi" , sdev_c = "sdevc", expval = "exp")

elt
#>     id rate  mean sdevi sdevc     exp       mdr sdev  cov        alpha
#>  1:  1 0.10   500   500   200  100000 0.0050000  700 1.40  0.502653061
#>  2:  2 0.10   200   400   100    5000 0.0400000  500 2.50  0.113600000
#>  3:  3 0.20   300   200   400   40000 0.0075000  600 2.00  0.240625000
#>  4:  4 0.10   100   300   500    4000 0.0250000  800 8.00 -0.009765625
#>  5:  5 0.20   500   100   200    2000 0.2500000  300 0.60  1.833333333
#>  6:  6 0.25   200   200   500   50000 0.0040000  700 3.50  0.077306122
#>  7:  7 0.01  1000   500   600  100000 0.0100000 1100 1.10  0.808181818
#>  8:  8 0.12   250   300   100    5000 0.0500000  400 1.60  0.321093750
#>  9:  9 0.14  1000   500   200    6000 0.1666667  700 0.70  1.534013605
#> 10: 10 0.00 10000  1000   500 1000000 0.0100000 1500 0.15 43.990000000
#>             beta  random_num
#>  1:  100.0279592 0.081967213
#>  2:    2.7264000 0.081967213
#>  3:   31.8427083 0.163934426
#>  4:   -0.3808594 0.081967213
#>  5:    5.5000000 0.163934426
#>  6:   19.2492245 0.204918033
#>  7:   80.0100000 0.008196721
#>  8:    6.1007812 0.098360656
#>  9:    7.6700680 0.114754098
#> 10: 4355.0100000 0.000000000

apply Monte Carlo simulation to turn ELT into YLT

ylt <- create_ylt(elt, sims=10 ,ann_rate = "rate" , event_id = "id", expval = "exp" , mu ="mean")

ylt
#>     Year         Loss Event
#>  1:    1 1.082873e+03     9
#>  2:    1 2.360210e+02     5
#>  3:    2 0.000000e+00  None
#>  4:    3 1.481102e-02     2
#>  5:    4 0.000000e+00  None
#>  6:    5 0.000000e+00  None
#>  7:    6 5.988576e-01     6
#>  8:    7 0.000000e+00  None
#>  9:    8 6.080306e+02     8
#> 10:    9 0.000000e+00  None
#> 11:   10 1.990766e+02     5

apply insurance structure to calculate limited losses


# Layer 500 xs 50

ylt[ , layer1_loss := layer_loss(Loss, Excess = 50 , Limit = 500  ) ] 

ylt
#>     Year         Loss Event layer1_loss
#>  1:    1 1.082873e+03     9    500.0000
#>  2:    1 2.360210e+02     5    186.0210
#>  3:    2 0.000000e+00  None      0.0000
#>  4:    3 1.481102e-02     2      0.0000
#>  5:    4 0.000000e+00  None      0.0000
#>  6:    5 0.000000e+00  None      0.0000
#>  7:    6 5.988576e-01     6      0.0000
#>  8:    7 0.000000e+00  None      0.0000
#>  9:    8 6.080306e+02     8    500.0000
#> 10:    9 0.000000e+00  None      0.0000
#> 11:   10 1.990766e+02     5    149.0766

Summarise losses by year and calculated average expected loss



ann <-ylt[, lapply( .SD , sum), by=Year, .SDcols = c("Loss","layer1_loss") ] 

ann
#>     Year         Loss layer1_loss
#>  1:    1 1.318894e+03    686.0210
#>  2:    2 0.000000e+00      0.0000
#>  3:    3 1.481102e-02      0.0000
#>  4:    4 0.000000e+00      0.0000
#>  5:    5 0.000000e+00      0.0000
#>  6:    6 5.988576e-01      0.0000
#>  7:    7 0.000000e+00      0.0000
#>  8:    8 6.080306e+02    500.0000
#>  9:    9 0.000000e+00      0.0000
#> 10:   10 1.990766e+02    149.0766

expected_loss <- ann[ , lapply(.SD, mean) , .SDcols = c("Loss","layer1_loss")      ]

expected_loss
#>        Loss layer1_loss
#> 1: 212.6614    133.5098

Calculate OEP


ep <-create_oep_curve(ann , y= "Year", z="Loss")
ep
#>     return_period          OEP
#>  1:         10000 1.318254e+03
#>  2:          5000 1.317614e+03
#>  3:          1000 1.312496e+03
#>  4:           500 1.306098e+03
#>  5:           250 1.293302e+03
#>  6:           200 1.286905e+03
#>  7:           100 1.254916e+03
#>  8:            50 1.190938e+03
#>  9:            25 1.062983e+03
#> 10:            10 6.791169e+02
#> 11:             5 2.808674e+02
#> 12:             2 7.405512e-03

calculate AAL and OEP