Skip to main content

reserving.OdpBootstrapFit

A fitted ODP bootstrap of every segment.

Usage

Source

reserving.OdpBootstrapFit()

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. fitted, residuals and scale need a single-segment fit; for several segments use segment(...) or totals_frame(). fitted and residuals are nested lists indexed [origin][development], like one segment of Triangle.values, with nan where the triangle is not observed.

Attributes

Name Description
cells Each simulation’s future incremental values, as simulated with their
chain_ladder The deterministic volume-weighted chain ladder the bootstrap is
development Development ages in months.
fitted Fitted incremental values, [origin][development].
index Label of each segment, as Triangle.index.
keys Names of the triangle’s key columns; empty without keys.
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 (the sum of future incremental
residuals Adjusted Pearson residuals (x - m) / sqrt(|m|) * sqrt(n / (n - p)),
scale The scale parameter phi: the sum of squared unadjusted residuals
ultimates Joint distribution of the ultimate by segment and origin: reserves with

cells

Each simulation’s future incremental values, as simulated with their

cells: PredictiveDistribution | None

process error, or None unless the fit was made with fit(cells=True). 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, 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, so cells.aggregate(keys + ["origin"]) gives the reserves. Indexation.reinflate_draws takes them as they are.


chain_ladder

The deterministic volume-weighted chain ladder the bootstrap is

chain_ladder: ChainLadderFit

centred on, with the bootstrap’s tail.


development

Development ages in months.

development: list[int]


fitted

Fitted incremental values, [origin][development].

fitted: list[list[float]]


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]


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 (the sum of future incremental

reserves: PredictiveDistribution

values) 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

Adjusted Pearson residuals (x - m) / sqrt(|m|) * sqrt(n / (n - p)),

residuals: list[list[float]]

[origin][development]; nan where not observed or where the fitted value is zero.


scale

The scale parameter phi: the sum of squared unadjusted residuals

scale: float

over the degrees of freedom n - p.


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, the
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
OdpBootstrapFit
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
OdpBootstrapFit

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 OdpBootstrap, OdpBootstrapFit, 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 = OdpBootstrap(n_sims=100, seed=1).fit(tri, "paid")
>>> OdpBootstrapFit.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, the

Usage

Source

totals_frame()

scale, and 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