A development curve fitted over every age
development_curve_fit.RdFits a curve to a triangle's estimated age-to-age factors over every age
(issue #556; design note docs/design/reserving-v02.md, decision 31), to
smooth the whole pattern: the observed factors are kept before
keep_observed_until and the curve's are used from there on. The
parameters match R's lm() and nls()
(validation/tests/reserving_curves.rs).
Usage
development_curve_fit(ptr)
development_curve(
triangle,
column = NULL,
shape = curve_shapes,
fit_period = NULL,
keep_observed_until = NULL,
average = "volume",
n_periods = NULL,
drop_high = 0,
drop_low = 0
)
development_curve_selected(fit)
development_curve_tail(fit, extrap_periods = 100)
development_curve_compare(
triangle,
column = NULL,
shapes = curve_shapes,
fit_period = NULL,
keep_observed_until = NULL,
average = "volume",
n_periods = NULL,
drop_high = 0,
drop_low = 0
)Arguments
- ptr
A
DevelopmentCurveFitpointer; used internally.- triangle
A
triangle()with one segment.- column
The column to fit; may be omitted when the triangle has one.
- shape
The curve:
"exponential","inverse_power","hoerl","sherman","loglogistic"or"weibull".- fit_period
The ages in months whose factors enter the fit, from the last age at or before the first (inclusive) to the last age at or before the second (exclusive), as
tail_curve()reads them;NAfor an open end,NULLfits every factor.- keep_observed_until
The observed factors are kept before this age in months and the curve is used from the first age at or after it on;
NULLuses the curve at every age.- average, n_periods, drop_high, drop_low
How the link ratios are averaged into the factors the curve is fitted to, as in
chain_ladder().- fit
A
development_curve_fit.- extrap_periods
Number of periods past the oldest age the curve is extrapolated, as in
tail_curve().- shapes
The shapes to compare; every shape by default.
Value
development_curve(): a development_curve_fit.
development_curve_selected(): a list of ldf, ldf_kind and
ldf_weight. development_curve_tail(): a number.
development_curve_compare(): a data.frame of shape, n_points,
n_parameters, sum_of_squares, r_squared and
adjusted_r_squared.
Details
k is the 1-based development index (1 for the factor from the youngest
age to the next), as tail_curve() reads it:
"exponential":log(f_k - 1) = a + b k;"inverse_power":log(f_k - 1) = a + b log(k);"hoerl":log(f_k - 1) = a + b k + c log(k);"sherman":f_k - 1 = a (k + c)^(-b)(Sherman 1984);"loglogistic","weibull": Clark's growth curveGas percents developed at the agestin months,f_k = G(t_(k+1)) / G(t_k).
The first three are least-squares lines on log(f - 1), the others
nonlinear least squares on the factors. Every shape is fitted to the
estimated factors in fit_period above 1.00001; the residuals, the sum
of squares and R-squared are on the factor scale, so that
development_curve_compare() gives one table.
development_curve()fits the curve. The properties of adevelopment_curve_fitareshape,fit_period,keep_observed_until,parameters(nameda,b,coromega,theta),development(the ages), by the age that starts each factorobserved(the estimated factors),fitted,residuals(observed - fitted),in_fitandldf(observedbeforeattachment, the first position the curve replaces, 0-based, andfittedfrom it on), andn_points,n_parameters,sum_of_squares,r_squaredandadjusted_r_squared.development_curve_selected()gives the fitted factors as theldf,ldf_kindandldf_weightarguments ofchain_ladder(),mack()and the expected-loss methods, anddevelopment_curve_tail()the curve's development past the oldest age for theirtail:do.call(chain_ladder, c(list(tri, tail = development_curve_tail(fit)), development_curve_selected(fit))). A selected factor carries no parameter error, so the curve lowers Mack's standard errors.development_curve_compare()fits several shapes to the same factors: a data.frame with one row per shape.
These are Python's DevelopmentCurve and DevelopmentCurveFit.
Examples
long <- data.frame(year = rep(2020:2024, 5:1),
age = c(12, 24, 36, 48, 60, 12, 24, 36, 48, 12, 24, 36, 12, 24, 12),
paid = c(100, 180, 215, 228, 233, 110, 196, 236, 249, 120, 218, 259,
130, 232, 140))
tri <- triangle(long, "year", "age", "paid")
fit <- development_curve(tri, shape = "inverse_power")
fit@parameters
#> a b
#> -0.09580297 -2.56507579
fit@r_squared
#> [1] 0.9625818
cl <- do.call(chain_ladder, c(list(tri, tail = development_curve_tail(fit)),
development_curve_selected(fit)))
cl@ultimate
#> 2020 2021 2022 2023 2024
#> 245.9551 269.6644 295.7160 305.5601 351.9342
development_curve_compare(tri, shapes = c("exponential", "inverse_power"))
#> shape n_points n_parameters sum_of_squares r_squared
#> 1 exponential 4 2 0.006888531 0.9822690
#> 2 inverse_power 4 2 0.014537036 0.9625818
#> adjusted_r_squared
#> 1 0.9734034
#> 2 0.9438726