Skip to contents

The claims development result (CDR) over the coming year of bayes_hierarchical_bf() for every program at once, by Pareto smoothed importance sampling of the posterior (decisions 17 and 30 of docs/design/reserving-bayes.md), as bayes_bf_normalised_one_year() does for one triangle. bayes_hierarchical_bf_one_year() fits the posterior and the lifetime reserves as bayes_hierarchical_bf() does with the same settings. Each simulation draws the year's increments of every program from a posterior draw with process error, reweights every posterior draw by the year's quasi likelihood (the scales, the priors and the prior ultimates unchanged), and takes each origin's CDR as its posterior mean reserve at the opening less its payment in the year and its weighted posterior mean reserve after it; a simulation whose Pareto k is above k_threshold is moment-matched and, if that cannot rescue it, refitted with NUTS, as refit says. A refit samples the whole panel.

Usage

hierarchical_bf_one_year_fit(ptr)

bayes_hierarchical_bf_one_year(
  triangle,
  column,
  exposure,
  apriori = 1,
  level_cv = NULL,
  cv = 0.1,
  development_sd = 10,
  tau_scale = 0.3,
  omega_scale = 0.5,
  process = c("gamma", "none"),
  chains = 4,
  tune = 1000,
  draws = 1000,
  n_sims = 10000,
  seed = 0,
  target_accept = 0.99,
  max_depth = 10,
  pattern_prior = NULL,
  k_threshold = 0.7,
  refit = c("moment_match_then_refit", "refit_flagged", "reweight_only", "refit_all"),
  max_refits = NULL,
  one_year_sims = NULL,
  light_refit = NULL
)

Arguments

ptr

A HierarchicalBfOneYearFit pointer; used internally.

triangle

A cumulative triangle with a segment per program, all on the same ages, every origin observed from the first age up to its latest. A triangle with one segment is one program. Or a named list of triangles, one program each: every one a triangle with one segment, with the column and the exposure and the same grains and cumulative state. They are stacked into a triangle with a segment per program under the key program (any keys they carry are dropped), and the fit equals, draw for draw, the fit of the same panel given as one triangle with that key. The names label the programs, which run in the sorted order of their names, as the segments of a triangle do, not in the list's order.

column

Name of the loss column to fit.

exposure

Name of the exposure column; each origin's latest observed value is its exposure.

apriori

Prior mean of the industry loss ratio L.

level_cv

Coefficient of variation of the lognormal prior on L, or NULL for a prior flat on log L.

cv

Coefficient of variation of each origin's expected ultimate about its program's level; fixed, finite and positive.

development_sd

Standard deviation of the normal prior on each shared beta[d], centred on 0; ignored with a pattern_prior.

tau_scale

Scale of the half-normal prior on tau, the spread of the programs' log loss ratios.

omega_scale

Scale of the half-normal prior on omega, the spread of the programs' log share ratios.

process

Process error on each simulated future increment: "gamma" or "none" for parameter error only.

chains, tune, draws

NUTS chains, warm-up draws per chain and kept draws per chain.

n_sims

Number of predictive simulations; positive.

seed

Seed of the chains and of the simulations, a non-negative whole number.

target_accept

Target mean acceptance rate of the step-size adaptation (default 0.99).

max_depth

Largest NUTS tree depth.

pattern_prior

A pattern_prior() on the triangle's ages for the shared pattern, or NULL.

k_threshold

The Pareto k above which a simulation's importance weights are not trusted (the threshold of Vehtari et al. 2024 for a few thousand draws).

refit

What happens to a flagged simulation: "moment_match_then_refit" (the default) moves the posterior draws by affine maps to the moments the weights estimate (moment matching, as loo::loo_moment_match()), refitting only a simulation whose k stays above k_threshold; "refit_flagged" refits it with NUTS; "reweight_only" reweights it anyway (fast, biased where k is high); "refit_all" refits every simulation, to check the reweighting.

max_refits

The most simulations refitted with NUTS: the first this many due for a refit, in simulation order; the others are reweighted as they are (as unreliable as their k says), listed in unrefitted and warned about. NULL (the default) refits every one, 0 none. In the _segments functions it applies to each segment, so k segments refit at most k times this many.

one_year_sims

The number of one-year simulations, or NULL (the default) for the model's n_sims, at most 2,000. The lifetime reserves keep n_sims. A smaller count gives the first simulations of a larger one.

light_refit

The sampler of the refits: a shorter, warm-started NUTS run instead of the fit's own. NULL (the default) is the model's own when refit is left at its default, the light refit of TRUE below, and the fit's sampler, with its pilot run, when refit is given. TRUE takes 4 chains of 150 warm-up and 250 kept draws, c(chains, tune, draws) its own, and FALSE turns a default light refit off. Each refit scales its sampler by the opening posterior and starts at its mean, with no pilot run, and warns when its closing reserve has R-hat above 1.05, fewer than 100 effective draws or a divergence.

Value

A hierarchical_bf_one_year_fit object.

Details

It is one view over the stacked programs and not one per program, because a program's next diagonal moves the industry level L, the spreads tau and omega and the shared pattern, and through them the other programs' closing reserves. The CDR is one joint predictive_distribution with dimensions program and origin, so a program's CDR is aggregate(view@cdr, "program") and the dependence between programs is kept.

Failed MCMC diagnostics of the fit raise one warning() listing them, and refits that failed theirs raise another. A panel whose programs stop at different ages raises one more, naming the programs whose next diagonal falls at development ages they have never observed: only the prior speaks there, so nearly every simulation is flagged and refitted and the view is expensive (or, with refit = "reweight_only", approximate; warnings).

Properties: fit (the hierarchical_bf_fit), per origin, program by program, program, origins, latest, opening_ultimate and opening_reserve (the posterior mean reserve on the observed triangle), cdr (a negative value is an adverse development, and -quantile(view@cdr, 0.005) is the one-year loss at 99.5%), pareto_k (one per simulation, Inf when too few weights differ to fit the tail), refitted (the simulations refitted with NUTS, 1-based), moment_matched (the simulations moment matching rescued, 1-based), unrefitted (the simulations due for a refit beyond max_refits, reweighted instead, 1-based), refit_warnings, k_threshold, flagged_share and warnings (what else the view warns of, one string each, empty when the programs share their ages). as.data.frame() has one row per program and origin: program, origin, latest, opening_ultimate, opening_reserve, and the cdr_mean and cdr_std_dev of the CDR.

Errors: as bayes_hierarchical_bf(); a k_threshold that is NaN.

This is Python's HierarchicalBf.one_year().

Examples

long <- data.frame(
  program = c(rep("a", 6), rep("b", 3)),
  year = c(2021, 2021, 2021, 2022, 2022, 2023, 2022, 2022, 2023),
  age = c(12, 24, 36, 12, 24, 12, 12, 24, 12),
  paid = c(100, 150, 170, 110, 172, 130, 55, 80, 60),
  premium = c(250, 250, 250, 270, 270, 290, 120, 120, 130))
tri <- triangle(long, "year", "age", c("paid", "premium"), keys = "program")
view <- bayes_hierarchical_bf_one_year(tri, "paid", "premium", apriori = 0.7,
                                       level_cv = 0.2, chains = 2, tune = 200, draws = 200,
                                       n_sims = 500, seed = 1, refit = "reweight_only")
#> Warning: bayes_hierarchical_bf_one_year: the MCMC diagnostics failed; check them before relying on the fit: log_tau: R-hat 1.0586 is above 1.01; log_tau: bulk ESS 119 is below 200 (100 per chain); log_tau: tail ESS 120 is below 200 (100 per chain); z[1]: R-hat 1.0119 is above 1.01; z[2]: R-hat 1.0103 is above 1.01; alpha[2,2]: tail ESS 165 is below 200 (100 per chain); beta[2]: R-hat 1.0392 is above 1.01; beta[2]: bulk ESS 60 is below 200 (100 per chain); beta[2]: tail ESS 115 is below 200 (100 per chain); beta[3]: bulk ESS 148 is below 200 (100 per chain); beta[3]: tail ESS 135 is below 200 (100 per chain); log_omega: bulk ESS 74 is below 200 (100 per chain); log_omega: tail ESS 130 is below 200 (100 per chain); delta[1,2]: R-hat 1.0355 is above 1.01; delta[1,2]: bulk ESS 79 is below 200 (100 per chain); delta[1,2]: tail ESS 164 is below 200 (100 per chain); delta[2,2]: R-hat 1.0358 is above 1.01; delta[2,2]: bulk ESS 81 is below 200 (100 per chain); delta[2,2]: tail ESS 170 is below 200 (100 per chain); delta[2,3]: R-hat 1.0121 is above 1.01
#> Warning: bayes_hierarchical_bf_one_year: programs whose next diagonal falls at development ages they have never observed: b (observed to age 24, its next diagonal to 36). Only the prior speaks for those ages, so nearly every one-year simulation is flagged (Pareto k above the threshold), and since the view reweights only, its weights are unreliable and the view is approximate (a refit mode refits them, at a cost)
view@flagged_share
#> [1] 0.432
sqrt(variance(aggregate(view@cdr, "program")))
#> [1] 15.02995
as.data.frame(view)
#>   program origin latest opening_ultimate opening_reserve    cdr_mean
#> 1       a   2021    170        170.00000         0.00000  0.00000000
#> 2       a   2022    172        194.64684        22.64684  0.14574528
#> 3       a   2023    130        222.81642        92.81642 -0.22936885
#> 4       b   2022     80         90.71335        10.71335 -0.06809839
#> 5       b   2023     60         99.75151        39.75151 -0.18410271
#>   cdr_std_dev
#> 1    0.000000
#> 2    3.982612
#> 3    7.360440
#> 4    3.981351
#> 5    5.197803