Repository navigation
Description
After Chainladder().fit() on a BootstrapODPSample triangle, full_triangle_ does not hold the path the fit simulated. MethodBase._include_process_variance adds gamma noise to each future cell and moves ultimate_ to the noisy last column. full_triangle_ then rebuilds every future cell from that ultimate with _get_full_triangle, which spreads ultimate_ - latest along the expected development pattern. The ultimates agree, but the cell-level noise is gone.
Shapland and Leong (2010), "Bootstrap Modeling: Beyond the Basics", CAS E-Forum Fall 2010, add process variance to each future incremental value (section 3) and report the cash flow distribution by calendar year (section 6.2, Figure 6.4). A calendar-year runoff built from full_triangle_, as in the plot_ibnr_runoff gallery, understates that spread.
import numpy as np
import chainladder as cl
tri = cl.load_sample("genins")
sims = cl.BootstrapODPSample(n_sims=200, random_state=42).fit_transform(tri)
model = cl.Chainladder().fit(sims)
# The path fit simulated: the expected completion of each resampled history plus process_variance_
no_noise = sims.copy()
del no_noise._get_process_variance
path = cl.Chainladder().fit(no_noise).full_triangle_ + model.process_variance_
def calendar_2011(full):
runoff = (full.cum_to_incr() - sims.cum_to_incr()).dev_to_val()
col = [str(v)[:4] for v in runoff.development].index("2011")
return np.nansum(runoff.values[:, 0, :, col], axis=1)
print("ultimates match:", np.allclose(path.values[..., -1], model.full_triangle_.values[..., -1]))
print("origin 2010, sim 0, ages 24-60, path: ", np.round(path.values[0, 0, -1, 1:5]).tolist())
print("origin 2010, sim 0, ages 24-60, full_triangle_:", np.round(model.full_triangle_.values[0, 0, -1, 1:5]).tolist())
print("sd of calendar 2011 paid, path: ", round(float(calendar_2011(path).std())))
print("sd of calendar 2011 paid, full_triangle_:", round(float(calendar_2011(model.full_triangle_).std())))On main cc3335c this prints
ultimates match: True
origin 2010, sim 0, ages 24-60, path: [1231064.0, 2056950.0, 2844350.0, 3147112.0]
origin 2010, sim 0, ages 24-60, full_triangle_: [1117686.0, 1915630.0, 2824323.0, 3328947.0]
sd of calendar 2011 paid, path: 721256
sd of calendar 2011 paid, full_triangle_: 593207
None of the interior future cells match in any of the 200 draws. process_variance_ holds the noise, but it has no docstring and the noise is measured against the completion before ultimate_ moved, so full_triangle_ + process_variance_ is not the path either.
Two options I can see.
- Keep the simulated path on the fitted model, for example as a
full_triangle_that returns it when process variance was drawn, or as a separate attribute. - Leave the behaviour and document it. Add a docstring for
process_variance_and a note onfull_triangle_that says it is not the simulated path after a bootstrap fit.
Which do you prefer? Related: #1639 and #1652 (process variance in predict) and #1664 (comparing methods on the same draws).
(This issue was written with Árbol, an AI assistant, under my direction.)
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Scope
Effort
Projects
- StatusShow more project fieldsNot Ready
Activity