## methods.mack()


Mack's chain ladder: the chain-ladder ultimate and its standard error.


Usage

``` python
methods.mack(
    cells,
    *,
    dev_grain_months=12,
    sigma_rule="log_linear",
    zero_cells="missing",
    average="volume",
    history_periods=None,
    drop_high=False,
    drop_low=False,
    preserve=1,
    drop_above=None,
    drop_below=None,
    exclude=(),
    exclude_valuations=(),
    trim_ties="volume",
    exhausted_exclusions="keep",
    tail=None,
    tail_factor=None,
    tail_decay=None,
    tail_attach_lag=None,
    tail_fit_lags=None,
    tail_steps=None,
    tail_rows=None,
    tail_sigma=None,
    tail_std_err=None
)
```


Mack (1993), distribution-free, and Mack (1999) for the development options. `cells` is as in [chain_ladder()](methods.chain_ladder.md#ibnr.methods.chain_ladder), and so are the development options, which choose the link ratios exactly as they do there: the same options give the same factors, bit for bit, and the same `link_ratios` table. There is no `unsupported_factor`: an age the options leave with no link ratio is refused, because a factor of 1.0 there would be chosen, not estimated, and Mack's formulas give it no variance.

`average` is `"volume"` (the default), `"simple"` or `"regression"`. In Mack's terms each link ratio is weighted by the amount it starts from to the power alpha, 1, 0 or 2, and the variance of one development step is `sigma ** 2 * amount ** (2 - alpha)`. `"median"` is refused: a median is not a weighted mean of the ratios, so Mack's variance does not exist for it (`"geometric"` is refused for the same reason).

The options choose which link ratios estimate the factors and the sigmas. The development still to come from each origin's latest amount keeps its full variance whatever was left out; chainladder-python drops the first year of it whenever a drop or a bound is set, and this function does not (`docs/coming-from-chainladder.md` has the numbers). `drop_high`, `drop_low`, `drop_above` and `drop_below` choose ratios after looking at them, which Mack's formulas do not allow for, so with them the standard errors are approximate and tend to be low; R's `MackChainLadder` and chainladder-python apply the formulas the same way. `history_periods=1` is refused (one ratio at every age leaves no sigma to estimate), and so are any options that leave at most one link ratio at every age. The one-year claims development result in `ibnr.kernels` needs a fit with no development options and no tail.

`zero_cells` is what a cumulative of exactly zero is. `"missing"` (the default here, as in chainladder-python) leaves out every link ratio with a zero at either end, from the factors and the sigmas alike. An origin whose latest cumulative is zero keeps 0 as its latest amount, so its ultimate is 0 and its standard errors are 0, the limit of Mack's formula as that amount goes to zero; chainladder-python leaves that origin's ultimate and standard error missing, and its total standard error equals the one here. Under `average="regression"` such an origin is refused: the variance of a step does not shrink with the amount, so it would get a mean of 0 and a positive standard error. `"observed"` keeps zeros as data, as R's `MackChainLadder` and [kernels.fit_mack](kernels.fit_mack.md#ibnr.kernels.fit_mack) (whose default it is) do: the factor uses every link ratio, and a zero latest cumulative on a still-developing origin is refused, because Mack's variance divides by it. Under `"observed"` a link ratio out of a zero has no value, so any development option on a triangle with one is refused.

`sigma_rule` picks how the variance is filled in at a development age with too few link ratios to estimate it, usually the last one: `"log_linear"` (the default, as in chainladder-python) extends a straight line through the logarithms of the other sigmas; `"mack"` is Mack's own 1993 rule, from the two ages before. The ultimates do not depend on it; the standard errors do. ([kernels.fit_mack](kernels.fit_mack.md#ibnr.kernels.fit_mack) keeps `"mack"` as its default, so published numbers made with it do not move.)

The tail options are as in [chain_ladder()](methods.chain_ladder.md#ibnr.methods.chain_ladder), and the tail is one more development step, taken by every origin, the fully developed one too (Mack 1999; R's `MackChainLadder(tail=, tail.se=, tail.sigma=)`). Its sigma and the tail factor's standard error are read off straight lines through the logarithms of the sigmas and of the factors' standard errors, at the age where a straight line through `log(factor - 1)` reaches the tail (`totals.tail_position`); the lines go through the factors above 1 and the positive values only, as R's do. `tail_sigma` and `tail_std_err` (R's `tail.sigma` and `tail.se`, zero or more) give either instead. The tail step's process variance is divided by the origin's amount at the last observed age to the power alpha, as every other step's is. Refused: a tail attached before the last observed age (no formula gives a curve factor's standard error where a link ratio's was); and, unless both `tail_sigma` and `tail_std_err` are given, a tail factor below 1, too few factors above 1 or positive sigmas to draw the lines through, and a tail larger than the line through the factors gives even at the first link, where the sigma would be read backwards past the data. chainladder-python's lines keep a left-out point's age in their sums, so its tail variance differs from this one whenever a factor is at or below 1 or a sigma is 0 (`docs/coming-from-chainladder.md` has the numbers).

`origins` and `totals` carry `mack_se` and its two parts: `parameter_se`, from estimating the factors, and `process_se`, from the randomness of future development, where `mack_se ** 2 = parameter_se ** 2 + process_se ** 2`. `development` adds `sigma`, `std_err` (the factor's standard error) and `sigma_extrapolated` (the sigma came from `sigma_rule` because the age kept fewer than two link ratios) to the chain ladder's columns, and `link_ratios` lists every observed link ratio and whether it was used, as for the chain ladder. Under `zero_cells="observed"` the standard errors need every still-developing origin's latest cumulative loss to be positive, and are refused otherwise. They also need at least one development age with two or more link ratios, since a sigma is estimated from the spread of link ratios: a triangle with at most one at every age (two origins, for example) is refused rather than given standard errors of 0. Input it will not answer is refused with [Refusal](methods.Refusal.md#ibnr.methods.Refusal), and so is a triangle whose amounts are so large that a standard error is not a finite number, or so small that its square reads as 0, and one where a factor is 0 (every origin at an age closing at zero), since every ultimate after it would be 0.
