## reserving.PaidIncurredChain


Merz and Wüthrich's (2010) paid-incurred chain (design note


Usage

``` python
reserving.PaidIncurredChain()
```


`reserving-v02.md`, decision 32): a paid and an incurred column of one square triangle combined into one ultimate per origin, in closed form.

Log paid link ratios (and the log first paid values) are normal with means `Phi_j` and standard deviations `sigma_j`, log incurred link ratios normal with means `Psi_j` and standard deviations `tau_j`, and both reach the same ultimate. With normal priors on `Phi` and `Psi` (non-informative by default) the posterior is normal, and each origin's ultimate is predicted from its latest paid and latest incurred value, with the square root of its conditional mean squared error of prediction. As [tau](esg.Svensson.md#prospicio.esg.Svensson.tau) grows the prediction becomes Hertig's paid chain ladder, as it shrinks the incurred chain ladder on geometric averages.

The defaults reproduce R ChainLadder's [PaidIncurredChain](reserving.PaidIncurredChain.md#prospicio.reserving.PaidIncurredChain), except that ChainLadder 0.2.21 leaves out of the posterior precision the terms coupling `Psi_0` with `Phi_1, ..., Phi_J`, which the newest origin's incurred-paid ratio implies: `convention="model"` is the model's posterior, `convention="r_chainladder"` ChainLadder's to its last digits. On ChainLadder's USAA example the model's total reserve and standard error are each about 0.5% above ChainLadder's.


## Parameters


`sigma: sequence of float`  
Paid standard deviations, one per development age; `None` estimates them (`sigma_0` from the log first paid values).

`tau: sequence of float`  
Incurred standard deviations, one per development age but the last; `None` estimates them.

`extrapolation: (loglinear, mack) = ``"loglinear"`  
How the last estimated [sigma](reserving.MackFit.md#prospicio.reserving.MackFit.sigma) and [tau](esg.Svensson.md#prospicio.esg.Svensson.tau), each with one observation, are filled in: a log-linear fit to the others (R's rule), or Mack's `min(s[J-1], s[J-2], s[J-1]**2 / s[J-2])`.

`convention: (model, r_chainladder) = ``"model"`  
The model's posterior, or R ChainLadder's.

`phi_mean: sequence of float`  
Prior means and standard deviations of `Phi_0, ..., Phi_J`, one per development age; `None` for a non-informative prior. An infinite standard deviation leaves that parameter non-informative.

`phi_sd: sequence of float`  
Prior means and standard deviations of `Phi_0, ..., Phi_J`, one per development age; `None` for a non-informative prior. An infinite standard deviation leaves that parameter non-informative.

`psi_mean: sequence of float`  
The same for `Psi_0, ..., Psi_{J-1}`, one per age but the last.

`psi_sd: sequence of float`  
The same for `Psi_0, ..., Psi_{J-1}`, one per age but the last.


## Raises


`ValueError`  
If [extrapolation](reserving.ApcGlm.md#prospicio.reserving.ApcGlm.extrapolation) or [convention](reserving.PaidIncurredChain.md#prospicio.reserving.PaidIncurredChain.convention) is unknown, or only one of a prior's means and standard deviations is given.


## Examples

``` python
>>> from prospicio.reserving import PaidIncurredChain, Triangle
>>> tri = Triangle.from_long(
...     [2020] * 4 + [2021] * 3 + [2022] * 2 + [2023],
...     [12, 24, 36, 48, 12, 24, 36, 12, 24, 12],
...     {
...         "paid": [100, 150, 170, 180, 110, 168, 186, 125, 180, 130],
...         "incurred": [200, 195, 185, 181, 215, 200, 192, 240, 230, 260],
...     },
... )
>>> fit = PaidIncurredChain().fit(tri, "paid", "incurred")
>>> fit.reserve[0], fit.total_std_err > 0
```

(0.0, True)


## Attributes

| Name | Description |
|----|----|
| [convention](#convention) | The posterior precision used. |
| [extrapolation](#extrapolation) | How the last estimated variances are filled in. |
| [sigma](#sigma) | The given paid standard deviations, or `None`. |
| [tau](#tau) | The given incurred standard deviations, or `None`. |

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


#### convention


The posterior precision used.


`convention: str`


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


#### extrapolation


How the last estimated variances are filled in.


`extrapolation: str`


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


#### sigma


The given paid standard deviations, or `None`.


`sigma: list[float] | None`


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


#### tau


The given incurred standard deviations, or `None`.


`tau: list[float] | None`


## Methods

| Name | Description |
|----|----|
| [fit()](#fit) | Fits the paid and incurred columns of a single-segment triangle. |

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


#### fit()


Fits the paid and incurred columns of a single-segment triangle.


Usage

``` python
fit(triangle, paid, incurred)
```


##### Parameters


`triangle: Triangle`  
As many origins as development ages (at least four), each origin observed at exactly its ages up to the latest diagonal, every value positive.

`paid: str`  
Names of the paid and incurred columns.

`incurred: str`  
Names of the paid and incurred columns.


##### Returns


`PaidIncurredFit`  


##### Raises


`ValueError`  
For a triangle of another shape or with several segments, a value that is not positive, settings of the wrong length or out of range, or an estimated variance of zero.
