Stochastic BornhuetterFerguson#
import chainladder as cl
We see how to use the :class:BootstrapODPSample and :class:BornhuetterFerguson
to come up with a stochastic view of the Bornhuetter-Ferguson method. This can
be done with any deterministic IBNR method which makes bootstraping so versatile.
import chainladder as cl
# Simulation parameters
random_state = 42
n_sims = 1000
# Get data
loss = cl.load_sample('genins')
premium = loss.latest_diagonal * 0 + 8e6
# Simulate loss triangles
sim = cl.BootstrapODPSample(random_state=random_state, n_sims=n_sims)
sim.fit(loss, sample_weight=premium)
# Fit Bornhuetter-Ferguson to stochastically generated data
model = cl.BornhuetterFerguson(0.65, apriori_sigma=0.10)
model.fit(sim.resampled_triangles_, sample_weight=premium)
# Grab completed triangle replacing simulated known data with actual known data
full_triangle = (model.full_triangle_ - model.X_ + loss) / premium
# Limiting to the current year for plotting
current_year = full_triangle[full_triangle.origin==full_triangle.origin.max()].to_frame().T
/home/docs/checkouts/readthedocs.org/user_builds/chainladder-python/envs/experimental/lib/python3.11/site-packages/chainladder/adjustments/bootstrap.py:284: UserWarning: 'where' used without 'out', expect unitialized memory in output. If this is intentional, use out=None.
hat = xp.diagonal(xp.sqrt(xp.divide(1, abs(1 - hat), where=(1 - hat) != 0)))