## reserving.Indexation


Restating a triangle at one price level by a [CalendarIndex](reserving.CalendarIndex.md#prospicio.reserving.CalendarIndex), and


Usage

``` python
reserving.Indexation()
```


re-inflating a projection.

[restate](reserving.Indexation.md#prospicio.reserving.Indexation.restate) divides each increment of a column by `I(p) / I(base)`, [p](models.Elpd.md#prospicio.models.Elpd.p) the index period that contains the cell's valuation month, in the triangle's basis; [inflate](reserving.Indexation.md#prospicio.reserving.Indexation.inflate) is its inverse. A restated triangle is developed by any method; its projected future increments, as [FutureCells](reserving.FutureCells.md#prospicio.reserving.FutureCells), are taken back to the money of their payment periods by [reinflate](reserving.Indexation.md#prospicio.reserving.Indexation.reinflate).


## Parameters


`index: CalendarIndex`  

`base: str or date`  
The base price level: the index period that contains this month (`"YYYY-MM"` or a date).


## Examples

``` python
>>> 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](#base) | The base month, `"YYYY-MM"`. |
| [index](#index) | The index. |

------------------------------------------------------------------------


#### base


The base month, `"YYYY-MM"`.


`base: str`


------------------------------------------------------------------------


#### index


The index.


`index: CalendarIndex`


## Methods

| Name | Description |
|----|----|
| [factor()](#factor) | `I(p) / I(base)`, [p](models.Elpd.md#prospicio.models.Elpd.p) the index period that contains `month`: |
| [inflate()](#inflate) | The inverse of [restate](reserving.Indexation.md#prospicio.reserving.Indexation.restate): the increments of [column](models.Design.md#prospicio.models.Design.column), at the |
| [reinflate()](#reinflate) | Future increments at the base level re-inflated to the money of |
| [reinflate_draws()](#reinflate_draws) | Simulated future increments at the base level re-inflated to the |
| [restate()](#restate) | A copy of the triangle with the increments of [column](models.Design.md#prospicio.models.Design.column) restated at |

------------------------------------------------------------------------


#### factor()


`I(p) / I(base)`, [p](models.Elpd.md#prospicio.models.Elpd.p) the index period that contains `month`:


Usage

``` python
factor(month)
```


the factor that takes an amount at the base level to the money of [p](models.Elpd.md#prospicio.models.Elpd.p).


##### Parameters


`month: str or date`  


##### Returns


`float`  


------------------------------------------------------------------------


#### inflate()


The inverse of [restate](reserving.Indexation.md#prospicio.reserving.Indexation.restate): the increments of [column](models.Design.md#prospicio.models.Design.column), at the


Usage

``` python
inflate(triangle, column)
```


base level, taken to the money of their payment periods.


##### Parameters


`triangle: Triangle`  

`column: str`  


##### Returns


`Triangle`  


------------------------------------------------------------------------


#### reinflate()


Future increments at the base level re-inflated to the money of


Usage

``` python
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](reserving.Separation.md#prospicio.reserving.Separation.future_rate)).


------------------------------------------------------------------------


#### reinflate_draws()


Simulated future increments at the base level re-inflated to the


Usage

``` python
reinflate_draws(draws, paths=None)
```


money of their payment periods, simulation by simulation.

[draws](distributions.Sampled.md#prospicio.distributions.Sampled.draws) holds one component per future cell. Its dimensions must include `origin` and exactly one of [development](reserving.MackFit.md#prospicio.reserving.MackFit.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](reserving.FutureCells.md#prospicio.reserving.FutureCells.from_odp_glm). Other dimensions pass through.

Without [paths](models.RelaxedCv.md#prospicio.models.RelaxedCv.paths), each cell of every simulation is multiplied by the [factor](models.Terms.md#prospicio.models.Terms.factor) of its payment month: [reinflate](reserving.Indexation.md#prospicio.reserving.Indexation.reinflate) applied to each simulation's cells. With [paths](models.RelaxedCv.md#prospicio.models.RelaxedCv.paths), simulation `i` of [draws](distributions.Sampled.md#prospicio.distributions.Sampled.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](reserving.ApcGlmFit.md#prospicio.reserving.ApcGlmFit.predict_distribution) and the [cells](aggregate.GridAudit.md#prospicio.aggregate.GridAudit.cells) of an [OdpBootstrap](reserving.OdpBootstrap.md#prospicio.reserving.OdpBootstrap) or [MackBootstrap](reserving.MackBootstrap.md#prospicio.reserving.MackBootstrap) fit made with `fit(cells=True)` give such draws; the bootstraps' [reserves](reserving.ApcGlmFit.md#prospicio.reserving.ApcGlmFit.reserves) are by origin only and are refused. The compartmental model's `paid` draws are cumulative: difference them by origin first.


##### Parameters


`draws: PredictiveDistribution`  

`paths: 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](distributions.Sampled.md#prospicio.distributions.Sampled.draws) and a `reinflated` parameter. `aggregate(["origin"])` gives the re-inflated reserves by origin.


##### Raises


`ValueError`  
For a missing or mistyped origin or age, both [development](reserving.MackFit.md#prospicio.reserving.MackFit.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

``` python
>>> 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](models.Design.md#prospicio.models.Design.column) restated at


Usage

``` python
restate(triangle, column)
```


the base level, in every segment. Other columns are unchanged.


##### Parameters


`triangle: Triangle`  

`column: str`  


##### Returns


`Triangle`  


##### Raises


`ValueError`  
For an unknown column or a payment period the index does not cover.
