## reserving.OdpBootstrap


Over-dispersed Poisson bootstrap of the chain ladder (England and


Usage


``` python
reserving.OdpBootstrap()
```


Verrall 2002), as R ChainLadder's `BootChainLadder`: adjusted Pearson residuals of the volume-weighted chain ladder are resampled into pseudo triangles, each is re-projected, and process error is added to every future incremental value. Simulation `i` uses random stream `i` of [seed](aggregate.EventSet.md#prospicio.aggregate.EventSet.seed) for every segment in turn, so results do not depend on the number of threads.


## Parameters


`n_sims: int = ``10000`  
Number of simulations; positive.

`seed: int = ``0`  
Seed of the simulation streams, from 0 to `2**64 - 1`. R accepts seeds below `2**53`; a seed in both ranges gives the same draws.

`process: (gamma, none) = ``"gamma"`  
Process error on each simulated future incremental value: Gamma with the expected value as mean and variance `scale * |mean|` (R's `process.distr = "gamma"`), or none for parameter error only.


## Raises


`ValueError`  
If [n_sims](aggregate.EventSet.md#prospicio.aggregate.EventSet.n_sims) is zero or [process](reserving.OdpBootstrap.md#prospicio.reserving.OdpBootstrap.process) is unknown.

`OverflowError`  
If [n_sims](aggregate.EventSet.md#prospicio.aggregate.EventSet.n_sims) or [seed](aggregate.EventSet.md#prospicio.aggregate.EventSet.seed) is negative or too large.


## Examples

``` python
>>> from prospicio.reserving import OdpBootstrap, Triangle
>>> tri = Triangle.from_long(
...     [2020] * 4 + [2021] * 3 + [2022] * 2 + [2023],
...     [12, 24, 36, 48, 12, 24, 36, 12, 24, 12],
...     [100.0, 150.0, 165.0, 170.0, 110.0, 170.0, 180.0, 120.0, 175.0, 130.0],
... )
>>> fit = OdpBootstrap(n_sims=2000, seed=42).fit(tri, "values")
>>> fit.reserves.components()
```

\[('2020',), ('2021',), ('2022',), ('2023',)\]

``` python
>>> fit.reserves.mean() > 0
```

True


## Attributes

| Name | Description |
|----|----|
| [n_sims](#n_sims) | Number of simulations. |
| [process](#process) | Process error: `"gamma"` or `"none"`. |
| [seed](#seed) | Seed of the simulation streams. |

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


#### n_sims


Number of simulations.


`n_sims: int`


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


#### process


Process error: `"gamma"` or `"none"`.


`process: str`


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


#### seed


Seed of the simulation streams.


`seed: int`


## Methods

| Name | Description |
|----|----|
| [fit()](#fit) | Bootstraps one measure column in every segment of a cumulative |
| [one_year()](#one_year) | The one-year view of any reserving method: the claims development |

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


#### fit()


Bootstraps one measure column in every segment of a cumulative


Usage


``` python
fit(triangle, column)
```


triangle, each with its own residuals and scale, into one joint distribution of the reserves. Every origin must be observed from the first age up to its latest.


##### Parameters


`triangle: Triangle`  
Cumulative, with any number of segments.

`column: str`  


##### Returns


`OdpBootstrapFit`  


##### Raises


`ValueError`  
As [ChainLadder.fit](reserving.ChainLadder.md#prospicio.reserving.ChainLadder.fit), and if an origin has a gap before its latest age or a segment has too few observed cells for the degrees of freedom to be positive.


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


#### one_year()


The one-year view of any reserving method: the claims development


Usage


``` python
one_year(triangle, column, method, exposure=None)
```


result over the coming year, by re-reserving on the bootstrap ("actuary in the box"). The coming year is every cell valued in the twelve months after the segment's valuation: one per origin for an annual development grain, four for a quarterly one (fewer for an origin that reaches the last age). Each simulation resamples the residuals for the volume-weighted factors, projects the increments of those cells in turn from the origin's resampled latest value with the bootstrap's process error, as [fit](risk.Gpd.md#prospicio.risk.Gpd.fit) projects, adds them to the observed latest value, appends the cells to the triangle, refits [method](risk.Allocation.md#prospicio.risk.Allocation.method) and records `CDR = opening ultimate - closing ultimate`; a negative CDR is an adverse development. An origin whose remaining cells all fall in the year thus has its lifetime bootstrap reserve as its one-year view; an origin at the last age gets no new cell; an origin short of the latest diagonal develops from its own latest cell, and only the year's cells are appended. Unlike [MackFit.claims_development_result()](reserving.MackFit.md#prospicio.reserving.MackFit.claims_development_result) (Merz and Wüthrich), any averaging, tail and development grain are allowed.


##### Parameters


`triangle: Triangle`  
Cumulative, with any number of segments and any development grain.

`column: str`  

`method: (ChainLadder, ExpectedLoss, BornhuetterFerguson, Benktander or CapeCod)`  
The method refitted at the start and at the end of the year.

`exposure: str = None`  
The exposure column; required by the expected-loss methods, not taken by [ChainLadder](reserving.ChainLadder.md#prospicio.reserving.ChainLadder). Its latest value per origin is kept for the end of the year.


##### Returns


`OneYearFit`  


##### Raises


`TypeError`  
If [method](risk.Allocation.md#prospicio.risk.Allocation.method) is not one of the classes above.

`ValueError`  
As [fit](risk.Gpd.md#prospicio.risk.Gpd.fit) and the method's own [fit](risk.Gpd.md#prospicio.risk.Gpd.fit); if [exposure](reserving.ClarkFit.md#prospicio.reserving.ClarkFit.exposure) is missing for an expected-loss method or given for [ChainLadder](reserving.ChainLadder.md#prospicio.reserving.ChainLadder); or if the refit fails in any simulation (the message counts them and gives one).


##### Examples

``` python
>>> from prospicio.reserving import BornhuetterFerguson, OdpBootstrap, Triangle
>>> tri = Triangle.from_long(
...     [2020] * 4 + [2021] * 3 + [2022] * 2 + [2023],
...     [12, 24, 36, 48, 12, 24, 36, 12, 24, 12],
...     {
...         "paid": [100.0, 150.0, 165.0, 170.0, 110.0, 170.0, 180.0, 120.0, 175.0, 130.0],
...         "premium": [250.0] * 4 + [260.0] * 3 + [270.0] * 2 + [280.0],
...     },
... )
>>> boot = OdpBootstrap(n_sims=2000, seed=42)
>>> fit = boot.one_year(tri, "paid", BornhuetterFerguson(apriori=0.7), exposure="premium")
>>> fit.cdr.components()
```

\[('2020',), ('2021',), ('2022',), ('2023',)\]

``` python
>>> fit.opening_reserve[0]
```

0.0

``` python
>>> fit.cdr.variance() < boot.fit(tri, "paid").reserves.variance()
```

True
