reserving.Indexation
Restating a triangle at one price level by a CalendarIndex, and
Usage
reserving.Indexation()re-inflating a projection.
restate divides each increment of a column by I(p) / I(base), p the index period that contains the cell’s valuation month, in the triangle’s basis; inflate is its inverse. A restated triangle is developed by any method; its projected future increments, as FutureCells, are taken back to the money of their payment periods by reinflate.
Parameters
index: CalendarIndexbase: str or date-
The base price level: the index period that contains this month (
"YYYY-MM"or a date).
Examples
>>> from prospicio.reserving import CalendarIndex, Indexation, Triangle
>>> tri = Triangle.from_long(
... [2020, 2020, 2021], [12, 24, 12],
... {"paid": [100.0, 155.0, 110.0]},
... )
>>> index = CalendarIndex("2020", [1.0, 1.1], future_rate=0.1)
>>> at_2020 = Indexation(index, "2020-01")
>>> restated = at_2020.restate(tri, "paid")
>>> restated.values[0][0][[100.0, 150.0], [100.0, nan]]
Attributes
| Name | Description |
|---|---|
| base |
The base month, "YYYY-MM".
|
| index | The index. |
base
The base month, "YYYY-MM".
base: str
index
The index.
index: CalendarIndex
Methods
| Name | Description |
|---|---|
| factor() |
I(p) / I(base), p the index period that contains month:
|
| inflate() | The inverse of restate: the increments of column, at the |
| reinflate() | Future increments at the base level re-inflated to the money of |
| reinflate_draws() | Simulated future increments at the base level re-inflated to the |
| restate() | A copy of the triangle with the increments of column restated at |
factor()
I(p) / I(base), p the index period that contains month:
Usage
factor(month)the factor that takes an amount at the base level to the money of p.
Parameters
month: str or date
Returns
float
inflate()
Usage
inflate(triangle, column)base level, taken to the money of their payment periods.
Parameters
triangle: Trianglecolumn: str
Returns
Triangle
reinflate()
Future increments at the base level re-inflated to the money of
Usage
reinflate(cells)their payment periods, summed by origin.
Parameters
cells: FutureCells
Returns
Reinflated
Raises
ValueError- If the index does not cover a cell’s payment period (set a future_rate).
reinflate_draws()
Simulated future increments at the base level re-inflated to the
Usage
reinflate_draws(draws, paths=None)money of their payment periods, simulation by simulation.
draws holds one component per future cell. Its dimensions must include origin and exactly one of development or age: the age in months at the end of the cell’s development period. An origin key is a period (as a model gives it), a period label such as "2020" or "2020Q3", or an integer year. The cell is paid in the month age - 1 months after the origin’s first month, as in FutureCells.from_odp_glm. Other dimensions pass through.
Without paths, each cell of every simulation is multiplied by the factor of its payment month: reinflate applied to each simulation’s cells. With paths, simulation i of draws takes path i, and the paths replace the future rate: a payment period inside the given index takes its given value, one from the paths’ first period on takes that simulation’s level, and one past the paths’ last period is an error.
OdpGlmFit.predict_distribution, ApcGlmFit.predict_distribution and the cells of an OdpBootstrap or MackBootstrap fit made with fit(cells=True) give such draws; the bootstraps’ reserves are by origin only and are refused. The compartmental model’s paid draws are cumulative: difference them by origin first.
Parameters
draws: PredictiveDistributionpaths: IndexPaths = None- One index path per simulation, starting in the period right after the index’s last given one, at the index’s grain; the base must then be one of the given periods.
Returns
PredictiveDistribution-
The same dimensions, components (in the same order) and simulations, re-inflated, with the provenance of draws and a
reinflatedparameter.aggregate(["origin"])gives the re-inflated reserves by origin.
Raises
ValueError-
For a missing or mistyped origin or age, both development and
age, an age below 1, two origin keys that name the same period, paths that do not start right after the index or have another number of simulations, a payment period the index or the paths do not cover, or with paths a base outside the given periods.
Examples
>>> from prospicio.distributions import PredictiveDistribution
>>> from prospicio.reserving import CalendarIndex, IndexPaths, Indexation
>>> draws = PredictiveDistribution(
... ["origin", "development"], [("2022", 24), ("2022", 36)],
... [[100.0, 50.0], [120.0, 40.0]],
... )
>>> at_2022 = Indexation(CalendarIndex("2021", [1.0, 1.1]), "2022-01")
>>> paths = IndexPaths("2023", [[1.21, 1.331], [1.155, 1.21]])
>>> out = at_2022.reinflate_draws(draws, paths)
>>> [[round(x, 6) for x in row] for row in out.draw_matrix()][[110.0, 60.5], [126.0, 44.0]]
restate()
A copy of the triangle with the increments of column restated at
Usage
restate(triangle, column)the base level, in every segment. Other columns are unchanged.
Parameters
triangle: Trianglecolumn: str
Returns
Triangle
Raises
ValueError- For an unknown column or a payment period the index does not cover.