## reserving.MackBootstrap


Mack's bootstrap for the lifetime and one-year views (England, Verrall


Usage


``` python
reserving.MackBootstrap()
```


and Wüthrich 2019, Appendix 1): the scaled bias-adjusted residuals of the link ratios are resampled into pseudo factors, and each future cumulative value, to the last age ([fit](risk.Gpd.md#prospicio.risk.Gpd.fit)) or over the coming year ([one_year](reserving.OdpBootstrap.md#prospicio.reserving.OdpBootstrap.one_year)), is drawn from the one before `C` (the observed latest value for the first) with mean `f* C` and Mack's variance `sigma**2 * abs(C)**(2 - alpha)`. The lifetime view's standard deviation approximates Mack's analytic standard error. Beside [OdpBootstrap](reserving.OdpBootstrap.md#prospicio.reserving.OdpBootstrap) (variance [scale](reserving.ClarkFit.md#prospicio.reserving.ClarkFit.scale) times the mean increment), it gives the one-year view under Mack's process: with the volume-weighted chain ladder and no tail, its standard deviation is [MackFit.claims_development_result()](reserving.MackFit.md#prospicio.reserving.MackFit.claims_development_result)'s (Merz and Wüthrich) within Monte Carlo error. The residuals are centred by default ([centre_residuals](reserving.MackBootstrap.md#prospicio.reserving.MackBootstrap.centre_residuals)), so the mean CDR is Merz and Wüthrich's zero and the lifetime mean reserve the chain ladder's, and EVW's Table 4 expected reserves agree. Uncentred, as EVW's Appendix 1 is written, the pool's non-zero mean biases the pseudo factors: the mean CDR is about -0.2 (RAA), -0.04 (GenIns) and +0.18 (ABC) times its standard deviation, the lifetime mean reserve about +17%, +0.7% and -0.8% off the chain ladder's, and the one-year standard deviation up to 1.3% wide on RAA. Simulation `i` uses random stream `i` of [seed](aggregate.EventSet.md#prospicio.aggregate.EventSet.seed) for every segment in turn.


## Parameters


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

`seed: int = ``0`  
Seed of the simulation streams, from 0 to `2**64 - 1`.

`process: (gamma, lognormal, residuals, normal, none) = ``"gamma"`  
Process error on each next cumulative value: Gamma or lognormal (negated for a negative mean) or normal, with Mack's mean and variance; the mean plus a resampled residual times the standard deviation, which carries the residuals' mean and variance; or none for parameter error only.

`average: (volume, simple, regression) = ``"volume"`  
How Mack's model averages the link ratios (its [alpha](models.ElasticNet.md#prospicio.models.ElasticNet.alpha)).

`sigma_interpolation: (log - linear, mack) = ``"log-linear"`  
How a sigma behind a single link ratio is filled in.

`centre_residuals: bool = ``True`  
Subtract the residuals' mean before resampling them, so that the pseudo factors are unbiased, the mean CDR is about zero and the lifetime mean reserve is the chain ladder's. `False` resamples them uncentred, as EVW's Appendix 1 is written.


## Raises


`ValueError`  
If [n_sims](aggregate.EventSet.md#prospicio.aggregate.EventSet.n_sims) is zero or a setting 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 ChainLadder, Mack, MackBootstrap, 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 = MackBootstrap(n_sims=2000, seed=42).one_year(tri, "values", ChainLadder())
>>> fit.model
```

'mack'

``` python
>>> fit.cdr.variance() ** 0.5 < Mack().fit(tri, "values").total_standard_error
```

True


## Attributes

| Name | Description |
|----|----|
| [average](#average) | How Mack's model averages the link ratios. |
| [centre_residuals](#centre_residuals) | Whether the residuals are centred before they are resampled. |
| [n_sims](#n_sims) | Number of simulations. |
| [process](#process) | Process error: `"gamma"`, `"lognormal"`, `"residuals"`, |
| [seed](#seed) | Seed of the simulation streams. |
| [sigma_interpolation](#sigma_interpolation) | How a sigma behind a single link ratio is filled in. |

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


#### average


How Mack's model averages the link ratios.


`average: str`


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


#### centre_residuals


Whether the residuals are centred before they are resampled.


`centre_residuals: bool`


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


#### n_sims


Number of simulations.


`n_sims: int`


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


#### process


Process error: `"gamma"`, `"lognormal"`, `"residuals"`,


`process: str`


`"normal"` or `"none"`.


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


#### seed


Seed of the simulation streams.


`seed: int`


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


#### sigma_interpolation


How a sigma behind a single link ratio is filled in.


`sigma_interpolation: str`


## Methods

| Name | Description |
|----|----|
| [fit()](#fit) | The lifetime view: bootstraps one measure column in every segment of |
| [one_year()](#one_year) | The one-year view of any reserving method under Mack's process, as |

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


#### fit()


The lifetime view: bootstraps one measure column in every segment of


Usage


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


a cumulative triangle, each with its own Mack model and residuals, into one joint distribution of the reserves (EVW's Appendix 1). Each simulation resamples the residuals into pseudo factors and draws every cumulative value from the latest observed one to the last age, each from the one before, with Mack's mean and variance; an origin's reserve is its last drawn value less its latest. Mack's model has no tail here, so development past the oldest age is not simulated. The standard deviation approximates Mack's analytic standard error ([Mack.fit](reserving.Mack.md#prospicio.reserving.Mack.fit)); the mean is the chain ladder's reserve with [centre_residuals](reserving.MackBootstrap.md#prospicio.reserving.MackBootstrap.centre_residuals) (the default), about 17% above it on RAA without.


##### Parameters


`triangle: Triangle`  
Cumulative, with any number of segments and any development grain, every origin observed from the first age to its latest with no negative value.

`column: str`  


##### Returns


`MackBootstrapFit`  


##### Raises


`ValueError`  
As [Mack.fit](reserving.Mack.md#prospicio.reserving.Mack.fit), if an origin has a gap before its latest age, or if a cumulative value is negative.


##### Examples

``` python
>>> from prospicio.reserving import MackBootstrap, 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 = MackBootstrap(n_sims=2000, seed=42).fit(tri, "values")
>>> fit.reserves.components()
```

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

``` python
>>> abs(fit.reserves.mean() / fit.chain_ladder.total_reserve - 1) < 0.05
```

True

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


#### one_year()


The one-year view of any reserving method under Mack's process, as


Usage


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


[OdpBootstrap.one_year](reserving.OdpBootstrap.md#prospicio.reserving.OdpBootstrap.one_year): each simulation draws the cells of the coming twelve months from Mack's bootstrap, each from the one before with the same pseudo factors, appends them to the triangle, refits [method](risk.Allocation.md#prospicio.risk.Allocation.method) and records `CDR = opening ultimate - closing ultimate`. Mack's model has no tail here: development past the oldest age moves only through [method](risk.Allocation.md#prospicio.risk.Allocation.method)'s refitted tail.


##### Parameters


`triangle: Triangle`  
Cumulative, with any number of segments and any development grain, every origin observed from the first age to its latest with no negative value.

`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).


##### Returns


`OneYearFit`  
With `model == "mack"`.


##### Raises


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

`ValueError`  
As [OdpBootstrap.one_year](reserving.OdpBootstrap.md#prospicio.reserving.OdpBootstrap.one_year) and [Mack.fit](reserving.Mack.md#prospicio.reserving.Mack.fit), and if a cumulative value is negative.
