The age-period-cohort reserving GLM
apc_glm_fit.RdFits log mu_ij = delta + alpha_i + beta_j + gamma_(i+j) to the
increments of a full triangle: accident (cohort), development (age) and
calendar (period) effects, with an over-dispersed Poisson error or the
gamma and Tweedie errors of odp_glm() (issue #979, design note
docs/design/reserving-inflation.md). Python's ApcGlm.
Usage
apc_glm_fit(
effects,
extrapolation,
origins,
ages,
level,
age_slope,
accident_slope,
age_second_differences,
accident_second_differences,
calendar_second_differences,
future_calendar_second_differences,
fitted,
deviance,
reserves,
future,
odp_fit
)
apc_glm(
triangle,
column = NULL,
effects = "APC",
extrapolation = "I0",
family = "poisson",
power = NULL,
tolerance = 1e-10,
max_iterations = 100
)Arguments
- effects
"APC"(the default),"AP","AC"or"PC".- extrapolation
"I0"(the default),"I1"or"I2".- origins, ages, level, age_slope, accident_slope, age_second_differences, accident_second_differences, calendar_second_differences, future_calendar_second_differences, fitted, deviance, reserves, future, odp_fit
The fields of an
apc_glm_fit, as described under Value. A fit is made byapc_glm(); theapc_glm_fit()constructor only holds its fields.- triangle
A single-segment
triangle().- column
The column to fit;
NULLfor the triangle's only one.- family
The error:
"poisson"(the default),"gamma"or"tweedie".- power
The Tweedie power, in (1, 2); only for
family = "tweedie".- tolerance
Convergence tolerance of the IRLS fit.
- max_iterations
Most IRLS iterations.
Value
An apc_glm_fit with the properties effects and
extrapolation (in upper case), origins, ages (months), level,
age_slope, accident_slope, age_second_differences,
accident_second_differences and calendar_second_differences (at
l = 2, ..., k - 1; empty for an effect the model drops),
future_calendar_second_differences (the two extrapolated ones at
l = k and k + 1, all later ones 0; zeros for "I2" and without a
calendar effect), fitted (a matrix of the fitted means, origins by
ages, NA on the future cells), deviance, reserves (the sum of
each origin's future means; the first origin's is 0, with no tail past
the oldest age), total_reserve, coefficients (the canonical
parameters, named level, slope_age, slope_accident, then
dd_age[l], dd_accident[l] and dd_calendar[l]), covariance
(their covariance matrix), dispersion (Pearson's), future (the
future cells as future_cells()), odp_fit (the odp_glm_fit on the
canonical design) and prediction_error (odp_fit's: a data frame
with a row per origin and a Total row).
Details
The calendar index is the sum of the accident and development indices,
so the three effects are identified only up to linear trends. The model
is fitted in the canonical parameterisation of Kuang, Nielsen and
Nielsen (2008a), as Python and R apc fit it: a level (the log mean of
the first origin's first age), an age_slope and an accident_slope
(the steps from age 0 to age 1 and from accident 0 to accident 1), then
the second differences of each effect at l = 2, ..., k - 1 on a k by
k triangle. Fitted values and the deviance do not depend on the
identification.
The future cells need the calendar effect past the latest diagonal.
extrapolation chooses how its second differences continue, by rules
that do not depend on the identification (Kuang, Nielsen and Nielsen
2008b; R apc's apc.forecast.apc):
"I2": the future second differences are 0, so the last linear trend of the calendar effect continues."I1": the next first difference of the calendar effect is the mean of the fitted ones (the first left out, as Rapcdoes), then the second differences are 0."I0"(the default, Rapc's): the future calendar effects lie on the least-squares line through the effects of the periods from the third on. It needs at least 4 origins; the other rules need 3.
effects drops one effect's second differences: "AP" (development and
calendar, Taylor's separation model as a GLM), "AC" (accident and
development, the chain ladder, with no calendar effect to extrapolate)
or "PC" (accident and calendar). The names are as Python and R apc
give them, in either case.
The triangle must be full: as many ages as origins, the origin grain
equal to the development grain, no hole. The fit is an ODP GLM on the
canonical design, odp_fit: its prediction_error (by the delta
method), predict_distribution() and residuals cover the extrapolated
calendar effect as a function of the fitted parameters.
Examples
# A 5 by 5 triangle of increments with a 5% calendar trend and noise.
shape <- c(0.5, 0.25, 0.12, 0.08, 0.05)
noise <- c(1.04, 0.97, 1.01, 0.95, 1.03)
long <- do.call(rbind, lapply(0:4, function(i) {
j <- 0:(4 - i)
data.frame(year = 2001 + i, age = 12 * (j + 1),
paid = 1000 * 1.05^(i + j) * shape[j + 1] * noise[(i + 2 * j) %% 5 + 1])
}))
tri <- triangle(long, "year", "age", "paid", cumulative = FALSE)
fit <- apc_glm(tri, extrapolation = "I1")
fit@reserves
#> 2001 2002 2003 2004 2005
#> 0.00000 59.66546 170.30000 329.97708 702.46477
fit@calendar_second_differences
#> [1] 0.045783658 0.003147433 0.023736957
fit@prediction_error
#> origin reserve process_se parameter_se rmsep cv
#> 1 2001 0.00000 0.000000 0.000000 0.00000 NA
#> 2 2002 59.66546 6.605516 7.350038 9.88210 0.16562513
#> 3 2003 170.30000 11.159701 12.766105 16.95619 0.09956658
#> 4 2004 329.97708 15.534136 20.490357 25.71311 0.07792393
#> 5 2005 702.46477 22.665092 35.312436 41.96039 0.05973309
#> 6 Total 1262.40732 30.384001 60.180541 67.41576 0.05340254
# The chain ladder as the accident and development model.
apc_glm(tri, effects = "AC")@total_reserve
#> [1] 1231.613