Skip to contents

The claims development result over the coming year of Gesmann and Morris' compartmental model (compartmental()), by Pareto smoothed importance sampling of its posterior (decision 20 of docs/design/reserving-bayes.md). The posterior and the lifetime reserves are compartmental()'s for the same settings. Each simulation picks a posterior draw, draws the paid and outstanding of the cells valued in the next twelve months from it (every origin's next diagonal), reweights every posterior draw by the likelihood of those cells, and smooths the weights (one Pareto k per simulation). Origin w's claims development result is the expected paid to the square's last age given the observed cells, less the year's paid and the same expectation given the year too; its mean is about zero. An origin with no observed cell (1997 on the papers' triangle) and, with development effects (model 2), an age with none take their effects as part of each posterior draw, so the year's cells update them.

Usage

compartmental_one_year_fit(ptr)

compartmental_one_year(
  triangle,
  paid,
  premium,
  priors,
  outstanding = NULL,
  incurred = NULL,
  likelihood = c("normal", "lognormal"),
  scale = c("amount", "loss_ratio"),
  paid_response = c("cumulative", "incremental"),
  rate_order = c("free", "ordered"),
  development_levels = c("per_age", "by_year"),
  start = c("data", "prior_centre"),
  chains = 4,
  tune = 1000,
  draws = 2000,
  n_sims = 10000,
  seed = 0,
  target_accept = 0.99,
  max_depth = 10,
  k_threshold = 0.7,
  refit = NULL,
  max_refits = NULL,
  one_year_sims = NULL,
  light_refit = NULL
)

compartmental_model_2_one_year(
  triangle,
  paid,
  premium,
  priors,
  outstanding = NULL,
  incurred = NULL,
  rate_order = c("free", "ordered"),
  development_levels = c("per_age", "by_year"),
  start = c("data", "prior_centre"),
  chains = 4,
  tune = 2000,
  draws = 8000,
  n_sims = 10000,
  seed = 0,
  target_accept = 0.999,
  max_depth = 10,
  k_threshold = 0.7,
  refit = NULL,
  max_refits = NULL,
  one_year_sims = NULL,
  light_refit = NULL
)

compartmental_one_year_fits(ptr)

compartmental_one_year_segments(
  triangle,
  paid,
  premium,
  priors,
  outstanding = NULL,
  incurred = NULL,
  likelihood = c("normal", "lognormal"),
  scale = c("amount", "loss_ratio"),
  paid_response = c("cumulative", "incremental"),
  rate_order = c("free", "ordered"),
  development_levels = c("per_age", "by_year"),
  start = c("data", "prior_centre"),
  chains = 4,
  tune = 1000,
  draws = 2000,
  n_sims = 10000,
  seed = 0,
  target_accept = 0.99,
  max_depth = 10,
  dependence = c("independent", "rank_correlation", "synchronized"),
  spearman = NULL,
  k_threshold = 0.7,
  refit = NULL,
  max_refits = NULL,
  one_year_sims = NULL,
  light_refit = NULL
)

Arguments

ptr

A CompartmentalOneYearFit or CompartmentalOneYearFits pointer; used internally.

triangle

A cumulative triangle with one segment.

paid

Name of the column of cumulative paid amounts.

premium

Name of the column with each origin's premium (its latest value); the fit's origins are this column's.

priors

A compartmental_priors list; required.

outstanding

Name of a column of outstanding amounts.

incurred

Name of a column of incurred amounts: outstanding is incurred less paid, cell by cell (the papers' outstanding on company 337 is incurred with bulk and IBNR less paid). Give exactly one of outstanding and incurred, or neither under fitted = "paid_only".

likelihood

"normal" (model 1) or "lognormal" (model 2).

scale

The response scale: "amount" (model 1) or "loss_ratio", amounts over the origin's premium (model 2).

paid_response

"cumulative" (model 1) or "incremental" (model 2).

rate_order

"free" or "ordered", as above.

development_levels

The width of a development level, for priors with development effects (model 2): "per_age" (the default), one level for each age, or "by_year", one for each development year (counted from the origin's start: ages 1 to 12 months, 13 to 24 and so on). Choose with bayes_loo(); see "Fitting sub-annual data" in compartmental(). The same fit at annual grain. An error for "by_year" with priors that have no development effects (model 1).

start

Where the pilot run starts: "data", a least-squares fit of the population curve (the prior centre if that fit fails, and under one response if its log posterior is below the prior centre's), or "prior_centre".

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 (the paper's adapt_delta, 0.99).

max_depth

Largest NUTS tree depth.

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, as in bayes_odp_one_year(), or NULL (the default) for the model's own: "moment_match_then_refit" without development effects (model 1), "refit_flagged" with the light refit with them (model 2; light_refit = FALSE makes it "reweight_only", with a warning).

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 n_sims capped at 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: the light refit for model 2 when refit is NULL, the fit's own sampler otherwise. TRUE takes 4 chains of 150 warm-up and 250 kept draws, c(chains, tune, draws) its own. FALSE turns model 2's default off: with refit = NULL the view reweights only and is approximate, with a warning. Each refit scales its sampler by the opening posterior and starts there, with no pilot run. On company 337 it comes within about 0.03 sd of the total claims development result of a full refit of model 2. A refit warns when its closing reserve has R-hat above 1.05, fewer than 100 effective draws or a divergence.

dependence

How the segments depend on each other: "independent", each segment's own view; or "rank_correlation", the segments' claims development results reordered as whole rows to the Spearman matrix spearman (an Iman-Conover reorder on the segments' total results). "synchronized" is accepted as odp_bootstrap() takes it, and is an error here.

spearman

With dependence = "rank_correlation" only: Spearman's rho between the segments' total claims development results, as odp_bootstrap()'s.

Value

A compartmental_one_year_fit object, or for compartmental_one_year_segments() a compartmental_one_year_fits.

Details

A simulation whose k is above k_threshold is flagged and handled as refit says (as bayes_odp_one_year()). On company 337 about four in five of model 1's simulations are flagged and all of model 2's; for model 1 moment matching rescues about nineteen in twenty of them, for model 2 none, and a refit takes as long as a fit (for model 2 about 31 s of wall time with 8 running side by side). So by default (refit = NULL, the user's decisions of 2026-10-16 and 2026-10-21) model 1 moment-matches its flagged simulations and refits with NUTS only those whose k stays above the threshold, and a model with development effects (model 2) refits them with the light refit (light_refit): a warm-started NUTS run of 4 chains, 150 warm-up and 250 kept draws, within about 0.03 sd of the total claims development result of a full refit, at about 20 times the run time of reweighting only (about 30 minutes for the default 2,000 simulations on company 337). light_refit = FALSE turns it off: model 2 then reweights its flagged simulations only, which is approximate (about 0.4 sd off a refit per simulation) and warns so (approximate). An explicit refit is used as it is, with the fit's own sampler unless light_refit is given, and max_refits a budget. The view runs one_year_sims simulations, by default n_sims capped at 2,000. compartmental_model_2_one_year() takes model 2's settings, as compartmental_model_2().

Failed MCMC diagnostics of the fit raise one warning() listing them, refits that failed theirs raise another, simulations left unrefitted by max_refits another, and a view that reweights only (model 2 with light_refit = FALSE) and is approximate another.

Properties of a compartmental_one_year_fit: fit (the compartmental_fit), origins (the premium column's), per origin latest_paid, opening_ultimate and opening_reserve (the posterior mean reserve on the observed triangle); cdr, a predictive_distribution of the claims development result with dimension origin (a negative value is an adverse development); pareto_k, refitted, moment_matched and unrefitted (1-based), refit_warnings, k_threshold and flagged_share, as a bayes_one_year_fit's; approximate, why the view is approximate (NULL unless the model's default reweighted only). as.data.frame() has one row per origin: origin, premium, latest_paid, opening_ultimate, opening_reserve, and the cdr_mean and cdr_std_dev of the claims development result; totals_frame() their totals and the flagged_share.

compartmental_one_year_segments() is the view of every segment of a triangle, each segment as compartmental_one_year() views it (its own premium column and outstanding cells, the same defaults, max_refits a budget of each segment) on the seeds of compartmental_segments(): a segment's simulations differ from compartmental_one_year() of that segment alone. The segments' claims development results are joined by row as dependence says, "independent" as drawn or "rank_correlation" by Iman-Conover on their totals. A compartmental_one_year_fits has origins, premium, latest_paid, opening_ultimate and opening_reserve (each segment's origins in turn), cdr (a predictive_distribution with the triangle's keys first among its dimensions), approximate, k_threshold, diagnostics (a data.frame with one row per segment, as compartmental_fits's), and for a single-segment fit pareto_k, refitted, moment_matched, unrefitted, refit_warnings, flagged_share, summary and draws; with several segments use segment() or totals_frame(), which has the flagged shares. Failed diagnostics, refits and an approximate view each raise one warning(), the first two naming the segments.

Errors: as compartmental(); a k_threshold that is NaN; dependence = "synchronized", or a spearman matrix that does not fit the segments, before any sampling.

This is Python's Compartmental.one_year(), which returns a CompartmentalOneYearFit, and Compartmental.one_year_segments(), which returns a CompartmentalOneYearFits.

Examples

long <- data.frame(year = rep(1988:1992, 5:1),
                   age = unlist(lapply(5:1, function(k) 12 * seq_len(k))),
                   paid = c(9.6, 22.8, 33.3, 40.3, 45.1, 7.9, 19.5, 29.6, 36.8,
                            8.7, 24.3, 35.4, 13.3, 33.0, 11.4),
                   incurred = c(62.7, 64.0, 65.6, 65.3, 62.3, 62.1, 56.7, 56.6, 56.8,
                                64.0, 61.5, 63.2, 73.9, 75.1, 77.1),
                   premium = rep(c(104.4, 88.9, 86.0, 99.3, 104.9), 5:1))
tri <- triangle(long, "year", "age", c("paid", "incurred", "premium"))
# Short chains, and reweighting only, for the example.
view <- suppressWarnings(compartmental_one_year(
  tri, "paid", "premium", gesmann_morris_priors(), incurred = "incurred", chains = 2,
  tune = 150, draws = 150, target_accept = 0.9, n_sims = 500, refit = "reweight_only"))
view@flagged_share
#> [1] 0.086
# The one-year view is narrower than the lifetime view.
c(one_year = sqrt(variance(view@cdr)), lifetime = sqrt(variance(view@fit@reserves)))
#>  one_year  lifetime 
#>  9.080894 12.694485 
as.data.frame(view)
#>   origin premium latest_paid opening_ultimate opening_reserve  cdr_mean
#> 1   1988   104.4        45.1         45.10000       0.0000000 0.0000000
#> 2   1989    88.9        36.8         35.73072      -1.0692788 0.5620607
#> 3   1990    86.0        35.4         35.20009      -0.1999109 0.1063406
#> 4   1991    99.3        33.0         40.79804       7.7980443 0.1273030
#> 5   1992   104.9        11.4         42.24489      30.8448944 0.1450260
#>   cdr_std_dev
#> 1    0.000000
#> 2    5.748757
#> 3    1.441152
#> 4    1.817318
#> 5    1.625703