vitopack collects a handful of utilities for non-life
actuarial work. This vignette walks through the three most common use
cases.
Start from long claims data and aggregate into a triangle:
df <- data.frame(
origin = c(1, 1, 1, 2, 2, 3),
dev = c(0, 1, 2, 0, 1, 0),
paid = c(10, 5, 2, 20, 7, 15)
)
trg <- create_triangle(df,
row_num = "origin",
col_num = "dev",
value = "paid")
trg
#> [,1] [,2] [,3]
#> [1,] 10 5 2
#> [2,] 20 7 NA
#> [3,] 15 NA NACumulate, then read off development factors:
cum <- create_cumulative_triangle(trg)
create_chl_coefs(cum, chl_length = c("full", 2))
#> CH_L_lengths 0 1 2
#> 1 chain_ladder - full NA 1.4 1.133333
#> 2 chain_ladder - 2 NA 1.4 1.133333A weighted variant accepts an explicit weight matrix (e.g. exposure):
weight <- matrix(1, nrow = nrow(cum), ncol = ncol(cum))
weight[is.na(cum)] <- NA
create_chl_coefs_weighted(cum, weight, chl_length = "full")
#> CH_L_lengths 0 1 2
#> 1 chain_ladder - full NA 1.425 1.133333For visual inspection use create_chl_trg_visualization()
(requires the plotly package, listed as a Suggests
dependency).
Turn a policy table into one column per accounting period:
policies <- data.frame(
policy_start = as.Date(c("2024-01-15", "2024-06-01")),
policy_end = as.Date(c("2024-12-31", "2025-05-31"))
)
create_policy_exposure_columns_m(
data = policies,
exp_names = c("exp_q1", "exp_q2", "exp_q3", "exp_q4"),
start_months = c("2024-01-01", "2024-04-01", "2024-07-01", "2024-10-01"),
end_months = c("2024-03-31", "2024-06-30", "2024-09-30", "2024-12-31"),
start_policy_var = "policy_start",
end_policy_var = "policy_end"
)Three slightly different rules for resolving the century are supported.