Skip to main content

reserving.MackBootstrapFit

A fitted bootstrap of Mack’s model, the lifetime view, of every

Usage

Source

reserving.MackBootstrapFit()

segment (MackBootstrap.fit).

reserves is one joint distribution with the triangle’s keys and "origin" as dimensions, so reserves.aggregate(["lob"]) keeps the dependence between segments. Per-origin lists run over the origins of each segment in turn, like the rows of to_frame() and the components of reserves. residuals needs a single-segment fit; for several segments use segment(...).

Attributes

Name Description
cells Each simulation’s future incremental values, or None unless the
chain_ladder The chain ladder of Mack’s model (its averaging), with the
development Development ages in months.
index Label of each segment, as Triangle.index.
keys Names of the triangle’s key columns; empty without keys.
mack Mack’s model on the observed triangle, with the bootstrap’s tail:
origins Origin period of each per-origin value and reserve component.
patterns Each simulation’s development pattern, to pair with the
reserves Joint distribution of the reserve (each origin’s last simulated
residuals Mack’s scaled bias-adjusted residuals of the link ratios,
ultimates Joint distribution of the ultimate by segment and origin: reserves with

cells

Each simulation’s future incremental values, or None unless the

cells: PredictiveDistribution | None

fit was made with fit(cells=True): each simulated cumulative value less the one before it, starting from the observed latest value, so that they are payments. The dimensions are the triangle’s keys, "origin" and "development" (the age in months at the end of the cell’s development period); one component per future cell, each origin’s cells after its latest age in age order, segment by segment as reserves; one row per simulation, in the reserves’ order (under dependence="rank_correlation" each segment’s cells move with its reserves). With a tail each origin has one more cell, the ultimate less the value at the oldest age, at the oldest age plus one development period, kept in every simulation even when it is 0. A fully developed origin with no tail has no cell. Each origin’s cells sum to its reserve in every simulation to round-off, so cells.aggregate(keys + ["origin"]) gives the reserves. Indexation.reinflate_draws takes them as they are.


chain_ladder

The chain ladder of Mack’s model (its averaging), with the

chain_ladder: ChainLadderFit

bootstrap’s tail: the reserves the bootstrap’s mean equals with centre_residuals=True, the default, without a tail or with a constant one (an estimated tail’s refit has its own mean).


development

Development ages in months.

development: list[int]


index

Label of each segment, as Triangle.index.

index: list[Any]


keys

Names of the triangle’s key columns; empty without keys.

keys: list[str]


mack

Mack’s model on the observed triangle, with the bootstrap’s tail:

mack: MackFit

the factors and sigmas the simulation uses, and the analytic standard errors the simulated standard deviations approximate (with an estimated tail, up to the refit’s own parameter error).


origins

Origin period of each per-origin value and reserve component.

origins: list[str]


patterns

Each simulation’s development pattern, to pair with the

patterns: DevelopmentPatterns

simulation’s loss ratio in the cash-flow engine.

Row i of every pattern is simulation i of reserves, ultimates and ultimate_draws.


reserves

Joint distribution of the reserve (each origin’s last simulated

reserves: PredictiveDistribution

cumulative value less its latest) by segment and origin: the triangle’s keys and "origin" are its dimensions, one component per segment and origin, one row per simulation. Its mean and quantile describe the total reserve. Columns of draw_matrix() follow origins.


residuals

Mack’s scaled bias-adjusted residuals of the link ratios,

residuals: list[list[float]]

[origin][development], [o][k] the link from age k to k + 1; nan where there is none, from a zero, or behind a factor with a single link ratio or a zero sigma. Never centred.


ultimates

Joint distribution of the ultimate by segment and origin: reserves with

ultimates: PredictiveDistribution

each origin’s latest value added in every simulation, the same dimensions, components and rows, so join, select and reorder_groups keep each simulation’s origins together.

Methods

Name Description
development_frame() The chain ladders’ development factors, one row per segment and
discounted() The unpaid claims discounted simulation by simulation, by origin and
from_json() A fit from a document written by to_json.
loss_ratio_draws() Each simulation’s ultimate over premium: the loss ratio a
segment() The bootstrap of one segment, chosen by key values as
to_frame() One row per segment and origin: the key columns, origin, the
to_json() This fit, every segment, as a JSON document that from_json reads
totals_frame() One row per segment: the key columns, the chain ladder’s totals, and
ultimate_draws() Each simulation’s ultimate, for a tower, a deal book or the cash-flow

development_frame()

The chain ladders’ development factors, one row per segment and

Usage

Source

development_frame()

age, as ChainLadderFit.development_frame. Needs pandas.

Returns
pandas.DataFrame

discounted()

The unpaid claims discounted simulation by simulation, by origin and

Usage

Source

discounted(
    *,
    basis,
    rate=None,
    curve=None,
    timing="mid",
    paid_pattern=None,
    latest_paid=None
)

in total, for the IFRS 17 liability for incurred claims and its risk adjustment (DiscountedReserves, docs/design/reserving-ifrs17.md).

Each simulation’s reserve is spread over that simulation’s pattern: the rises of its running maximum after each origin’s latest age, the tail’s share one period past the oldest age.

Parameters
basis: (paid, incurred) = "paid"

What the fit’s column is, stated by the caller (no default), so that a fit on incurred claims is not discounted by its reporting pattern by mistake. "paid" pays each simulation’s reserve along that simulation’s own pattern. "incurred" pays each reserve (the IBNR) plus the origin’s case reserve (its latest incurred less latest_paid) along paid_pattern.

rate: float = None

A flat annual effective rate. Give rate or curve.

curve: DiscountCurve = None

Spot rates by maturity.

timing: (mid, end) = "mid"

Payments at the middle or the end of each development period.

paid_pattern: list of float = None

For basis="incurred": the cumulative paid share at each of the fit’s pattern ages (with the tail’s age when the fit has a tail), ending at 1.

latest_paid: list of float = None
For basis="incurred": each origin’s latest paid, one per component of reserves in their order.
Returns
DiscountedReserves

from_json()

A fit from a document written by to_json.

Usage

Source

from_json(text)
Parameters
text: str
Returns
MackBootstrapFit
Raises
ValueError
If the text is not such a document, or is from a newer version.

loss_ratio_draws()

Each simulation’s ultimate over premium: the loss ratio a

Usage

Source

loss_ratio_draws(origin, premium)

contract on the loss ratio reads, in the order of ultimate_draws. Multiply by the premium for Tower.apply_annual.

Parameters
origin: (tuple, str, int or None)

As in ultimate_draws; None for the total.

premium: float
The subject premium of the origin (of every origin for the total), finite and positive.
Returns
list of float

segment()

The bootstrap of one segment, chosen by key values as

Usage

Source

segment(**keys)

ChainLadderFit.segment, with its part of the joint reserves (same dimensions) and of cells. Its cells are None when the fit kept none, and also when it kept them but this segment has no future cell (fully developed, with no tail).

Returns
MackBootstrapFit

to_frame()

One row per segment and origin: the key columns, origin, the

Usage

Source

to_frame()

chain ladder’s latest, ultimate and reserve, and the mean and std_dev of the bootstrapped reserve. Needs pandas.

Returns
pandas.DataFrame

to_json()

This fit, every segment, as a JSON document that from_json reads

Usage

Source

to_json()

back exactly: the simulated reserves, the patterns and the cells (if kept) included, every number bit for bit. Pickling uses it too.

Returns
str
Examples
>>> import pickle
>>> from prospicio.reserving import MackBootstrap, MackBootstrapFit, Triangle
>>> tri = Triangle.from_long(
...     origin=[2020] * 4 + [2021] * 3 + [2022] * 2 + [2023],
...     development=[12, 24, 36, 48, 12, 24, 36, 12, 24, 12],
...     values={"paid": [100.0, 150.0, 165.0, 170.0, 110.0, 172.0, 185.0,
...                      120.0, 175.0, 130.0]})
>>> fit = MackBootstrap(n_sims=100, seed=1).fit(tri, "paid")
>>> MackBootstrapFit.from_json(fit.to_json()).reserves.mean() == fit.reserves.mean()

True

>>> pickle.loads(pickle.dumps(fit)).to_json() == fit.to_json()

True


totals_frame()

One row per segment: the key columns, the chain ladder’s totals, and

Usage

Source

totals_frame()

the mean and std_dev of the segment’s bootstrapped total reserve. Needs pandas.

Returns
pandas.DataFrame

ultimate_draws()

Each simulation’s ultimate, for a tower, a deal book or the cash-flow

Usage

Source

ultimate_draws(origin=None)

engine: index i is simulation i for every origin and every call, the same as row i of reserves and ultimates, and the same again when the fit is run with the same seed.

The ultimate is the origin’s latest value plus its reserve in that simulation.

Parameters
origin: (tuple, str, int or None) = None
The component key, the segment’s key values then the origin (("Auto", 2021)); an origin period by its label ("2021", 2021, "2021Q3"). None (the default) gives the total over every component, summed simulation by simulation.
Returns
list of float