## kernels.rereserve()


`(n_draws, n_w)` one-year CDR draws from simulated next-diagonal values.


Usage

``` python
kernels.rereserve(
    fit,
    next_diagonal,
)
```


The second axis, and it is not a choice: the reserve is re-estimated with the **volume-weighted chain ladder**, which is the market convention and what R's `ChainLadder` uses for its Mack CDR and its bootstrap CDR alike (`getAvDFs(dfs, wghts)` with the cumulative triangle as weights *is* the volume-weighted factor written out). Every generator therefore shares this one implementation, and a third-party diagonal - draws from any model that can predict next year's cells - can be re-reserved by calling this directly.

`next_diagonal[:, i]` is origin `i`'s **cumulative** loss one year on, on the same basis as `fit.cum`. Closed origins are ignored (they have no next cell, so their CDR is identically zero); pass zeros there.

What happens, per draw:

1.  append the diagonal and re-run the chain ladder. Only the factors move, and each moves by exactly one new observation, because on a run-off staircase exactly one origin joins each development step next year:

``` python
f_j^{I+1} = (S_j f_j-hat + X_{i_j}) / (S_j + C_{i_j,j})
```

which is algebraically the volume-weighted factor recomputed on the extended triangle - the numerator `S_j f_j-hat` is `sum_i C_{i,j+1}` and the denominator is `sum_i C_{i,j}`, so adding the new pair to each is the refit; 2. re-project each origin's ultimate off its new diagonal cell with the suffix product of the UPDATED factors; 3. `CDR_i = C-hat_{i,J}^{I} - C-hat_{i,J}^{I+1}`, so a positive draw is a reserve release.

Only `f`, `s`, [latest](kernels.MackFit.md#ibnr.kernels.MackFit.latest), `latest_dev` and [ultimate](kernels.MackFit.md#ibnr.kernels.MackFit.ultimate) are read off the fit - the volume-weighted chain ladder and the triangle it came from. Mack's `sigma2` is not touched, which is why the ODP bootstrap can use the identical function.

ONE MACK ASSUMPTION SURVIVES HERE AND IT IS WORTH NAMING. Step 3 differences against `fit.ultimate`, the *deterministic* chain-ladder ultimate at time I. Under Mack that is exactly right and it is what makes `E[CDR | D_I] = 0` - the draws are centred on zero, so `E[CDR^2]` (`simulated_msep()`) is the risk measure. Under a residual bootstrap the simulated diagonal's mean is only *approximately* the chain-ladder projection, so the CDR draws carry a small bootstrap bias and the mean square about zero is not quite the variance. R makes the same distinction from the other side: its Mack CDR reports the analytic msep (about zero) while `CDR.BootChainLadder` reports `sd()` of the re-reserved amount (about its own mean). Report both when the generator is not `mack`.

Under a GALLERY generator the drift is not a nuisance at all - it is the model saying next year's diagonal will land somewhere other than where the chain ladder puts it, which is most of what a separate model is FOR. It is still not part of a variance, so the same rule applies with more force: `mean` and `sd` separately, never `E[CDR^2]` alone.
