reserving.OdpBootstrap
Over-dispersed Poisson bootstrap of the chain ladder (England and
Usage
reserving.OdpBootstrap()Verrall 2002), as R ChainLadder’s BootChainLadder: adjusted Pearson residuals of the volume-weighted chain ladder are resampled into pseudo triangles, each is re-projected, and process error is added to every future incremental value. Simulation i uses random stream i of seed for every segment in turn, so results do not depend on the number of threads.
Parameters
n_sims: int = 10000-
Number of simulations; positive.
seed: int = 0-
Seed of the simulation streams, from 0 to
2**64 - 1. R accepts seeds below2**53; a seed in both ranges gives the same draws. process: (gamma, none) = "gamma"-
Process error on each simulated future incremental value: Gamma with the expected value as mean and variance
scale * |mean|(R’sprocess.distr = "gamma"), or none for parameter error only. tail: (float, TailConstant, TailCurve, TailBondy or TailLogLinear)-
Development past the oldest age in the lifetime view (fit), as ChainLadder’s; no tail by default, as R’s
BootChainLadder. An estimated tail (TailCurve, TailBondy, TailLogLinear) is refitted on each simulation’s pseudo factors, which gives its parameter error; a constant one is fixed unless tail_std_err is given. The step from the oldest age to ultimate is one more future increment, with mean the pseudo value at the oldest age times the tail factor less 1 and the same process error. one_year values that step one development period after the oldest age and takes it for the origins whose step falls in the coming year, closing them; method’s tail must then be this one. R’s rule (TailLogLinear) refitted on the ODP’s pseudo factors is often exactly 1 (5.7% of simulations on RAA) and on average high (RAA’s oldest origin’s mean reserve 78% above the plug-in); a constant tail with tail_std_err has neither. tail_std_err: float-
Standard error of a constant tail factor: each simulation draws the factor from the lognormal with the factor as mean and this standard deviation. Not given, the factor is fixed, unlike MackBootstrap, which extrapolates Mack’s standard error. Unused when the 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 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. The residuals and the scale come from the triangle’s own volume-weighted factors; each simulation then uses
w * selected + (1 - w) * pseudoat the selected ages, so a fully selected factor is the same in every simulation (no parameter error) and a blended one moves by1 - wtimes the pseudo factor’s deviation. The origins’ level still moves (each simulation projects from its pseudo latest values), so even a fully selected pattern keeps part of the spread: with every factor selected and no process error, about 73% of the unblended standard deviation on RAA. This is the ODP’s parameter error in the origins’ levels, which a development pattern does not fix, and it is kept on purpose; MackBootstrap projects from the observed latest values and keeps only the process error. A supplied pattern lowers the reported uncertainty. 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, and the tail its pattern implies to be method’s. ldf_kind: optional-
A selected development pattern, as in ChainLadder. The residuals and the scale come from the triangle’s own volume-weighted factors; each simulation then uses
w * selected + (1 - w) * pseudoat the selected ages, so a fully selected factor is the same in every simulation (no parameter error) and a blended one moves by1 - wtimes the pseudo factor’s deviation. The origins’ level still moves (each simulation projects from its pseudo latest values), so even a fully selected pattern keeps part of the spread: with every factor selected and no process error, about 73% of the unblended standard deviation on RAA. This is the ODP’s parameter error in the origins’ levels, which a development pattern does not fix, and it is kept on purpose; MackBootstrap projects from the observed latest values and keeps only the process error. A supplied pattern lowers the reported uncertainty. 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, and the tail its pattern implies to be method’s. ldf_weight: optional-
A selected development pattern, as in ChainLadder. The residuals and the scale come from the triangle’s own volume-weighted factors; each simulation then uses
w * selected + (1 - w) * pseudoat the selected ages, so a fully selected factor is the same in every simulation (no parameter error) and a blended one moves by1 - wtimes the pseudo factor’s deviation. The origins’ level still moves (each simulation projects from its pseudo latest values), so even a fully selected pattern keeps part of the spread: with every factor selected and no process error, about 73% of the unblended standard deviation on RAA. This is the ODP’s parameter error in the origins’ levels, which a development pattern does not fix, and it is kept on purpose; MackBootstrap projects from the observed latest values and keeps only the process error. A supplied pattern lowers the reported uncertainty. 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, and the tail its pattern implies to be method’s. ldf_origin: optional-
A selected development pattern, as in ChainLadder. The residuals and the scale come from the triangle’s own volume-weighted factors; each simulation then uses
w * selected + (1 - w) * pseudoat the selected ages, so a fully selected factor is the same in every simulation (no parameter error) and a blended one moves by1 - wtimes the pseudo factor’s deviation. The origins’ level still moves (each simulation projects from its pseudo latest values), so even a fully selected pattern keeps part of the spread: with every factor selected and no process error, about 73% of the unblended standard deviation on RAA. This is the ODP’s parameter error in the origins’ levels, which a development pattern does not fix, and it is kept on purpose; MackBootstrap projects from the observed latest values and keeps only the process error. A supplied pattern lowers the reported uncertainty. 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, and the tail its pattern implies to be method’s. ldf_underwriting: optional-
A selected development pattern, as in ChainLadder. The residuals and the scale come from the triangle’s own volume-weighted factors; each simulation then uses
w * selected + (1 - w) * pseudoat the selected ages, so a fully selected factor is the same in every simulation (no parameter error) and a blended one moves by1 - wtimes the pseudo factor’s deviation. The origins’ level still moves (each simulation projects from its pseudo latest values), so even a fully selected pattern keeps part of the spread: with every factor selected and no process error, about 73% of the unblended standard deviation on RAA. This is the ODP’s parameter error in the origins’ levels, which a development pattern does not fix, and it is kept on purpose; MackBootstrap projects from the observed latest values and keeps only the process error. A supplied pattern lowers the reported uncertainty. 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, and the tail its pattern implies to be method’s. n_periods: optional-
As ChainLadder, for the volume-weighted chain ladder the bootstrap fits (it has no average setting). The fitted values are back-cast with the factors under the exclusions; an incremental cell has a residual only if the link ratio it closes is kept (the first age’s cells always do), and the pseudo factors average the kept links only. The drops are fixed on the observed triangle: the simulated triangles are not ranked again. The scale is the sum of the kept squared residuals over
N - p(chainladder-python’s rule), which is biased low under exclusions: on RAA withn_periods=3it is about 70% of the plain scale (694 against 984), and the standard deviations are correspondingly narrow. 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 aValueErrornames 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, for the volume-weighted chain ladder the bootstrap fits (it has no average setting). The fitted values are back-cast with the factors under the exclusions; an incremental cell has a residual only if the link ratio it closes is kept (the first age’s cells always do), and the pseudo factors average the kept links only. The drops are fixed on the observed triangle: the simulated triangles are not ranked again. The scale is the sum of the kept squared residuals over
N - p(chainladder-python’s rule), which is biased low under exclusions: on RAA withn_periods=3it is about 70% of the plain scale (694 against 984), and the standard deviations are correspondingly narrow. 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 aValueErrornames 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, for the volume-weighted chain ladder the bootstrap fits (it has no average setting). The fitted values are back-cast with the factors under the exclusions; an incremental cell has a residual only if the link ratio it closes is kept (the first age’s cells always do), and the pseudo factors average the kept links only. The drops are fixed on the observed triangle: the simulated triangles are not ranked again. The scale is the sum of the kept squared residuals over
N - p(chainladder-python’s rule), which is biased low under exclusions: on RAA withn_periods=3it is about 70% of the plain scale (694 against 984), and the standard deviations are correspondingly narrow. 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 aValueErrornames 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.
Raises
Examples
>>> from prospicio.reserving import OdpBootstrap, 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 = OdpBootstrap(n_sims=2000, seed=42).fit(tri, "values")
>>> fit.reserves.components()[(‘2020’,), (‘2021’,), (‘2022’,), (‘2023’,)]
>>> fit.reserves.mean() > 0True
Attributes
| Name | Description |
|---|---|
| dependence |
How the segments depend on each other: "independent",
|
| drop_high | How many of the highest link ratios at each age are left out. |
| drop_low | How many of the lowest link ratios at each age are left out. |
| 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 | Link ratios that start before the latest n_periods calendar |
| n_sims | Number of simulations. |
| process |
Process error: "gamma" or "none".
|
| seed | Seed of the simulation streams. |
| spearman |
The Spearman matrix of dependence="rank_correlation"; None
|
| tail | The lifetime view’s tail: a constant factor as a number, otherwise |
| tail_std_err | The standard error a constant tail factor is drawn with, or |
dependence
How the segments depend on each other: "independent",
dependence: str
"synchronized" or "rank_correlation".
drop_high
How many of the highest link ratios at each age are left out.
drop_high: int
drop_low
How many of the lowest link ratios at each age are left out.
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
Link ratios that start before the latest n_periods calendar
n_periods: int | None
diagonals are left out; None keeps all.
n_sims
Number of simulations.
n_sims: int
process
Process error: "gamma" or "none".
process: str
seed
Seed of the simulation streams.
seed: int
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_std_err
The standard error a constant tail factor is drawn with, or
tail_std_err: float | None
None to keep it fixed.
Methods
| Name | Description |
|---|---|
| fit() | Bootstraps one measure column in every segment of a cumulative |
| one_year() | The one-year view of any reserving method: the claims development |
fit()
Bootstraps one measure column in every segment of a cumulative
Usage
fit(triangle, column, *, cells=False)triangle, each with its own residuals and scale, into one joint distribution of the reserves, the segments depending on each other as dependence says. Every origin must be observed from the first age up to its latest.
Parameters
triangle: Triangle-
Cumulative, with any number of segments.
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
OdpBootstrapFit
Raises
ValueError-
As ChainLadder.fit, and if an origin has a gap before its latest age, a segment has too few observed cells for the degrees of freedom to be positive, synchronized segments differ in their origins, ages or observed cells, or spearman does not fit the segments; with an estimated tail, if it 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).
one_year()
The one-year view of any reserving method: the claims development
Usage
one_year(triangle, column, method, exposure=None, bootstrap_ldf=True)result over the coming year, by re-reserving on the bootstrap (“actuary in the box”). The coming year is every cell valued in the twelve months after the segment’s valuation: one per origin for an annual development grain, four for a quarterly one (fewer for an origin that reaches the last age). Each simulation resamples the residuals for the volume-weighted factors, projects the increments of those cells in turn from the origin’s resampled latest value with the bootstrap’s process error, as fit projects, adds them to the observed latest value, appends the cells to the triangle, refits method and records CDR = opening ultimate - closing ultimate; a negative CDR is an adverse development. An origin whose remaining cells all fall in the year thus has its lifetime bootstrap reserve as its one-year view; an origin at the last age gets no new cell; an origin short of the latest diagonal develops from its own latest cell, and only the year’s cells are appended. Unlike MackFit.claims_development_result() (Merz and Wüthrich), any averaging, tail and development grain are allowed.
Without a bootstrap tail, development past the oldest age moves only through method’s refitted tail. With one, which must be method’s tail, the tail is drawn in each simulation as fit draws it, and its step to ultimate is valued one development period after the oldest age: an origin whose step falls in the coming year (with an annual grain, one already at the oldest age) takes it and is closed at that simulated ultimate. The step is the whole tail: a curve or a decayed constant tail is taken as the product of its factors in that one step, so an origin that takes it has its lifetime tail risk in the coming year, an upper bound on its one-year risk.
Parameters
triangle: Triangle-
Cumulative, with any number of segments and any development grain.
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. Its latest value per origin is kept for the end of the year.
bootstrap_ldf: bool = True-
With a bootstrap that has no ldf of its own, whether it takes method’s selected pattern, so that each simulation’s pseudo factors are blended with it as the method’s factors are (as R’s
odp_one_year(bootstrap_ldf = TRUE)and the Rust default,OneYearPattern::Method).Falsesimulates from the triangle’s own factors and lets the pattern enter only when the method re-reserves; it is an error with a bootstrap that has its own ldf. A bootstrap’s own ldf must select the same factors and weights as method’s, in any order or kind; and when it implies a tail (a cumulative pattern to the oldest age, no tail), method must use the same tail. The ldf taken from method is read as method reads it: with no tail on either, a cumulative pattern to the oldest age implies the same tail for both; when method has a tail, to which it rescales the pattern’s level, the pattern implies no tail for the bootstrap either.
Returns
OneYearFit
Raises
TypeError-
If method is not one of the classes above.
ValueError- As fit and the method’s own fit; if exposure is missing for an expected-loss method or given for ChainLadder; if the bootstrap has a tail that is not the one method uses (its own, or the one its ldf implies), or an ldf that selects other factors or weights than method’s; or if the refit (or the bootstrap’s tail refit) fails in any simulation (the message counts them and gives one).
Examples
>>> from prospicio.reserving import BornhuetterFerguson, OdpBootstrap, Triangle
>>> tri = Triangle.from_long(
... [2020] * 4 + [2021] * 3 + [2022] * 2 + [2023],
... [12, 24, 36, 48, 12, 24, 36, 12, 24, 12],
... {
... "paid": [100.0, 150.0, 165.0, 170.0, 110.0, 170.0, 180.0, 120.0, 175.0, 130.0],
... "premium": [250.0] * 4 + [260.0] * 3 + [270.0] * 2 + [280.0],
... },
... )
>>> boot = OdpBootstrap(n_sims=2000, seed=42)
>>> fit = boot.one_year(tri, "paid", BornhuetterFerguson(apriori=0.7), exposure="premium")
>>> fit.cdr.components()[(‘2020’,), (‘2021’,), (‘2022’,), (‘2023’,)]
>>> fit.opening_reserve[0]0.0
>>> fit.cdr.variance() < boot.fit(tri, "paid").reserves.variance()True