BootstrapODPSample#
- class chainladder.BootstrapODPSample(n_sims=1000, n_periods=-1, hat_adj=True, drop=None, drop_high=None, drop_low=None, drop_valuation=None, random_state=None)[source]#
Class to generate bootstrap samples of triangles. Currently this Only supports ‘single’ triangles (single index and single column).
- Parameters:
- n_sims: int (default=1000)
Number of simulations to generate
- n_periods: integer, optional (default=-1)
number of origin periods to be used in the ldf average calculation. For all origin periods, set n_periods=-1
- hat_adj: bool (default=False)
Adjust standardized Pearson residuals with the hat matrix adjustment factor. If false, Degree of Freedom adjustment is used.
- drop: tuple or list of tuples
Drops specific origin/development combination(s) from residual sample
- drop_high: bool or list of bool (default=None)
Drops highest link ratio(s) from residual sample
- drop_low: bool or list of bool (default=None)
Drops lowest link ratio(s) from residual sample
- drop_valuation: str or list of str (default=None)
Drops specific valuation periods from residual sample. str must be date convertible.
- random_state: int, RandomState instance or None, optional (default=None)
If int, random_state is the seed used by the random number generator; If RandomState instance, random_state is the random number generator; If None, the random number generator is the RandomState instance used by np.random.
- Attributes:
- resampled_triangles_: Triangle
A set of triangles represented by each simulation
- scale_:
The scale parameter to be used in generating process risk
See also
MackChainladderEstimates prediction error for chainladder reserves.
Examples
Generate ODP bootstrap samples of the RAA sample triangle. The estimator re-samples standardized Pearson residuals to produce
n_simssynthetic triangles stacked along the index axis ofresampled_triangles_, and exposes the scale parameterscale_used to generate process risk.random_stateand a smalln_simskeep the output deterministic and fast.raa = cl.load_sample('raa') boot = cl.BootstrapODPSample(n_sims=100, random_state=42).fit(raa) print(boot.resampled_triangles_.shape) print(round(float(boot.scale_), 2))
(100, 1, 10, 10) 983.64
Because
resampled_triangles_is itself a Triangle (with the simulation index along the first axis), it can be fed straight into any downstream reserving estimator to obtain a stochastic distribution of ultimates and IBNR. Below, a deterministic chain-ladder is fit on the resampled triangle and the total IBNR is summarised across the 100 simulations.sims = cl.BootstrapODPSample( n_sims=100, random_state=42 ).fit_transform(raa) ibnr = cl.Chainladder().fit(sims).ibnr_.sum('origin') print(ibnr.shape) print(round(float(ibnr.mean()), 2)) print(round(float(ibnr.std()), 2))
(100, 1, 1, 1) 51301.13 16149.47
The estimator also supports a leave-one-out sensitivity check on the residual distribution. Setting
drop_high=Trueexcludes the highest link ratio in each development column before computing residuals, without making any outlier judgement, so the resultingscale_measures how influential the column maxima are on the bootstrap. For the RAA triangle this shrinksscale_from 983.64 to 648.94.boot_dh = cl.BootstrapODPSample( n_sims=100, random_state=42, drop_high=True ).fit(raa) print(round(float(boot_dh.scale_), 2))
648.94
Two further levers control how the residual pool is built.
n_periodsrestricts the internalDevelopmentfit to the most recent origin periods, which changes the Pearson residuals and thereforescale_, whilehat_adjswaps the hat matrix adjustment for the simpler degree-of-freedom adjustment when standardizing residuals before resampling.short_hist = cl.BootstrapODPSample( n_sims=100, random_state=42, n_periods=3 ).fit(raa) dof = cl.BootstrapODPSample( n_sims=100, random_state=42, hat_adj=False ).fit(raa) print(round(float(short_hist.scale_), 2)) print(round(float(dof.scale_), 2))
322.4 983.64
Inherited Methods
|
Fit to data, then transform it. |
|
Get metadata routing of this object. |
|
Get parameters for this estimator. |
|
Apply |
|
Converts triangle array_backend. |
|
Set output container. |
|
Set the parameters of this estimator. |
|
Serializes triangle object to json format |
|
Serializes triangle object to pickle. |