Over-dispersed Poisson GLM on a triangle
odp_glm_fit.Rdodp_glm() fits the over-dispersed Poisson model as a GLM: the
incremental values of column are quasi-Poisson with a log link, an
origin factor and a development factor. Its fitted future cells
reproduce the chain-ladder reserves, and the dispersion is Pearson's
chi-squared over the residual degrees of freedom. The triangle must
have a single segment.
Usage
odp_glm_fit(ptr)
odp_glm(
triangle,
column = NULL,
formula = NULL,
tolerance = 1e-10,
max_iterations = 100,
family = "poisson",
power = NULL
)Arguments
- triangle
A single-segment triangle of cumulative values.
- column
The column to fit, by default the triangle's only one.
- formula
NULLfor the cross-classified model (an origin and a development factor), or a one-sided formula on the cells.- tolerance
Convergence tolerance of the IRLS fit.
- max_iterations
Most IRLS iterations.
- family
The error:
"poisson"(the ODP),"gamma"or"tweedie".- power
The Tweedie power, in (1, 2); only for
family = "tweedie".
Details
family = "gamma" swaps the error for a gamma, variance phi * mu^2,
and family = "tweedie" for a Tweedie, variance phi * mu^power with
1 < power < 2 (Taylor and McGuire, section 6.5), each with the log link
and Pearson's dispersion as stats::glm() with Gamma(link = "log") or
statmod's tweedie(var.power = power, link.power = 0). Their reserves are
no longer the chain ladder's. The gamma needs every observed increment
positive, the Tweedie every one at least 0.
formula fits another design on the triangle's cells instead, the
columns of odp_glm_cells() (origin, development and calendar as
labels, origin_index, development_index and calendar_index from 0,
age): fewer parameters, calendar trends, interactions (Taylor and
McGuire, CAS Monograph 3, Chapter 7). It is a one-sided formula run
through stats::model.matrix(), so it has an intercept unless it says
- 1, and offset() terms are honoured. A numeric term extrapolates to
the future cells; a factor level that only future cells take (of
calendar, say) cannot be estimated, nor can a column that is zero on
every observed cell.
prediction_error gives the reserves' analytic prediction error by the
delta method, by origin and in total: the process variance
phi * sum(V(mu)) (V(mu) = mu for the ODP, mu^2 for the gamma,
mu^power for the Tweedie) and the parameter variance g' Sigma g with g = sum(mu * x) over each
origin's future cells. It reproduces Taylor and McGuire's (CAS Monograph
3) Table 5-4 (validation/tests/reserving.rs).
The fit's properties are origins, reserves (named by origin),
total_reserve, dispersion, coefficients and std_errors (named by
parameter), covariance (their covariance matrix), future (a data frame
of the future cells' origin, development, fitted mean and
predictive_mean, the mean of draws whose coefficients are drawn
normally) and prediction_error (a data frame with a row per origin and
a Total row: reserve, process_se, parameter_se, rmsep and cv,
NA for a zero reserve). predict_distribution() draws the future cells
jointly (no newdata).
residuals is a data frame with a row per observed cell, origin-major:
origin, development (age in months), calendar (the calendar
period's label), calendar_index (0 for the earliest valuation),
actual, fitted, actual_to_fitted (the cell of the actual-to-fitted
heat map), pearson, deviance, leverage (the hat value),
standardized_deviance (as stats::rstandard()) and
standardized_pearson. A cell with leverage 1, the only observation of
its origin or age, is fitted exactly and has no standardized residual
(NA). residual_summary() groups the standardized deviance residuals
by origin, development or calendar period (Taylor and McGuire, Chapter
6).
Examples
long <- data.frame(year = c(2020, 2020, 2020, 2021, 2021, 2022),
age = c(12, 24, 36, 12, 24, 12),
paid = c(100, 150, 165, 110, 170, 120))
fit <- odp_glm(triangle(long, "year", "age", "paid"))
fit@total_reserve
#> [1] 98.14286
fit@prediction_error
#> origin reserve process_se parameter_se rmsep cv
#> 1 2020 0.00000 0.000000 0.000000 0.000000 NA
#> 2 2021 17.00000 1.519474 1.763289 2.327657 0.13692103
#> 3 2022 81.14286 3.319663 4.447048 5.549451 0.06839112
#> 4 Total 98.14286 3.650886 5.392348 6.512018 0.06635244
pd <- predict_distribution(fit, n_sims = 1000, seed = 1)
mean(total(pd))
#> [1] 98.03555
# The origins' effect a straight line in their index, an effect per age.
line <- odp_glm(triangle(long, "year", "age", "paid"),
formula = ~ origin_index + factor(development))
line@coefficients
#> (Intercept) origin_index factor(development)24
#> 4.5958985 0.1011728 -0.6404307
#> factor(development)36
#> -1.8878483
# A gamma error: every cell's relative error weighs alike.
odp_glm(triangle(long, "year", "age", "paid"), family = "gamma")@total_reserve
#> [1] 98.29313