[ Info: Precompiling CSV [336ed68f-0bac-5ca0-87d4-7b16caf5d00b]
+Benchmarks
+Categories
Categories
On this page
ExperienceAnalysis.j
Meeting your exposure calculation needs.
QuickStart
-using ExperienceAnalysis
-using Dates
+Quickstart
+df = DataFrame(
+ policy_id = 1:3,
+ issue_date = [Date(2020,5,10), Date(2020,4,5), Date(2019, 3, 10)],
+ end_date = [Date(2022, 6, 10), Date(2022, 8, 10), Date(2022,12,31)],
+ status = ["claim", "lapse", "inforce"]
+)
+
+df.policy_year = exposure.(
+ ExperienceAnalysis.Anniversary(Year(1)),
+ df.issue_date,
+ df.end_date,
+ df.status .== "claim"; # continued exposure
+ study_start = Date(2020, 1, 1),
+ study_end = Date(2022, 12, 31)
+)
+
+df = flatten(df, :policy_year)
-issue = Date(2016, 7, 4)
-termination = Date(2020, 1, 17)
-basis = ExperienceAnalysis.Anniversary(Year(1))
-exposure(basis, issue, termination)
-This will return an array of tuples with a from
and to
date:
-4-element Array{NamedTuple{(:from, :to),Tuple{Date,Date}},1}:
- (from = Date("2016-07-04"), to = Date("2017-07-04"))
- (from = Date("2017-07-04"), to = Date("2018-07-04"))
- (from = Date("2018-07-04"), to = Date("2019-07-04"))
- (from = Date("2019-07-04"), to = Date("2020-01-17"))
+df.exposure_fraction =
+ map(e -> yearfrac(e.from, e.to + Day(1), DayCounts.Thirty360()), df.policy_year)
+# + Day(1) above because DayCounts has Date(2020, 1, 1) to Date(2021, 1, 1) as an exposure of 1.0
+# here we end the interval at Date(2020, 12, 31), so we need to add a day to get the correct exposure fraction.
+policy_idInt64 |
+issue_dateDate |
+end_dateDate |
+statusString |
+policy_year@NamedTuple{from::Date, to::Date, policy\_timestep::Int64} |
+exposure_fractionFloat64 |
+
---|---|---|---|---|---|
1 | +2020-05-10 | +2022-06-10 | +claim | +(from = Date(“2020-05-10”), to = Date(“2021-05-09”), policy_timestep = 1) | +1.0 | +
1 | +2020-05-10 | +2022-06-10 | +claim | +(from = Date(“2021-05-10”), to = Date(“2022-05-09”), policy_timestep = 2) | +1.0 | +
1 | +2020-05-10 | +2022-06-10 | +claim | +(from = Date(“2022-05-10”), to = Date(“2023-05-09”), policy_timestep = 3) | +1.0 | +
2 | +2020-04-05 | +2022-08-10 | +lapse | +(from = Date(“2020-04-05”), to = Date(“2021-04-04”), policy_timestep = 1) | +1.0 | +
2 | +2020-04-05 | +2022-08-10 | +lapse | +(from = Date(“2021-04-05”), to = Date(“2022-04-04”), policy_timestep = 2) | +1.0 | +
2 | +2020-04-05 | +2022-08-10 | +lapse | +(from = Date(“2022-04-05”), to = Date(“2022-08-10”), policy_timestep = 3) | +0.35 | +
3 | +2019-03-10 | +2022-12-31 | +inforce | +(from = Date(“2020-01-01”), to = Date(“2020-03-09”), policy_timestep = 1) | +0.191667 | +
3 | +2019-03-10 | +2022-12-31 | +inforce | +(from = Date(“2020-03-10”), to = Date(“2021-03-09”), policy_timestep = 2) | +1.0 | +
3 | +2019-03-10 | +2022-12-31 | +inforce | +(from = Date(“2021-03-10”), to = Date(“2022-03-09”), policy_timestep = 3) | +1.0 | +
3 | +2019-03-10 | +2022-12-31 | +inforce | +(from = Date(“2022-03-10”), to = Date(“2022-12-31”), policy_timestep = 4) | +0.808333 | +