#
# 1 create an example ELT
#
nevents=1000
totalannualrate=3
evid=c(1:nevents)
mloss=(c(1:nevents)^2)/100 #max is 10k
mrate=rep(totalannualrate/nevents,nevents)
elt=data.frame(evid,mrate,mloss)
#
# 2 example 1
#
message("**************************************************************")
message("Example 1: 2 years of simulation, 2 layers, detailed outputs  ")
message("**************************************************************")
#
# 3 simulate a 2 year YLT
#
nyears=2
set.seed(3)
ylt=yltsim(nyears=nyears,elt)
#
# 4 set up 2 catXL layers
#
limit=c(2000,4000)
deductible=c(1000,3000)
nrst=c(2,2)
premium=1000
rst_premium_pc=c(80,90)
#
# 5 analyze the catXL
#
catxlresults=catxl(ylt,limit,deductible,nrst,premium,rst_premium_pc)
#
# 6 look at the results
#
message("\nsummary:")
print(catxlresults$summary)
message("\nshortrecord:")
print(catxlresults$shortrecord)
message("\nlongrecord:")
print(catxlresults$longrecord)
#
# 7 example 2
#
message("**************************************************************")
message("Example 2: 1k years of simulation, 1 layer, summary outputs")
message("**************************************************************")
nyears=100
#
# 8 simulate 2x 1k YLTs to investigate convergence
#
set.seed(1);ylt1=yltsim(nyears=nyears,elt)
set.seed(2);ylt2=yltsim(nyears=nyears,elt)
#
# 9 set up 1 catXL layer this time
#
limit=c(2000)
deductible=c(1000)
nrst=c(1)
premium=1000
rst_premium_pc=c(80)
#
# 10 analyze the catXL and look at the summary results
#
message("\nylt1 summary:")
print(catxl(ylt1,limit,deductible,nrst,premium,rst_premium_pc)$summary)
message("\nylt2 summary:")
print(catxl(ylt2,limit,deductible,nrst,premium,rst_premium_pc)$summary)
