kernels.MackFit
A fitted distribution-free chain ladder on one cohort.
Usage
kernels.MackFit(
cum,
obs_mask,
latest_dev,
f,
sigma2,
s,
n_obs,
n_pos,
origin_periods,
dev_grain_months,
sigma_rule,
units=None,
loss_field=None,
zero_cells="observed",
average="volume",
links=None,
selection=None,
tail=None,
tail_factor=1.0,
tail_sigma2=0.0,
tail_se2=0.0,
tail_position=None
)Arrays are 0-based on both axes: dev index j spans 0 .. n_d - 1 and the development step j -> j + 1 carries f[j], sigma2[j], s[j] (its volume denominator), n_obs[j] (the origins behind the FACTOR) and n_pos[j] (the origins behind the SIGMA), each of length n_d - 1. The last two differ only where a pair origin has a zero cumulative, and never under zero_cells="missing"; see the module docstring. zero_cells is the reading of a zero cumulative the fit was made with, and zero_links counts the link ratios it left out.
cum keeps the observed triangle (NaN outside it); full is the same matrix with the lower triangle filled by the chain-ladder projection, so full[:, -1] is the projection to the last observed age (the ultimate only without a tail; with one, the ultimate is ultimate) and full[i, j] for j > latest_dev[i] is the C-hat_{i,j} that Mack’s and Merz-Wuthrich’s variance formulas both evaluate at.
A fit made with development options (see fit_mack_grid()) also carries average, the links rules and the selection they made. Then s[j] is the weight total sum C^alpha over the link ratios used at step j, n_obs[j] is how many were used and n_pos[j] equals it. links and selection are None on a fit made without options, which is 0.7.2’s estimator.
A fit made with a tail (fit_mack_grid(tail=...)) carries the ~ibnr.kernels.tail.TailSpec in tail, the development beyond the last observed age in tail_factor, the tail step’s sigma squared in tail_sigma2, the tail factor’s standard error squared in tail_se2, and in tail_position where the tail sits on the link axis (None when both variances were given, or the tail factor is 1). full still ends at the last observed age; ultimate is its last column times tail_factor, and every origin, the oldest too, develops one more step. Without a tail these are None, 1.0, 0.0, 0.0 and None.
Parameter Attributes
cum: np.ndarrayobs_mask: np.ndarraylatest_dev: np.ndarrayf: np.ndarraysigma2: np.ndarrays: np.ndarrayn_obs: np.ndarrayn_pos: np.ndarrayorigin_periods: list[dt.date]dev_grain_months: intsigma_rule: strunits: str | None = Noneloss_field: str | None = Nonezero_cells: str = "observed"average: str = "volume"links: LinkRules | None = Noneselection: LinkSelection | None = Nonetail: TailSpec | None = Nonetail_factor: float = 1.0tail_sigma2: float = 0.0tail_se2: float = 0.0tail_position: float | None = None
Attributes
| Name | Description |
|---|---|
| all_history_volume | Whether this is the volume average over every link ratio the zero rule |
| alpha |
Mack’s exponent for average: 1 for volume, 0 simple, 2 regression.
|
| full | (n_w, n_d) observed triangle completed by the chain-ladder projection. |
| latest | (n_w,) each origin’s cumulative loss on the latest diagonal. |
| reserve | (n_w,) IBNR = ultimate - latest. Zero for a fully developed origin, |
| ultimate | (n_w,) projected ultimate = the completed triangle’s last column, times |
| zero_links |
How many observed link ratios zero_cells="missing" left out.
|
all_history_volume
Whether this is the volume average over every link ratio the zero rule
all_history_volume: bool
allows: no development option that can leave a ratio out. It reads the settings, not what they removed from this triangle.
alpha
Mack’s exponent for average: 1 for volume, 0 simple, 2 regression.
alpha: int
full
(n_w, n_d) observed triangle completed by the chain-ladder projection.
full: np.ndarray
latest
(n_w,) each origin’s cumulative loss on the latest diagonal.
latest: np.ndarray
reserve
(n_w,) IBNR = ultimate - latest. Zero for a fully developed origin,
reserve: np.ndarray
unless there is a tail.
ultimate
(n_w,) projected ultimate = the completed triangle’s last column, times
ultimate: np.ndarray
the tail factor when there is a tail.
zero_links
How many observed link ratios zero_cells="missing" left out.
zero_links: int
A link ratio is left out under that rule when either of its two cells is zero. Always 0 under zero_cells="observed", which leaves nothing out (a zero there is data, and only sigma skips a pair starting from it).
Methods
| Name | Description |
|---|---|
| from_arrow() | Decode a fit written by to_arrow(), refusing any other kind - |
| msep_runoff() | Mack’s conditional MSEP of the FULL run-off reserve. |
| require_positive_open_diagonals() | Every OPEN origin’s latest-diagonal cell must be strictly positive. |
| summary() | One row per origin: latest, ultimate, IBNR and the run-off standard |
| to_arrow() |
Arrow IPC bytes. Carries n_obs and n_pos separately, because
|
from_arrow()
Decode a fit written by to_arrow(), refusing any other kind -
Usage
from_arrow(data)including the MackFitPanel it may well have come out of.
msep_runoff()
Mack’s conditional MSEP of the FULL run-off reserve.
Usage
msep_runoff()Mack (1993) formula (3), per accident year i:
msep_i = C-hat_{i,J}^2 * sum_{j=k_i}^{J-1} (sigma_j^2 / f_j^2)
* (1 / C-hat_{i,j} + 1 / S_j)
where k_i = latest_dev[i] is the dev index of i’s diagonal cell and J = n_d - 1. The 1/C-hat term is process risk, the 1/S_j term estimation risk; both are returned separately because cl.MackChainladder exposes them separately and the tie-out checks each. For the aggregate, Mack’s second formula adds the estimation-risk covariance between accident years, which share the same estimated factors:
msep_total = sum_i msep_i
+ 2 * sum_{i<k} C-hat_{i,J} C-hat_{k,J}
* sum_{j=k_i}^{J-1} (sigma_j^2 / f_j^2) / S_j
(the inner sum runs over the OLDER year’s dev range, which is the intersection of the two ranges). Process risk carries no cross term: accident years are independent under Mack’s assumptions.
Returns msep / process / parameter per origin (variances, not standard errors) plus the scalars msep_total, process_total, parameter_total.
Under zero_cells="missing" an open origin whose latest cumulative is zero gets msep 0, its process and parameter parts 0, and adds nothing to the aggregate cross term. That is the limit of the formulas above as the latest amount goes to zero, since C-hat_{i,J} and every C-hat_{i,j} are that amount times a product of factors: the process part is proportional to it and the other two to its square. It is set directly because the process part’s 1 / C-hat_{i,j} would otherwise divide by the zero.
With a general alpha (average “simple” or “regression”, Mack 1999) the process term is sigma_j^2 / f_j^2 / C-hat_{i,j}^alpha, the variance sigma_j^2 C^(2 - alpha) rolled forward to ultimate, and S_j is the weight total sum C^alpha behind f_j. At alpha 1 this is the formula above, computed the same way.
With a tail (Mack 1999, and R’s MackChainLadder(tail=)) the tail is one more step with factor F = tail_factor, sigma squared tail_sigma2 and factor standard error squared tail_se2, taken by EVERY origin, the fully developed one too. C-hat_{i,J} becomes the tailed ultimate U_i, and each origin adds process U_i^2 (tail_sigma2 / F^2) / C-hat_{i,J}^alpha and parameter U_i^2 tail_se2 / F^2, with C-hat_{i,J} its projected amount at the last observed age and alpha the last link’s (the fit’s); the cross term’s shared sum gains tail_se2 / F^2 for every pair.
require_positive_open_diagonals()
Every OPEN origin’s latest-diagonal cell must be strictly positive.
Usage
require_positive_open_diagonals()The factor estimator cannot enforce this and never could. Its c0 cells are exactly the cells with an observed successor, and on a run-off staircase an open origin’s diagonal cell has none - so the diagonal is the one cell class no factor-side guard ever sees. Every variance formula downstream then divides by it: msep_runoff’s process term (ratio_j / C-hat_{i,j} starting at j = latest_dev[i]) and Merz-Wuthrich’s Phi_i = ratio_k / C_{i,k} + ....
numpy divides silently, so without this the failure is invisible: a zero diagonal returns NaN msep for that origin AND a NaN total, a negative one returns a finite NEGATIVE msep whose square root is then NaN, and simulate_ultimates returns an exactly degenerate zero column because var = sigma2 * state is non-positive and every draw comes back at its mean. Nothing raises; the numbers are just wrong.
Deliberately NOT called on the point path. The chain-ladder ultimate is a product of factors off that cell and needs no positivity at all, and the gallery’s skill benchmark (scripts/compare_gallery.py) wants the ultimate even for a cohort whose variance is undefined. fit_mack therefore still succeeds; only msep_runoff / simulate_ultimates / the CDR refuse.
A CLOSED origin (already at the last dev column) is exempt: it has no remaining step, so nothing divides by its diagonal. With a tail no origin is closed: the tail step divides by every origin’s amount at the last age.
Under zero_cells="missing" a latest cell of exactly zero is accepted too. Every term of Mack’s msep for that origin carries its latest amount as a factor, so the msep’s limit as the latest amount goes to zero is 0, and msep_runoff() returns that limit directly rather than dividing by the zero. A simulation from it is a point mass at 0, which is the same limit. A negative latest cell is still refused under either rule.
Except under average="regression" (alpha 2), whose variance sigma^2 * C^0 does not shrink with the amount: an origin at a latest amount of zero would have a mean of 0 and a positive standard error, a spread around nothing, so that is refused as not_supported.
summary()
One row per origin: latest, ultimate, IBNR and the run-off standard
Usage
summary()error, plus a total row. Mirrors cl.MackChainladder.summary_.
to_arrow()
Arrow IPC bytes. Carries n_obs and n_pos separately, because
Usage
to_arrow(*, compression=None)they are different counts and the positivity contract is the difference.