Meyers' CRC, CSR and CAY models over segments
meyers_fits.Rdmeyers() fitted to every segment of a triangle column, each segment
with its own posterior (the same model and settings, sampled
independently) and its premium from its own premium column as
meyers() reads it, into joint posterior predictive distributions of
the ultimates and of the reserves laid out as bayes_odp_segments()'s,
the segments depending on each other as dependence says. Segment k
(in index order) takes seeds derived from seed and k for its chains
and its simulations, so independent segments share no random numbers,
and a segment's draws differ from meyers() of that segment alone.
Under dependence = "rank_correlation" each segment's ultimates move
with its reserves, simulation by simulation, so each row's ultimates
less its reserves stay the latest values. Failed MCMC diagnostics raise
one warning() listing every segment's messages, each prefixed with
its segment's label.
Usage
meyers_fits(ptr)
meyers_segments(
triangle,
column,
premium,
model = c("crc", "csr", "cay"),
logelr_mean = -0.4,
logelr_sd = 3.162,
origin_sd = 3.162,
development_sd = 3.162,
gamma_sd = 0.05,
rho_shape = 2,
chains = 4,
tune = 1000,
draws = 2000,
n_sims = 10000,
seed = 0,
target_accept = 0.95,
max_depth = 10,
dependence = c("independent", "rank_correlation", "synchronized"),
spearman = NULL
)Arguments
- ptr
A
MeyersFitspointer; used internally.- triangle
A cumulative triangle with any number of segments, every origin observed from the first age up to its latest.
- column
Name of the column to fit: paid, or case incurred.
Name of the column with each origin's premium (its latest value, as
cape_cod()reads exposure).- model
"crc", the correlated chain ladder without its correlation between origins,"csr", the changing settlement rate model, or"cay", the correlated accident year model.- logelr_mean, logelr_sd
Mean and standard deviation of the normal prior on
logelr, the log expected loss ratio (3.162 is Meyers' rounding ofsqrt(10)).- origin_sd
Standard deviation of the normal prior on each origin effect
alpha[w],w >= 2.- development_sd
Standard deviation of the normal prior on each development effect
beta[d],d < m.- gamma_sd
Standard deviation of the normal prior on
gamma("csr"only).- rho_shape
Both shapes of the beta prior on
(1 - rho) / 2("cay"only); Meyers' 2 makes the prior density ofrhoproportional to1 - rho^2.- chains, tune, draws
NUTS chains, warm-up draws per chain and kept draws per chain; with 1,000 kept draws the late
sigma[d]sometimes miss the R-hat threshold.- n_sims
Number of predictive simulations, independent of the number of posterior draws; 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; at NUTS's usual 0.8 the paid fits of group 353 leave divergent transitions.
- max_depth
Largest NUTS tree depth.
- dependence
How the segments depend on each other:
"independent", each segment's own posterior and simulations; or"rank_correlation", the segments' simulations reordered as whole rows (Iman-Conover on the segments' total reserves) to the Spearman matrixspearmanand put in a random order, asodp_bootstrap()'s."synchronized"is accepted asodp_bootstrap()takes it, and is an error here.- spearman
With
dependence = "rank_correlation"only: Spearman's rho between the segments' total reserves, asodp_bootstrap()'s.
Details
Properties of the fit: model, chain_ladder (the volume-weighted
chain_ladder_fit of every segment), origins, development,
premium (each segment's origins in turn, in the order of origins),
ultimates and reserves (predictive_distributions with the
triangle's keys and origin as dimensions, one component per segment
and origin, so aggregate(fit@reserves, keep = "lob") keeps the
dependence between segments) and diagnostics (a data.frame with one
row per segment: the key columns, max_rhat, min_ess_bulk,
min_ess_tail, divergences and warnings, the segment's messages
joined by "; "). summary, draws and bayes_loo() are those of
meyers_fit and need a single-segment fit: with several segments use
segment(). as.data.frame(), totals_frame() (with each segment's
total premium and the moments of its total ultimate),
development_frame() and segment() work as for meyers().
Errors: as meyers() for any segment (the message names the segment);
dependence = "synchronized", before any sampling, since a posterior
has no residuals to share; or a spearman matrix that does not fit the
segments.
Examples
paid <- c(952, 1529, 2813, 3647, 3724, 849, 1564, 2202, 2432, 983, 2211, 2830,
1657, 2685, 932)
one <- data.frame(year = rep(1988:1992, 5:1),
age = unlist(lapply(5:1, function(k) 12 * seq_len(k))),
paid = paid,
premium = rep(c(5812, 4908, 5454, 5165, 5214), 5:1))
two <- one
two[c("paid", "premium")] <- 2 * two[c("paid", "premium")]
long <- rbind(cbind(lob = "auto", one), cbind(lob = "home", two))
tri <- triangle(long, "year", "age", c("paid", "premium"), keys = "lob")
# Short chains may miss a diagnostic threshold.
fits <- suppressWarnings(meyers_segments(tri, "paid", "premium", tune = 200, draws = 200,
n_sims = 1000))
fits@reserves@keys
#> lob origin
#> 1 auto 1988
#> 2 auto 1989
#> 3 auto 1990
#> 4 auto 1991
#> 5 auto 1992
#> 6 home 1988
#> 7 home 1989
#> 8 home 1990
#> 9 home 1991
#> 10 home 1992
fits@diagnostics
#> lob max_rhat min_ess_bulk min_ess_tail divergences
#> 1 auto 1.023484 280.6044 244.5968 5
#> 2 home 1.018770 351.8726 270.5597 3
#> warnings
#> 1 logelr: bulk ESS 328 is below 400 (100 per chain); logelr: tail ESS 335 is below 400 (100 per chain); alpha[3]: R-hat 1.0107 is above 1.01; alpha[5]: tail ESS 337 is below 400 (100 per chain); beta[1]: tail ESS 269 is below 400 (100 per chain); sigma[1]: R-hat 1.0235 is above 1.01; sigma[1]: bulk ESS 306 is below 400 (100 per chain); sigma[2]: R-hat 1.0164 is above 1.01; sigma[2]: bulk ESS 316 is below 400 (100 per chain); sigma[2]: tail ESS 367 is below 400 (100 per chain); sigma[3]: bulk ESS 298 is below 400 (100 per chain); sigma[3]: tail ESS 318 is below 400 (100 per chain); sigma[4]: bulk ESS 332 is below 400 (100 per chain); sigma[4]: tail ESS 372 is below 400 (100 per chain); sigma[5]: bulk ESS 281 is below 400 (100 per chain); sigma[5]: tail ESS 245 is below 400 (100 per chain); 5 divergent transitions among the kept draws
#> 2 logelr: R-hat 1.0188 is above 1.01; logelr: bulk ESS 381 is below 400 (100 per chain); logelr: tail ESS 285 is below 400 (100 per chain); alpha[4]: R-hat 1.0160 is above 1.01; beta[3]: R-hat 1.0150 is above 1.01; sigma[1]: bulk ESS 393 is below 400 (100 per chain); sigma[1]: tail ESS 347 is below 400 (100 per chain); sigma[2]: bulk ESS 376 is below 400 (100 per chain); sigma[3]: bulk ESS 352 is below 400 (100 per chain); sigma[3]: tail ESS 380 is below 400 (100 per chain); sigma[4]: bulk ESS 376 is below 400 (100 per chain); sigma[5]: bulk ESS 400 is below 400 (100 per chain); sigma[5]: tail ESS 271 is below 400 (100 per chain); 3 divergent transitions among the kept draws
segment(fits, lob = "home")@premium
#> [1] 11624 9816 10908 10330 10428