reserving.MackBootstrap
Mack’s bootstrap for the lifetime and one-year views (England, Verrall
Usage
reserving.MackBootstrap()and Wüthrich 2019, Appendix 1): the link ratios’ residuals are resampled into pseudo factors (parameter error), and each future cumulative value is drawn from the one before with Mack’s mean and variance (process error), to the last age (fit) or over the coming year (one_year). Its lifetime standard deviation approximates Mack’s standard error, and its one-year view is MackFit.claims_development_result()’s within Monte Carlo error.
The method, its formulas, the centring of the residuals and its reference are documented once, in the Rust reference: https://docs.rs/prospicio-reserving/latest/prospicio_reserving/mack_bootstrap/index.html
Simulation i uses random stream i of seed for every segment in turn.
Parameters
n_sims: int = 10000-
Number of simulations; positive.
seed: int = 0-
Seed of the simulation streams, from 0 to
2**64 - 1. process: (gamma, lognormal, residuals, normal, none) = "gamma"-
Process error on each next cumulative value: Gamma or lognormal (negated for a negative mean) or normal, with Mack’s mean and variance; the mean plus a resampled residual times the standard deviation, which carries the residuals’ mean and variance; or none for parameter error only.
average: (volume, simple, regression, geometric) = "volume"-
How Mack’s model averages the link ratios (its alpha).
sigma_interpolation: (log - linear, mack) = "log-linear"-
How a sigma behind a single link ratio is filled in.
n_periods: optional-
As ChainLadder. The bootstrap keeps the link ratios that are kept at the observed triangle (the drops are not ranked again in each simulation): only they have residuals and enter the pseudo factors, so Mack’s standard error under the same settings is its standard deviation’s reference. In one_year, a bootstrap that sets none of them takes method’s; one that sets its own must set the same as method, else a
ValueErrornames both. The mean of the claims development result is then not zero: the window moves and the drops are ranked again on the closing triangle, as the next year’s reserving does. drop_high: optional-
As ChainLadder. The bootstrap keeps the link ratios that are kept at the observed triangle (the drops are not ranked again in each simulation): only they have residuals and enter the pseudo factors, so Mack’s standard error under the same settings is its standard deviation’s reference. In one_year, a bootstrap that sets none of them takes method’s; one that sets its own must set the same as method, else a
ValueErrornames both. The mean of the claims development result is then not zero: the window moves and the drops are ranked again on the closing triangle, as the next year’s reserving does. drop_low: optional-
As ChainLadder. The bootstrap keeps the link ratios that are kept at the observed triangle (the drops are not ranked again in each simulation): only they have residuals and enter the pseudo factors, so Mack’s standard error under the same settings is its standard deviation’s reference. In one_year, a bootstrap that sets none of them takes method’s; one that sets its own must set the same as method, else a
ValueErrornames both. The mean of the claims development result is then not zero: the window moves and the drops are ranked again on the closing triangle, as the next year’s reserving does. centre_residuals: bool = True-
Subtract the residuals’ mean before resampling them, so that the pseudo factors are unbiased, the mean CDR is about zero and the lifetime mean reserve is the chain ladder’s (without a tail or with a constant one).
Falseresamples them uncentred, as EVW’s Appendix 1 is written. tail: (float, TailConstant, TailCurve, TailBondy or TailLogLinear)-
Development past the oldest age in the lifetime view (fit), as Mack’s: one more step, to ultimate, with the process error of the tail’s sigma (Mack 1999). An estimated tail (TailCurve, TailBondy, TailLogLinear) is refitted on each simulation’s pseudo factors, which gives its parameter error; a constant one is drawn from the lognormal with the factor as mean and the tail’s standard error. No tail by default. one_year takes the step for the origins whose step falls in the coming year, as OdpBootstrap’s does; method’s tail must then be this one.
tail_sigma: float-
The tail’s sigma (R’s
tail.sigma); extrapolated if not given. Unused when the tail factor is 1. tail_std_err: float-
The constant tail factor’s standard error (R’s
tail.se); extrapolated if not given, unlike OdpBootstrap, which then keeps the factor fixed. Unused when the tail factor is 1; an error with an estimated tail. dependence: (independent, synchronized, rank_correlation) = "independent"-
How the segments of a multi-segment triangle depend on each other in fit and one_year: each resamples its own residuals independently; every segment resamples the link-ratio residuals of the same origins and ages in each simulation (the synchronous bootstrap of Taylor and McGuire 2007 and Kirschner, Kerley and Isaacs 2008), so the lines’ parameter error takes the correlation of their residuals and process error stays independent, which needs the same origins, ages and observed cells in every segment; or each is bootstrapped independently and the segments’ simulations are reordered as whole rows (Iman–Conover on the segment totals) to the Spearman matrix spearman and then put in a random order, so that row
iis no longer simulationibut any subset of rows is a fair sample. spearman: list of list of float-
With
dependence="rank_correlation"only: Spearman’s rho between the segments’ totals, one row and column per segment in index order, symmetric with a unit diagonal. It is converted to the normal scores’ correlation2 sin(pi rho / 6), which must be positive definite. ldf: optional-
A selected development pattern, as in ChainLadder. Mack’s sigmas and residuals come from the triangle’s own estimate; each simulation then uses
w * selected + (1 - w) * pseudoat the selected ages, so a fully selected factor has no parameter error and a blended one1 - wtimes the pseudo factor’s deviation, as Mack charges it; the process error is unchanged. A supplied pattern lowers the reported uncertainty. Each origin is projected from its observed latest value, so with every factor selected only the process error is left (unlike OdpBootstrap, which keeps the origins’ level error). With no tail, a cumulative pattern to the oldest age implies a constant tail (ChainLadderFit.pattern_tail), the same in every simulation unless tail_std_err is given. In one_year, a bootstrap without a pattern takes method’s (bootstrap_ldf); one with a pattern needs method to select the same factors. ldf_kind: optional-
A selected development pattern, as in ChainLadder. Mack’s sigmas and residuals come from the triangle’s own estimate; each simulation then uses
w * selected + (1 - w) * pseudoat the selected ages, so a fully selected factor has no parameter error and a blended one1 - wtimes the pseudo factor’s deviation, as Mack charges it; the process error is unchanged. A supplied pattern lowers the reported uncertainty. Each origin is projected from its observed latest value, so with every factor selected only the process error is left (unlike OdpBootstrap, which keeps the origins’ level error). With no tail, a cumulative pattern to the oldest age implies a constant tail (ChainLadderFit.pattern_tail), the same in every simulation unless tail_std_err is given. In one_year, a bootstrap without a pattern takes method’s (bootstrap_ldf); one with a pattern needs method to select the same factors. ldf_weight: optional-
A selected development pattern, as in ChainLadder. Mack’s sigmas and residuals come from the triangle’s own estimate; each simulation then uses
w * selected + (1 - w) * pseudoat the selected ages, so a fully selected factor has no parameter error and a blended one1 - wtimes the pseudo factor’s deviation, as Mack charges it; the process error is unchanged. A supplied pattern lowers the reported uncertainty. Each origin is projected from its observed latest value, so with every factor selected only the process error is left (unlike OdpBootstrap, which keeps the origins’ level error). With no tail, a cumulative pattern to the oldest age implies a constant tail (ChainLadderFit.pattern_tail), the same in every simulation unless tail_std_err is given. In one_year, a bootstrap without a pattern takes method’s (bootstrap_ldf); one with a pattern needs method to select the same factors. ldf_origin: optional-
A selected development pattern, as in ChainLadder. Mack’s sigmas and residuals come from the triangle’s own estimate; each simulation then uses
w * selected + (1 - w) * pseudoat the selected ages, so a fully selected factor has no parameter error and a blended one1 - wtimes the pseudo factor’s deviation, as Mack charges it; the process error is unchanged. A supplied pattern lowers the reported uncertainty. Each origin is projected from its observed latest value, so with every factor selected only the process error is left (unlike OdpBootstrap, which keeps the origins’ level error). With no tail, a cumulative pattern to the oldest age implies a constant tail (ChainLadderFit.pattern_tail), the same in every simulation unless tail_std_err is given. In one_year, a bootstrap without a pattern takes method’s (bootstrap_ldf); one with a pattern needs method to select the same factors. ldf_underwriting: optional-
A selected development pattern, as in ChainLadder. Mack’s sigmas and residuals come from the triangle’s own estimate; each simulation then uses
w * selected + (1 - w) * pseudoat the selected ages, so a fully selected factor has no parameter error and a blended one1 - wtimes the pseudo factor’s deviation, as Mack charges it; the process error is unchanged. A supplied pattern lowers the reported uncertainty. Each origin is projected from its observed latest value, so with every factor selected only the process error is left (unlike OdpBootstrap, which keeps the origins’ level error). With no tail, a cumulative pattern to the oldest age implies a constant tail (ChainLadderFit.pattern_tail), the same in every simulation unless tail_std_err is given. In one_year, a bootstrap without a pattern takes method’s (bootstrap_ldf); one with a pattern needs method to select the same factors.
Raises
Examples
>>> from prospicio.reserving import ChainLadder, Mack, MackBootstrap, Triangle
>>> tri = Triangle.from_long(
... [2020] * 4 + [2021] * 3 + [2022] * 2 + [2023],
... [12, 24, 36, 48, 12, 24, 36, 12, 24, 12],
... [100.0, 150.0, 165.0, 170.0, 110.0, 170.0, 180.0, 120.0, 175.0, 130.0],
... )
>>> fit = MackBootstrap(n_sims=2000, seed=42).one_year(tri, "values", ChainLadder())
>>> fit.model‘mack’
>>> fit.cdr.variance() ** 0.5 < Mack().fit(tri, "values").total_standard_errorTrue
Attributes
| Name | Description |
|---|---|
| average | How Mack’s model averages the link ratios. |
| centre_residuals | Whether the residuals are centred before they are resampled. |
| dependence |
How the segments depend on each other: "independent",
|
| drop_high | Highest link ratios left out at each age. |
| drop_low | Lowest link ratios left out at each age. |
| ldf |
The selected pattern by age, as given; None without one.
|
| ldf_kind |
How ldf is expressed: "ldf", "cdf" or
|
| ldf_origin | The origin grain ldf was measured on, averaged over the fitted |
| ldf_underwriting | The underwriting basis ldf is converted to at fit time |
| ldf_weight | The weight on the selected factors: a number, a dict by age, or |
| n_periods |
Number of latest diagonals averaged; None uses every link ratio.
|
| n_sims | Number of simulations. |
| process |
Process error: "gamma", "lognormal", "residuals",
|
| seed | Seed of the simulation streams. |
| sigma_interpolation | How a sigma behind a single link ratio is filled in. |
| spearman |
The Spearman matrix of dependence="rank_correlation"; None
|
| tail | The lifetime view’s tail: a constant factor as a number, otherwise |
| tail_sigma |
The given tail sigma, or None to extrapolate it.
|
| tail_std_err |
The given standard error of a constant tail factor, or None to
|
average
How Mack’s model averages the link ratios.
average: str
centre_residuals
Whether the residuals are centred before they are resampled.
centre_residuals: bool
dependence
How the segments depend on each other: "independent",
dependence: str
"synchronized" or "rank_correlation".
drop_high
Highest link ratios left out at each age.
drop_high: int
drop_low
Lowest link ratios left out at each age.
drop_low: int
ldf
The selected pattern by age, as given; None without one.
ldf: dict | None
ldf_kind
How ldf is expressed: "ldf", "cdf" or
ldf_kind: str | None
"percent_developed"; None without a pattern.
ldf_origin
The origin grain ldf was measured on, averaged over the fitted
ldf_origin: str | None
origins’ periods at fit time; None reads it at the origin’s age.
ldf_underwriting
The underwriting basis ldf is converted to at fit time
ldf_underwriting: UnderwritingBasis | None
(UnderwritingBasis), or None.
ldf_weight
The weight on the selected factors: a number, a dict by age, or
ldf_weight: Any | None
None without a pattern.
n_periods
Number of latest diagonals averaged; None uses every link ratio.
n_periods: int | None
n_sims
Number of simulations.
n_sims: int
process
Process error: "gamma", "lognormal", "residuals",
process: str
"normal" or "none".
seed
Seed of the simulation streams.
seed: int
sigma_interpolation
How a sigma behind a single link ratio is filled in.
sigma_interpolation: str
spearman
The Spearman matrix of dependence="rank_correlation"; None
spearman: list[list[float]] | None
otherwise.
tail
The lifetime view’s tail: a constant factor as a number, otherwise
tail: Any
its estimator.
tail_sigma
The given tail sigma, or None to extrapolate it.
tail_sigma: float | None
tail_std_err
The given standard error of a constant tail factor, or None to
tail_std_err: float | None
extrapolate it.
Methods
| Name | Description |
|---|---|
| fit() | The lifetime view: bootstraps one measure column in every segment of |
| one_year() | The one-year view of any reserving method under Mack’s process, as |
fit()
The lifetime view: bootstraps one measure column in every segment of
Usage
fit(triangle, column, *, cells=False)a cumulative triangle, each with its own Mack model and residuals, into one joint distribution of the reserves (EVW’s Appendix 1), the segments depending on each other as dependence says. Each simulation resamples the residuals into pseudo factors and draws every cumulative value from the latest observed one to the last age, each from the one before, with Mack’s mean and variance; an origin’s reserve is its last drawn value less its latest. With a tail each origin takes one more step, to ultimate, with the tail’s sigma, the tail factor refitted (an estimated tail) or drawn (a constant one) per simulation. The standard deviation approximates Mack’s analytic standard error (Mack.fit, with the same tail; for an estimated tail the parameter error is the refit’s, not Mack’s extrapolated one); the mean is the chain ladder’s reserve with centre_residuals (the default), without a tail or with a constant one, about 17% above it on RAA without centring.
Parameters
triangle: Triangle-
Cumulative, with any number of segments and any development grain, every origin observed from the first age to its latest with no negative value.
column: strcells: bool = False- Whether to keep each simulation’s future incremental values in the fit’s cells, for Indexation.reinflate_draws. The reserves and patterns are the same, bit for bit, with and without them, since keeping them draws no other random number. They take n_sims times the number of future cells in memory (about 4 MB on RAA at 10,000 simulations, 66 MB on a 40 by 40 quarterly triangle), so they are kept only when asked for.
Returns
MackBootstrapFit
Raises
ValueError-
As Mack.fit, if an origin has a gap before its latest age, if a cumulative value is negative, if synchronized segments differ in their origins, ages or observed cells, if spearman does not fit the segments, if tail_std_err is given with an estimated tail, or if the tail cannot be refitted on some simulation’s pseudo factors (the message counts them and gives one); with
cells=True, if no segment has a future cell (a fully developed triangle with no tail).
Examples
>>> from prospicio.reserving import MackBootstrap, Triangle
>>> tri = Triangle.from_long(
... [2020] * 4 + [2021] * 3 + [2022] * 2 + [2023],
... [12, 24, 36, 48, 12, 24, 36, 12, 24, 12],
... [100.0, 150.0, 165.0, 170.0, 110.0, 170.0, 180.0, 120.0, 175.0, 130.0],
... )
>>> fit = MackBootstrap(n_sims=2000, seed=42).fit(tri, "values")
>>> fit.reserves.components()[(‘2020’,), (‘2021’,), (‘2022’,), (‘2023’,)]
>>> abs(fit.reserves.mean() / fit.chain_ladder.total_reserve - 1) < 0.05True
one_year()
The one-year view of any reserving method under Mack’s process, as
Usage
one_year(triangle, column, method, exposure=None, bootstrap_ldf=True)OdpBootstrap.one_year: each simulation draws the cells of the coming twelve months from Mack’s bootstrap, each from the one before with the same pseudo factors, appends them to the triangle, refits method and records CDR = opening ultimate - closing ultimate. Without a bootstrap tail, development past the oldest age moves only through method’s refitted tail; with one, which must be method’s, the origins whose tail step falls in the coming year take Mack’s step to ultimate and are closed, as in OdpBootstrap.one_year.
Parameters
triangle: Triangle-
Cumulative, with any number of segments and any development grain, every origin observed from the first age to its latest with no negative value.
column: strmethod: (ChainLadder, ExpectedLoss, BornhuetterFerguson, Benktander or CapeCod)-
The method refitted at the start and at the end of the year.
exposure: str = None-
The exposure column; required by the expected-loss methods, not taken by ChainLadder.
bootstrap_ldf: bool = True-
As OdpBootstrap.one_year: without an ldf of its own, the bootstrap takes method’s selected pattern and reads it as method does (no implied tail when method has a tail);
Falsesimulates from the triangle’s own factors.
Returns
OneYearFit-
With
model == "mack".
Raises
TypeError-
If method is not one of the classes above.
ValueError- As OdpBootstrap.one_year and Mack.fit, if a cumulative value is negative, and if the bootstrap has a tail that is not method’s.