reserving.CapeCodFit
A fitted Cape Cod of every segment of a triangle column: the fields of
Usage
reserving.CapeCodFit()ExpectedLossFit, with apriori the detrended loss ratio applied to each origin (chainladder-python’s detrended_apriori_), plus trended_apriori before detrending (its apriori_).
Per-origin lists run over the origins of each segment in turn, like the rows of to_frame().
Examples
>>> from prospicio.reserving import CapeCod, Triangle
>>> tri = Triangle.from_long(
... [2020, 2020, 2021], [12, 24, 12],
... {"paid": [100.0, 150.0, 200.0], "premium": [250.0, 250.0, 400.0]},
... )
>>> fit = CapeCod(trend=0.1).fit(tri, "paid", "premium")
>>> round(fit.trended_apriori[0] / fit.apriori[0], 10)1.1
Attributes
| Name | Description |
|---|---|
| apriori | Detrended expected loss ratio applied per origin. |
| cdf | Age-to-ultimate factors, one per age, including the tail. |
| chain_ladder | The underlying chain-ladder projection, with the chain ladder’s |
| development | Development ages in months. |
| expected_loss | The expected-loss fit: ultimates, exposures and the detrended |
| exposure | Exposure per origin: the exposure column’s latest observed cumulative |
| index | Label of each segment, as Triangle.index. |
| keys | Names of the triangle’s key columns; empty without keys. |
| latest | Latest observed cumulative value per origin. |
| ldf |
Age-to-age factors; factor k links age k to k + 1.
|
| origins | Origin period of each per-origin value. |
| reserve | Reserve (ultimate minus latest) per origin. |
| total_reserve | Total reserve across segments and origins. |
| total_ultimate | Total ultimate across segments and origins. |
| trended_apriori | Expected loss ratio per origin at the valuation date’s price level, |
| ultimate | Cape Cod ultimate per origin. |
apriori
Detrended expected loss ratio applied per origin.
apriori: list[float]
cdf
Age-to-ultimate factors, one per age, including the tail.
cdf: list[float]
chain_ladder
The underlying chain-ladder projection, with the chain ladder’s
chain_ladder: ChainLadderFit
ultimate.
development
Development ages in months.
development: list[int]
expected_loss
The expected-loss fit: ultimates, exposures and the detrended
expected_loss: ExpectedLossFit
apriori.
exposure
Exposure per origin: the exposure column’s latest observed cumulative
exposure: list[float]
value.
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]
latest
Latest observed cumulative value per origin.
latest: list[float]
ldf
ldf: list[float]
origins
Origin period of each per-origin value.
origins: list[str]
reserve
Reserve (ultimate minus latest) per origin.
reserve: list[float]
total_reserve
Total reserve across segments and origins.
total_reserve: float
total_ultimate
Total ultimate across segments and origins.
total_ultimate: float
trended_apriori
Expected loss ratio per origin at the valuation date’s price level,
trended_apriori: list[float]
before detrending. For a treaty year that incepts later, trend it one more year (or the years from the valuation date to the treaty year’s average date) beyond this value.
ultimate
Cape Cod ultimate per origin.
ultimate: list[float]
Methods
| Name | Description |
|---|---|
| development_frame() | One row per segment and age, as ChainLadderFit.development_frame. |
| from_json() | A fit from a document written by to_json. |
| segment() | The fit of one segment, chosen by key values as |
| to_frame() |
One row per segment and origin: the key columns, origin,
|
| to_json() | This fit, every segment, as a JSON document that from_json reads |
| totals_frame() | One row per segment: the key columns and the segment’s total |
development_frame()
One row per segment and age, as ChainLadderFit.development_frame.
Usage
development_frame()Needs pandas.
Returns
pandas.DataFrame
from_json()
A fit from a document written by to_json.
Usage
from_json(text)Parameters
text: str
Returns
CapeCodFit
Raises
ValueError- If the text is not such a document, or is from a newer version.
segment()
The fit of one segment, chosen by key values as
Usage
segment(**keys)Returns
CapeCodFit
to_frame()
One row per segment and origin: the key columns, origin,
Usage
to_frame()latest, ultimate, reserve, exposure, apriori, trended_apriori and ulr, the ultimate over the exposure (a loss ratio only when the exposure is premium). Needs pandas.
Returns
pandas.DataFrame
to_json()
This fit, every segment, as a JSON document that from_json reads
Usage
to_json()back exactly, every number bit for bit. Pickling uses it too.
Returns
str
Examples
>>> import pickle
>>> from prospicio.reserving import CapeCod, CapeCodFit, Triangle
>>> tri = Triangle.from_long(
... [2020, 2020, 2021], [12, 24, 12],
... {"paid": [100.0, 150.0, 200.0], "premium": [250.0, 250.0, 400.0]},
... )
>>> fit = CapeCod(trend=0.1).fit(tri, "paid", "premium")
>>> CapeCodFit.from_json(fit.to_json()).ultimate == fit.ultimateTrue
>>> pickle.loads(pickle.dumps(fit)).to_json() == fit.to_json()True
totals_frame()
One row per segment: the key columns and the segment’s total
Usage
totals_frame()latest, ultimate, reserve, exposure and ulr, the total ultimate over the total exposure. Needs pandas.
Returns
pandas.DataFrame