Skip to main content

methods.tweedie_glm()

A Tweedie GLM fitted to the triangle’s increments, and each origin’s ultimate.

Usage

Source

methods.tweedie_glm(
    cells,
    *,
    power=1.0,
    link="log",
    origin="factor",
    calendar="none",
    projection="pattern",
    dev_grain_months=12,
    max_iter=100,
    tail=None
)

cells is as in chain_ladder(): CUMULATIVE losses, one row per observed cell, zero or more. The function takes the increments of those cumulatives and fits, by iteratively reweighted least squares, a GLM in which each increment has mean mu and variance dispersion * mu ** power:

  • power: 0 is the normal distribution, 1 the over-dispersed Poisson (the default), between 1 and 2 the compound Poisson-gamma, 2 the gamma, and above 2 the other Tweedie distributions. No Tweedie distribution has a power between 0 and 1, and those powers are refused. At power 1 and above every increment must be zero or more, and at power 2 and above more than zero; power 0 accepts negative increments, but under the log link, which keeps every fitted increment above zero, an age or origin whose increments sum to zero or less can leave no finite fit (the refusal names it; link="identity" fits it).
  • link: "log" (the default), log(mu) is the sum of the terms, or "identity", mu is.
  • origin: "factor" (the default) gives each origin its own level; "none" gives every origin the same expected increments.
  • calendar: "none" (the default) or "trend", a straight line in the calendar period on the link scale. Only with origin="none": beside origin and development factors a calendar trend cannot be estimated, because the calendar period is the origin index plus the development index. Under the log link a calendar trend with development factors fits the same means as a straight line across origins, so it is not an inflation estimate.
  • projection: "pattern" (the default) takes each origin’s latest cumulative times its fitted development from the latest age to the last, as chainladder-python’s TweedieGLM with Chainladder does; "increments" adds the fitted future increments to the latest cumulative, as R’s glmReserve does. The two agree at power 1 with a log link and origin factors. "increments" needs origin factors.
  • max_iter: the most iterations (100 by default). A fit that has not settled by then is refused, never returned. The fit stops when no fitted increment moves by more than 1e-10 times the largest increment, a rule that does not depend on the units, and there is no penalty, so the answer scales exactly with the amounts.
  • dev_grain_months: as in chain_ladder().
  • tail: not supported yet; anything but None is refused. Each origin is projected to the last observed development age.

Power 1 with a log link and origin and development factors (the defaults) is the over-dispersed Poisson model, whose ultimates equal the volume-weighted chain ladder’s, chain_ladder(cells, zero_cells="observed"), by either projection. The exception is an origin whose losses start from zero (a cumulative of 0 followed by a positive one): the chain ladder keeps it at 0 times its factors, and the GLM gives it a level from its later cells. Under the log link an origin (with origin factors) or a development age whose observed increments are all zero is fitted at exactly zero, the limit of the fit: its coefficient is null in coefficients with fitted_zero true, the zero origin’s ultimate is 0 and the factor into a zero age is 1. Where the losses leave the fit with no finite answer (an origin whose only losses sit where the model needs a positive level from cells that are all zero), it is refused as degenerate_fit.

Unlike chainladder-python’s TweedieGLM, there is no penalty and no alpha: chainladder always applies scikit-learn’s ridge penalty of 1.0, whatever alpha it is given, so its answers depend on the units of the amounts. docs/coming-from-chainladder.md lists the differences.

Returns a ReserveResult whose link_ratios is None:

  • origins: origin, origin_period, latest_dev_lag, latest, ultimate and ibnr (by the chosen projection) and model_ibnr (float64, the sum of the fitted future increments, which is ibnr under projection="increments").
  • development: dev_lag, factor, cdf and pct_reported, the one fitted pattern every origin shares under the log link; null under the identity link, whose pattern differs by origin (it is in cells), and null where the fitted cumulative is 0 (a first age with no losses). n_observed (int64) counts the observed increments at the age.
  • cells: one row per cell of the full rectangle, observed or not: origin, origin_period, dev_lag, observed (bool), increment (null when not observed), fitted_increment, fitted_cumulative, factor (the origin’s fitted factor to the next age; null at the last age or where the fitted cumulative is 0), cdf (to the last age; null where the fitted cumulative is 0) and pearson_residual ((increment - fitted) / sqrt(fitted ** power), not divided by the dispersion; null when not observed or the fitted increment is 0).
  • coefficients: one row per term, with the first origin and the first age with losses as the reference levels, as in R’s glm: term (intercept, origin, development or calendar), origin and origin_period (null unless an origin term), dev_lag (int64, null unless a development term), estimate (on the link scale) and std_error (null when fitted_zero or when the dispersion is undefined), and fitted_zero (bool).
  • totals: latest, ultimate, ibnr, model_ibnr, power, link (string), deviance, pearson_chi2, dispersion (pearson_chi2 / (n_observed - n_parameters), null when they are equal), n_observed, n_parameters and iterations (int64). n_observed and n_parameters count only the cells and terms in the regression, not those fitted at zero.

Refused, besides the refusals of chain_ladder()’s cells: a negative increment at power 1 or above (negative_increment), a zero increment at power 2 or above (zero_increment), no losses at all or more terms than the cells can tell apart (not_identified), a fit that did not settle (did_not_converge), a fit with no finite answer (degenerate_fit, including a fitted mean that falls below 1e-8 of the largest increment on a cell whose increment is zero or less), an identity-link fitted increment of zero or less at a power above 0, or one that falls to 1e-8 of the largest increment where the increment is 0 (negative_fitted_mean), and an ultimate below zero (negative_projection). Whether a triangle is refused does not depend on its units.