## reserving.ChainLadderFit


A fitted chain-ladder projection of every segment of a triangle column.


Usage


``` python
reserving.ChainLadderFit()
```


Per-origin lists ([origins](reserving.MackFit.md#prospicio.reserving.MackFit.origins), [latest](reserving.MackFit.md#prospicio.reserving.MackFit.latest), [ultimate](reserving.MackFit.md#prospicio.reserving.MackFit.ultimate), [reserve](reserving.MackFit.md#prospicio.reserving.MackFit.reserve)) run over the origins of each segment in turn, like the rows of [to_frame()](reserving.MackFit.md#prospicio.reserving.MackFit.to_frame), so a single-segment fit has one value per origin. Per-age lists ([ldf](reserving.MackFit.md#prospicio.reserving.MackFit.ldf), [cdf](risk.Gpd.md#prospicio.risk.Gpd.cdf), [sigma](reserving.MackFit.md#prospicio.reserving.MackFit.sigma), [std_err](reserving.MackFit.md#prospicio.reserving.MackFit.std_err)) and the tail need a single-segment fit; for several segments use [development_frame()](reserving.MackFit.md#prospicio.reserving.MackFit.development_frame) (per age), [totals_frame()](reserving.MackFit.md#prospicio.reserving.MackFit.totals_frame) ([tail](reserving.Mack.md#prospicio.reserving.Mack.tail), [tail_sigma](reserving.Mack.md#prospicio.reserving.Mack.tail_sigma), [tail_std_err](reserving.Mack.md#prospicio.reserving.Mack.tail_std_err)) or `segment(...)`.


## Examples

``` python
>>> from prospicio.reserving import ChainLadder, Triangle
>>> tri = Triangle.from_long(
...     [2020, 2020, 2021] * 2,
...     [12, 24, 12] * 2,
...     {"paid": [100.0, 150.0, 200.0, 10.0, 20.0, 30.0]},
...     keys={"lob": ["Auto"] * 3 + ["Home"] * 3},
... )
>>> fit = ChainLadder().fit(tri, "paid")
>>> fit.index, fit.reserve
```

(\['Auto', 'Home'\], \[0.0, 100.0, 0.0, 30.0\])

``` python
>>> fit.segment(lob="Home").ldf
```

\[2.0\]


## Attributes

| Name | Description |
|----|----|
| [cdf](#cdf) | Age-to-ultimate factors, one per age, including the tail. |
| [development](#development) | Development ages in months. |
| [estimated_ldf](#estimated_ldf) | Age-to-age factors as estimated, before the tail replaced any. |
| [index](#index) | Label of each segment, as [Triangle.index](reserving.Triangle.md#prospicio.reserving.Triangle.index). |
| [keys](#keys) | Names of the triangle's key columns; empty without keys. |
| [latest](#latest) | Latest observed cumulative value per origin. |
| [ldf](#ldf) | Selected age-to-age factors, which the projection uses: the |
| [origins](#origins) | Origin period of each per-origin value. |
| [reserve](#reserve) | Reserve (ultimate minus latest) per origin. |
| [sigma](#sigma) | Variance parameter of each factor, with unestimable ones |
| [std_err](#std_err) | Standard error of each factor. |
| [tail](#tail) | Tail factor from the oldest age to ultimate. |
| [tail_attachment_age](#tail_attachment_age) | Age from which [ldf](reserving.MackFit.md#prospicio.reserving.MackFit.ldf) holds the tail's factors rather than the |
| [tail_ldf](#tail_ldf) | Factors past the oldest age, which multiply to [tail](reserving.Mack.md#prospicio.reserving.Mack.tail): one per |
| [tail_sigma](#tail_sigma) | The tail's variance parameter, extrapolated log-linearly; 0 without |
| [tail_std_err](#tail_std_err) | Standard error of the tail factor, extrapolated log-linearly. |
| [total_reserve](#total_reserve) | Total reserve across segments and origins. |
| [total_ultimate](#total_ultimate) | Total ultimate across segments and origins. |
| [ultimate](#ultimate) | Projected ultimate per origin. |

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


#### cdf


Age-to-ultimate factors, one per age, including the tail.


`cdf: list[float]`


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


#### development


Development ages in months.


`development: list[int]`


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


#### estimated_ldf


Age-to-age factors as estimated, before the tail replaced any.


`estimated_ldf: list[float]`


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


#### index


Label of each segment, as [Triangle.index](reserving.Triangle.md#prospicio.reserving.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


Selected age-to-age factors, which the projection uses: the


`ldf: list[float]`


estimated ones, replaced by the tail's from its attachment age. Factor `k` links age `k` to `k + 1`.


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


#### origins


Origin period of each per-origin value.


`origins: list[str]`


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


#### reserve


Reserve (ultimate minus latest) per origin.


`reserve: list[float]`


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


#### sigma


Variance parameter of each factor, with unestimable ones


`sigma: list[float]`


interpolated (`nan` where that is impossible).


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


#### std_err


Standard error of each factor.


`std_err: list[float]`


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


#### tail


Tail factor from the oldest age to ultimate.


`tail: float`


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


#### tail_attachment_age


Age from which [ldf](reserving.MackFit.md#prospicio.reserving.MackFit.ldf) holds the tail's factors rather than the


`tail_attachment_age: int`


estimated ones; the oldest age when the tail replaced none.


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


#### tail_ldf


Factors past the oldest age, which multiply to [tail](reserving.Mack.md#prospicio.reserving.Mack.tail): one per


`tail_ldf: list[float]`


development period of the following year and one to ultimate, as chainladder-python's `ldf_` (a single factor for [TailLogLinear](reserving.TailLogLinear.md#prospicio.reserving.TailLogLinear)).


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


#### tail_sigma


The tail's variance parameter, extrapolated log-linearly; 0 without


`tail_sigma: float`


a tail (a factor of 1), `nan` if it cannot be extrapolated. A tail below 1 is read where a tail of 1.001 would be, as chainladder-python does.


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


#### tail_std_err


Standard error of the tail factor, extrapolated log-linearly.


`tail_std_err: float`


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


#### total_reserve


Total reserve across segments and origins.


`total_reserve: float`


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


#### total_ultimate


Total ultimate across segments and origins.


`total_ultimate: float`


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


#### ultimate


Projected ultimate per origin.


`ultimate: list[float]`


## Methods

| Name | Description |
|----|----|
| [development_frame()](#development_frame) | One row per segment and age: the key columns, [development](reserving.MackFit.md#prospicio.reserving.MackFit.development), |
| [segment()](#segment) | The fit of one segment, chosen by key values (compared as `str()` |
| [to_frame()](#to_frame) | One row per segment and origin: the key columns, `origin`, |
| [totals_frame()](#totals_frame) | One row per segment: the key columns, the segment's total |

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


#### development_frame()


One row per segment and age: the key columns, [development](reserving.MackFit.md#prospicio.reserving.MackFit.development),


Usage


``` python
development_frame()
```


[ldf](reserving.MackFit.md#prospicio.reserving.MackFit.ldf) (the selected factor to the next age), [cdf](risk.Gpd.md#prospicio.risk.Gpd.cdf) (to ultimate, with the tail), [sigma](reserving.MackFit.md#prospicio.reserving.MackFit.sigma) and [std_err](reserving.MackFit.md#prospicio.reserving.MackFit.std_err); the oldest age has `nan` for [ldf](reserving.MackFit.md#prospicio.reserving.MackFit.ldf), [sigma](reserving.MackFit.md#prospicio.reserving.MackFit.sigma) and [std_err](reserving.MackFit.md#prospicio.reserving.MackFit.std_err), and the tail factor as its [cdf](risk.Gpd.md#prospicio.risk.Gpd.cdf). Needs pandas.


##### Returns


`pandas.DataFrame`  


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


#### segment()


The fit of one segment, chosen by key values (compared as `str()`


Usage


``` python
segment(**keys)
```


of each value). Keys not named may take any value, so a fit with one segment needs none.


##### Returns


`ChainLadderFit`  


##### Raises


`ValueError`  
If a key or value is unknown, or the choice matches several segments.


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


#### to_frame()


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


Usage


``` python
to_frame()
```


[latest](reserving.MackFit.md#prospicio.reserving.MackFit.latest), [ultimate](reserving.MackFit.md#prospicio.reserving.MackFit.ultimate) and [reserve](reserving.MackFit.md#prospicio.reserving.MackFit.reserve). Needs pandas.


##### Returns


`pandas.DataFrame`  


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


#### totals_frame()


One row per segment: the key columns, the segment's total


Usage


``` python
totals_frame()
```


[latest](reserving.MackFit.md#prospicio.reserving.MackFit.latest), [ultimate](reserving.MackFit.md#prospicio.reserving.MackFit.ultimate) and [reserve](reserving.MackFit.md#prospicio.reserving.MackFit.reserve), and its [tail](reserving.Mack.md#prospicio.reserving.Mack.tail), [tail_sigma](reserving.Mack.md#prospicio.reserving.Mack.tail_sigma) and [tail_std_err](reserving.Mack.md#prospicio.reserving.Mack.tail_std_err). Needs pandas.


##### Returns


`pandas.DataFrame`
