Bayesian over-dispersed Poisson chain ladder
bayes_odp_fit.RdThe Bayesian chain ladder of England and Verrall (2002, 2006): the
over-dispersed Poisson model of a cumulative triangle's incremental
values with mean exp(c + a[w] + b[d]) (a[1] = b[1] = 0), normal
priors on the log scale (c centred on the log of the mean observed
increment, the others on 0), and the chain ladder's Pearson scale phi
(the scale of odp_bootstrap()) plugged in. The posterior is sampled
with NUTS, and each draw projects the future cells up to the oldest
observed age (no tail) with the process error of process, as
odp_bootstrap() does. Every origin's and every development column's
observed increments must sum to more than zero; negative cells are
allowed. One seed replays a fit exactly, whatever the number of
threads: the chains and the simulations each take a seed derived from
it.
Usage
bayes_odp_fit(ptr)
bayes_odp(
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
)Arguments
- ptr
A
BayesOdpFitpointer; used internally.- triangle
A cumulative triangle with one segment, 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.
Details
Failed MCMC diagnostics (R-hat above 1.01, bulk or tail ESS below 100
per chain, any divergent transition) do not fail the fit:
bayes_odp() raises one warning() listing them, and they stay in the
fit's diagnostics.
Properties of the fit: chain_ladder (the volume-weighted
chain_ladder_fit whose latest values and scale the model uses),
origins, development, scale (the plugged-in phi), reserves (a
predictive_distribution of the reserve with dimension origin, one
component per origin, laid out as odp_bootstrap()'s), diagnostics (a
list of max_rhat, min_ess_bulk, min_ess_tail, divergences and
warnings), summary (the posterior summary as bayes_glm_model's:
parameter, mean, sd, q05, q50, q95, rhat, ess_bulk and
ess_tail; also summary(fit)) and draws (a matrix of the posterior
draws of c, a[2], ..., b[2], ..., one row per draw, chain by
chain). bayes_loo() gives the PSIS-LOO of the observed increments, with
the normalised over-dispersed Poisson density as the pointwise term, so
compare it only with models of the same incremental values; it is an
error on a triangle with a negative increment. as.data.frame(),
totals_frame(), development_frame() and segment() work as for
odp_bootstrap(), with the mean and std_dev of the posterior
predictive reserve.
Errors: as odp_bootstrap(); if the triangle has several segments; if a
prior standard deviation is not positive and finite or a sampler setting
is invalid; or if an origin's or a development column's increments do
not sum to more than zero.
Examples
long <- data.frame(year = rep(2018:2021, 4:1),
age = c(12, 24, 36, 48, 12, 24, 36, 12, 24, 12),
paid = c(100, 150, 165, 170, 110, 170, 180, 120, 175, 130))
fit <- bayes_odp(triangle(long, "year", "age", "paid"), n_sims = 2000, seed = 1)
fit@diagnostics$max_rhat
#> [1] 1.00421
head(fit@summary)
#> parameter mean sd q05 q50 q95 rhat
#> 1 c 4.62395789 0.07274047 4.50345167 4.62492061 4.7420376 1.004210
#> 2 a[2] 0.08684408 0.09173368 -0.06083230 0.08730058 0.2365111 1.003201
#> 3 a[3] 0.13353710 0.09405782 -0.01827523 0.13335901 0.2921361 1.003144
#> 4 a[4] 0.24277710 0.10821468 0.06812020 0.24184263 0.4230393 1.001916
#> 5 b[2] -0.69443503 0.07936093 -0.82881313 -0.69442777 -0.5664663 1.002080
#> 6 b[3] -2.16067311 0.18308621 -2.46592581 -2.15718131 -1.8686396 1.000504
#> ess_bulk ess_tail
#> 1 6634.800 2607.673
#> 2 7077.851 3391.809
#> 3 6720.267 2807.970
#> 4 7028.462 3075.092
#> 5 6534.319 2917.873
#> 6 6325.572 2710.547
mean(fit@reserves)
#> [1] 112.2261
quantile(fit@reserves, 0.995)
#> [1] 156.5252