portfolio <- data.frame(
policy_id = 1:10,
sector = rep(c("Industry", "Retail"), each = 5),
claim_count = c(
0, 1, 1, 1, 1,
0, 1, 1, 1, 1
),
claim_amount = c(
0, 25000, 120000, 50000, 175000,
0, 40000, 90000, 150000, 300000
),
policy_years = rep(1, 10)
)
thresholds <- assess_excess_threshold(
data = portfolio,
claim_amount = "claim_amount",
thresholds = c(25000, 50000, 100000, 150000),
exposure = "policy_years",
group = "sector",
claim_count = "claim_count"
)
thresholds
if (requireNamespace("gt", quietly = TRUE)) {
as_gt(thresholds)
}
# Calculate the average additional risk premium required to finance
# the excess portion of the claims.
thresholds |>
dplyr::summarise(
policy_years = sum(policy_years),
excess_loss = sum(excess_loss),
capped_loss = sum(capped_loss),
extra_risk_premium = excess_loss / policy_years,
risk_premium_increase = excess_loss / capped_loss,
.by = "threshold"
)
# After selecting a threshold, compare which groups benefit most
# from the excess protection.
selected_threshold <- thresholds |>
dplyr::filter(threshold == 100000) |>
dplyr::select(
sector,
threshold,
policy_years,
n_claims,
n_excess_records,
premium_reduction,
premium_reduction_ratio
) |>
dplyr::arrange(dplyr::desc(premium_reduction_ratio))
selected_threshold
# If claim_count is omitted, records with positive claim amounts are counted.
assess_excess_threshold(
data = portfolio,
claim_amount = "claim_amount",
thresholds = 100000,
exposure = "policy_years",
group = "sector"
)
Run the code above in your browser using DataLab