kernels.fit_mack_grid()
Fit Mack’s distribution-free chain ladder from a grid dict (the array entry point).
Usage
kernels.fit_mack_grid(
grid,
*,
sigma_rule="mack",
zero_cells=None,
average="volume",
links=None,
tail=None
)grid is the dense one-cohort dict that kernels.cohort_grid_frame builds from a plain pandas frame (origin_period, dev_lag, value); its page lists the keys read here. It holds cumulative losses in cum (origins by development steps, NaN where unobserved), with obs_mask, latest_dev, origin_periods and dev_grain_months beside it. fit_mack() is the same fit starting from a Triangle.
The grid is checked before it is used, exactly as kernels.fit_conventional_grid checks it: the keys and arrays must agree, the measure must be "cumulative", origin periods must be the first day of their period and one development step apart, the cells must form a run-off triangle, and every still-developing origin must be observed up to the same date.
This always estimates Mack’s variance parameters as well as the factors, so it refuses some triangles the point estimate alone would not need to refuse: for example a development step with several origin pairs of which fewer than two start from a positive amount, which leaves that step’s variance with nothing to be estimated from. For a point estimate on its own, use kernels.fit_conventional_grid.
sigma_rule picks how the variance is filled in for a development step with too few pairs to estimate it directly (usually the last step):
"mack"(the default here): Mack’s 1993 rule, the smallest of the last two estimated variances and the next value their ratio points to."log_linear": extend a straight line through the logarithms of the earlier standard deviations.
chainladder-python’s MackChainladder uses the log-linear rule by default, so pass sigma_rule="log_linear" to compare standard errors with it. The factors and ultimates do not depend on this choice.
zero_cells says what a cumulative of exactly zero is:
"observed"(the default here): data. The factor at each step uses every origin observing both ends of it, zeros included, as R’sMackChainLadderdoes; sigma uses the pairs that start from a positive amount, since its residual divides by that amount."missing": chainladder-python’s rule, which stores a zero cell as missing. A link ratio is used only when neither of its two cells is zero, so the link into a zero and the link out of it both drop, from the factor, its volumes,n_obsand sigma alike. An origin whose latest cumulative is zero keeps it as its latest amount: its ultimate is 0 and its standard error is 0, the limit of Mack’s formula (chainladder-python leaves that origin’s ultimate missing instead). MackFit.zero_links counts the link ratios the rule left out. The one-year claims development result refuses a fit where this rule left anything out, because the Merz-Wuthrich formulas have not been checked under it.
On a triangle with no zero cumulative the two give the identical fit. zero_cells=None (the default) is "observed", or the rule links carries when it is given; giving both with different values is refused.
Development options (Mack 1999). average is "volume" (the default), "simple" or "regression", Mack’s alpha 1, 0 and 2: each link ratio is weighted by the amount it starts from to that power, in the factor and in sigma, and the process variance of a step is sigma^2 * C^(2 - alpha). A median or a geometric average is refused: it is not a weighted mean of the ratios, so Mack’s variance does not exist for it. links (an ibnr.kernels.links.LinkRules) chooses the link ratios with kernels.links.select_links(), the selection the conventional fits use, and the factors are kernels.links.link_factors() of it, so they equal the chain ladder’s with the same options exactly. Then s is the weight total behind each factor and n_obs and n_pos count the ratios used. The options choose which ratios estimate f and sigma; the development still to come from each origin’s latest amount keeps its full variance whatever was left out. The drops that look at the ratios (drop_high, drop_low, drop_above, drop_below) choose after seeing the data, which Mack’s formulas do not allow for, so the standard errors with them are approximate and tend to be low; R’s MackChainLadder and chainladder-python apply the formulas the same way.
With neither average nor links given, the fit is 0.7.2’s, byte for byte. With either, the development options path is taken, which:
- refuses
history_periods=1by name, and any other options that leave at most one link ratio at every age, since no sigma could be estimated; - refuses an age left with no link ratio (
no_link_ratio): a factor of 1.0 there would be chosen, not estimated, and has no variance; - refuses
zero_cells="observed"on a triangle with a link ratio out of a zero, whose ratio has no value to rank, bound or window; - fills a sigma at an age left with one link ratio: at the last age only, as above; at an earlier age, under
"log_linear"from one regression over every age with a positive sigma, and under"mack"by Mack’s rule from the two ages before, filled or estimated, in order (both as R’sMackChainLadderdoes), refusing an age before the third.
Tail (Mack 1999; R’s MackChainLadder(tail=, tail.se=, tail.sigma=)). tail (an ibnr.kernels.tail.TailSpec) adds one development step beyond the last observed age, taken by every origin, whose factor is the tail factor: a constant tail’s own, or a curve’s fitted to f (after the development options). Its sigma and standard error are read by ibnr.kernels.tail.tail_variance() off straight lines through the logarithms of the sigmas and the factors’ standard errors, at the age where the tail sits, unless TailSpec.sigma and TailSpec.std_err give them. msep_runoff then carries the tail step (see there), with the tail step’s process variance divided by the amount at the last age to the power of the fit’s alpha. Refused: a tail attached before the last observed age (not_supported: Mack’s standard errors are derived for factors estimated from link ratios, and curve factors in their place have no derived standard error), and every refusal of apply_tail and tail_variance. A tailed fit has no one-year claims development result and no simulation yet; both refuse it by name.