Bayesian over-dispersed Poisson chain ladder over segments
bayes_odp_fits.Rdbayes_odp() fitted to every segment of a triangle column, each segment
with its own posterior (the same model and settings, sampled
independently), into one joint posterior predictive distribution of the
reserves laid out as odp_bootstrap()'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 bayes_odp() of that segment alone. Failed MCMC diagnostics
raise one warning() listing every segment's messages, each prefixed
with its segment's label.
Usage
bayes_odp_fits(ptr)
bayes_odp_segments(
triangle,
column = NULL,
intercept_sd = 10,
origin_sd = 10,
development_sd = 10,
process = c("gamma", "none"),
chains = 4,
tune = 1000,
draws = 1000,
n_sims = 10000,
seed = 0,
target_accept = 0.95,
max_depth = 10,
dependence = c("independent", "rank_correlation", "synchronized"),
spearman = NULL
)Arguments
- ptr
A
BayesOdpFitspointer; 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; by default the only one.
- intercept_sd
Standard deviation of the normal prior on the intercept
c.- origin_sd
Standard deviation of the normal prior on each origin effect
a[w],w >= 2.- development_sd
Standard deviation of the normal prior on each development effect
b[d],d >= 2.- process
Process error on each simulated future increment:
"gamma"(meanmu, variancephi * mu) 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, 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; above NUTS's usual 0.8, which on triangles such as RAA usually leaves a few 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 segment totals) 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' totals, asodp_bootstrap()'s.
Details
Properties of the fit: chain_ladder (the volume-weighted
chain_ladder_fit of every segment), origins, development,
reserves (a predictive_distribution 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 "; "). scale,
summary, draws and bayes_loo() are those of bayes_odp_fit and
need a single-segment fit: with several segments use segment(), or
totals_frame() for the scales. as.data.frame(), totals_frame(),
development_frame() and segment() work as for odp_bootstrap().
Errors: as bayes_odp() for any segment (the message names the
segment); dependence = "synchronized", before any sampling, since it
resamples the residuals of the same cells in every segment and a
posterior has no residuals to share; or a spearman matrix that does
not fit the segments.
Examples
long <- data.frame(lob = rep(c("auto", "home"), each = 10),
year = rep(rep(2018:2021, 4:1), 2),
age = rep(c(12, 24, 36, 48, 12, 24, 36, 12, 24, 12), 2),
paid = c(100, 150, 165, 170, 110, 170, 180, 120, 175, 130,
200, 300, 330, 340, 220, 340, 360, 240, 350, 260))
tri <- triangle(long, "year", "age", "paid", keys = "lob")
# Short chains may miss a diagnostic threshold.
fits <- suppressWarnings(bayes_odp_segments(tri, tune = 300, draws = 300, n_sims = 1000))
fits@reserves@keys
#> lob origin
#> 1 auto 2018
#> 2 auto 2019
#> 3 auto 2020
#> 4 auto 2021
#> 5 home 2018
#> 6 home 2019
#> 7 home 2020
#> 8 home 2021
fits@diagnostics
#> lob max_rhat min_ess_bulk min_ess_tail divergences
#> 1 auto 1.008392 1931.090 817.2880 0
#> 2 home 1.015083 1633.998 750.1758 0
#> warnings
#> 1
#> 2 c: R-hat 1.0151 is above 1.01
segment(fits, lob = "home")@scale
#> [1] 1.457364