reserving.ChainLadder
The chain-ladder method: each origin’s latest value projected to
Usage
reserving.ChainLadder()ultimate with age-to-age factors estimated from the triangle and a tail.
Parameters
average: (volume, simple, regression, geometric) = "volume"-
How link ratios are averaged into one factor per age: volume weighted, their mean, or least squares through the origin (Mack’s alpha of 1, 0 and 2), or their geometric mean. A geometric average estimates the factors only: Mack and the bootstraps reject it, since it has no variance model.
sigma_interpolation: (log - linear, mack) = "log-linear"-
How a variance parameter with a single link ratio is filled in.
n_periods: int-
Average only the link ratios that start in the latest n_periods calendar diagonals of the triangle; an age with fewer uses all of them. All of them by default.
drop_high: int = 0-
Leave out this many of the highest link ratios at each age, among those n_periods keeps. Skipped at an age where it would leave none.
drop_low: int = 0-
As drop_high, for the lowest link ratios.
tail: (float, TailConstant, TailCurve, TailBondy or TailLogLinear)-
Development past the oldest age: a number is a constant factor from the oldest age to ultimate. No tail (a factor of 1) by default.
ldf: dict-
A selected development pattern, from age in months to value, which replaces (or, with ldf_weight, blends with) the factors estimated from the triangle at the ages it gives; the other ages stay estimated, so a benchmark for the immature ages only is a partial pattern. As ldf_kind says, the values are age-to-age factors, or factors to ultimate or percents developed, which select the factors between the first age and the last (
cdf[a] / cdf[next age]); one factor to ultimate (or percent developed) is the tail from its age, so it is given at the oldest age, with no tail and ldf_weight 1, and on a triangle observed at one age it is the whole projection. When every age given is a development age of the triangle, an age-to-age factor links its age to the triangle’s next age (any age but the oldest: development past it is the tail’s), and a development age the cumulative values skip is interpolated: between two given agesb < c,log(cdf)is linear in the age, so the factor from a to the next agea'is(cdf[b] / cdf[c]) ** ((a' - a) / (c - b))(percents developed are converted to factors to ultimate first). Otherwise the pattern is read on its own ages: an age-to-age factor runs to the next age given (the last one by the spacing before it), a link of the triangle within the pattern’s span is selected withlog(cdf)linear between the pattern’s ages, and what the pattern gives past the triangle’s oldest age folds into a constant tail there, at full weight. So a monthly pattern applies to an annual triangle. Adding one off-grid age to a sparse age-to-age pattern changes how its other factors are read: each then runs to the pattern’s next age, not the triangle’s. On RAA,{12: 1.5, 18: 1.1, 36: 1.2}selects 1.5484 from 12 to 24, where{12: 1.5, 36: 1.2}selects 1.5, and nothing warns of the change. Their level at their last age selects nothing. With no tail and a last age that is the oldest, the level is the tail: a constant tail factor equal to the factor to ultimate there (1 over the percent developed), with no parameter error, as chainladder-python’sDevelopmentConstantkeeps it (ChainLadderFit.pattern_tail). Otherwise the level is rescaled to the factors and tail in use (ChainLadderFit.pattern_rescale). A selected factor at or after a tail’s attachment age is an error. ldf_kind: (ldf, cdf, percent_developed) = "ldf"-
How ldf is expressed; required with it, since age-to-age factors and factors to ultimate cannot be told apart. Factors to ultimate and percents developed need only be finite and positive, in any order.
ldf_weight: float or dict-
The credibility
won each selected factor, from 0 to 1: the factor used isw * selected + (1 - w) * estimated. A number applies to every selected factor, a dict from age (the age that starts the factor’s link) to weight to those listed, the others fully selected. Not given, every selected factor is used as is (w = 1). ldf_origin: (M, Q, S, Y) = "M"-
The origin grain ldf was measured on, when it is not the triangle’s: an accident-month pattern is
"M". At fit time the pattern is averaged over the sub-periods of each origin period, with the exposure even through the period, into percents developed at every month (Rust’sSelectedPattern::averaged_over_origins). The ultimates are exact for origins up to the pattern’s last age; past it the development of the period’s later sub-periods is deferred to the period’s last age, which overstates the ultimate slightly. An estimated tail is then fitted on monthly factors, so a constant tail taken from the monthly pattern’s own tail is the safer choice. The triangle’s origin grain must be a whole multiple of it; a weight by age (ldf_weight a dict, applied before the averaging; the averaged pattern cannot be weighted by age here) and a single age-to-age factor are errors; the triangle’s own grain leaves the pattern as given. Requires ldf. With ldf_underwriting it is the grain of the accident periods ldf is converted from instead. ldf_underwriting: UnderwritingBasis-
Converts ldf, an accident-period pattern, to the pattern of the triangle’s underwriting periods at fit time: an underwriting year’s share developed at age a from its start is
sum_t e(t) p(a - t), witheits exposure by accident month (the writing convolved with even earning over the policy term, UnderwritingBasis.exposure) and p an accident month’s (Rust’sSelectedPattern::to_underwriting_basis). ldf is on accident periods of ldf_origin, or of the triangle’s origin grain without it: an accident-year pattern on underwriting-year origins needs no ldf_origin. An accident-month pattern (ldf_origin="M") converts under any writing and term; a pattern of longer accident periods needs a policy term that is a whole multiple of them or writing even within each of them. Given at every month from 1 it is exact; at other ages (annual ones, say) it is read between them as UnderwritingBasis.reading says: by default the Weibull fitted through the period averages and corrected to the nearest monotone accident-month pattern whose averages are the given values exactly, within 0.2% of a simulated parallelogram book at every age, or by the rule above withreading="ln-linear"(31% too much developed at 12 months on that book). The result is longer than ldf by the writing months plus the policy term less the accident period (12 months for an accident-year pattern under the default, 23 for an accident-month one), and a constant tail from ldf’s own tail is the safer choice there. The writing must be no longer than the triangle’s origin period (the default’s 12 months suit underwriting years only; on underwriting quarters giveUnderwritingBasis([1, 1, 1])), or the fit is an error. Requires ldf. Aprocessthe
Examples
>>> from prospicio.reserving import ChainLadder, Triangle
>>> tri = Triangle.from_long([2020, 2020, 2021], [12, 24, 12], {"paid": [100.0, 150.0, 200.0]})
>>> fit = ChainLadder().fit(tri, "paid")
>>> fit.ldf, fit.ultimate, fit.total_reserve([1.5], [150.0, 300.0], 100.0)
A benchmark for the immature ages only: 50% developed at 12 months and 80% at 24, so the factor from 12 to 24 is 1.6; the factor from 24 to 36 stays the triangle’s.
>>> tri = Triangle.from_long(
... [2020, 2020, 2020, 2021, 2021, 2022],
... [12, 24, 36, 12, 24, 12],
... {"paid": [100.0, 150.0, 165.0, 110.0, 170.0, 120.0]},
... )
>>> bench = ChainLadder(ldf={12: 0.5, 24: 0.8}, ldf_kind="percent_developed").fit(tri, "paid")
>>> [round(f, 4) for f in bench.ldf], [round(f, 4) for f in bench.estimated_ldf]([1.6, 1.1], [1.5238, 1.1])
>>> round(bench.ultimate[2], 2), round(bench.pattern_rescale, 4)(211.2, 1.1364)
A pattern to the oldest age with no tail keeps its level as the tail: 95% developed at 36 months is a tail of 1 / 0.95.
>>> full = ChainLadder(ldf={12: 0.5, 24: 0.8, 36: 0.95}, ldf_kind="percent_developed")
>>> fit = full.fit(tri, "paid")
>>> round(fit.pattern_tail, 4), round(fit.ultimate[2], 2)(1.0526, 240.0)
Attributes
| Name | Description |
|---|---|
| average | How link ratios are averaged. |
| 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.
|
| sigma_interpolation | How unestimable variance parameters are filled in. |
| tail | The tail: a constant factor as a number, otherwise its estimator. |
average
How link ratios are averaged.
average: str
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
sigma_interpolation
How unestimable variance parameters are filled in.
sigma_interpolation: str
tail
The tail: a constant factor as a number, otherwise its estimator.
tail: Any
Methods
| Name | Description |
|---|---|
| fit() | Fits one measure column in every segment of a triangle, each on its |
| fit_diagonal() | Projects a latest diagonal, in every segment, with the fully |
fit()
Fits one measure column in every segment of a triangle, each on its
Usage
fit(triangle, column)own.
Parameters
triangle: Triangle-
Cumulative or incremental, with any number of segments.
column: str
Returns
ChainLadderFit
Raises
ValueError- If the column is unknown, a factor cannot be estimated or the tail cannot be fitted (a constant that is not positive, a curve with fewer than two factors above 1 to fit); with keys, the message names the segment.
fit_diagonal()
Projects a latest diagonal, in every segment, with the fully
Usage
fit_diagonal(diagonal, development=None, segment_map=None)selected pattern ldf (ldf_weight 1, no n_periods or drops) or with the development of a fit (development): docs/design/reserving-v02.md, decisions 15 to 19. Each origin’s latest value is multiplied by the pattern’s factor to ultimate at its own age, read log(cdf)-linearly between the pattern’s ages, and the tail. The fit’s development axis is the grid the diagonal is placed on, which spans the pattern’s ages as well as the diagonal’s; its origins run oldest first over every period from the earliest to the latest. An origin older than the pattern’s end is developed as the diagonal’s past_pattern_end says.
Parameters
diagonal: LatestDiagonaldevelopment: ChainLadderFit = None-
A fit whose factors and tail develop the diagonal, each segment by the source segment of the same label (a single-segment source develops every segment): chainladder-python’s
fit(source).predict(target). For another method’s fit, pass its.chain_ladder. The method itself then takes no ldf, no tail other than 1 and no n_periods, drop_high or drop_low. The source’s factors are read at each origin’s own age, as fitted, with no ldf_origin: a source fitted on another origin grain (accident quarters for a diagonal of accident years, say) goes through to_chain_ladder() instead, with ldf_origin added to the arguments it gives, one segment at a time. segment_map: dict = None-
With development, the source segment of each segment of the diagonal, as
{target: source}with labels written as index writes them ("Total", a str, or a tuple); every segment of the diagonal listed once.
Returns
ChainLadderFit
Raises
ValueError-
If there is no pattern, it is not fully selected, an origin is younger than its first age, or older than its end with
past_pattern_end="reject"; if the map leaves a segment without a source; with keys, the message names the segment.
Examples
>>> from prospicio.reserving import ChainLadder, LatestDiagonal, Triangle
>>> tri = Triangle.from_long([2020, 2020, 2021], [12, 24, 12], {"paid": [100.0, 150.0, 200.0]})
>>> own = ChainLadder().fit(tri, "paid")
>>> d = LatestDiagonal.from_triangle(tri, "paid")
>>> ChainLadder().fit_diagonal(d, development=own).ultimate[150.0, 300.0]