A one-year view of a small P&C insurer
This notebook uses prospicio end to end. It models three risks over the coming year, each with its own method, and then puts them together:
- Reserve risk: the one-year view of the GenIns paid triangle. This is the claims development result over the coming year, from re-reserving inside an ODP bootstrap.
- Fleet motor premium risk: a Poisson GLM for claim frequency and a gamma GLM for severity on a policy file. They go into a collective model that carries the parameter uncertainty of the GLM.
- Property per-risk: a risk profile by sum-insured band. A surplus treaty inures to a per-risk excess of loss that has a paid reinstatement, pro rata as to time.
The notebook then does these steps:
- It prices the per-risk XL from its simulated losses and places it at that price.
- It joins the three risks with a rank correlation.
- It sets and allocates capital at TVaR 99%, gross and net of reinsurance. The net view pays what the reinsurance costs.
To run it, clone the repository and install the released package with pip install prospicio matplotlib jupyter (or uv pip install). PyPI has prebuilt wheels, so you do not need a Rust toolchain. Then open this notebook from anywhere in the repository. To run it against unreleased changes, build from source instead (cd python && maturin develop, which needs Rust). Set PROSPICIO_EXAMPLE_SIMS to run fewer simulations.
import csv
import math
import os
from pathlib import Path
from prospicio.aggregate import simulate_events
from prospicio.distributions import Gamma, PredictiveDistribution, Sampled, claim_count
from prospicio.models import Glm, Terms
from prospicio.pricing import Mbbefd, RiskProfile, price
from prospicio.reinsurance import Layer, Tower
from prospicio.reserving import ChainLadder, OdpBootstrap, Triangle
from prospicio.risk import Distortion, capital, iman_conover
N_SIMS = int(os.environ.get("PROSPICIO_EXAMPLE_SIMS", "20000"))
# The repository's data folder, from wherever the notebook runs inside the repository.
DATA = next((p / "validation" / "data" for p in [Path.cwd(), *Path.cwd().parents]
if (p / "validation" / "data").is_dir()), None)
if DATA is None:
raise FileNotFoundError(
f"validation/data not found in {Path.cwd()} or above it: this notebook reads the GenIns triangle and the "
"policy file from the repository, so open it from inside a clone of the repository")
def read_csv(name):
with open(DATA / name) as f:
return list(csv.DictReader(line for line in f if not line.startswith("#")))
def one_component(label, sampled):
"""A one-line PredictiveDistribution from a component's draws."""
return PredictiveDistribution(["line"], [(label,)], [[x] for x in sampled.draws])
def money(x):
return f"{x / 1e6:,.2f}m"1. Reserve risk
GenIns is a cumulative paid triangle, ten origin years by ten ages. The insurer already holds a reserve for these years. One-year capital must cover how far that reserve can deteriorate over the coming year. That amount is the claims development result (CDR): the estimate of the ultimate now, less the estimate a year from now. This is the one-year view of Merz and Wüthrich, on which a one-year capital standard such as Solvency II measures reserve risk. Development after the year gets its reserve at the end of the year, with the capital of that year.
OdpBootstrap.one_year simulates the year by re-reserving. Each simulation does these steps:
- It resamples the scaled Pearson residuals of the triangle.
- It draws the next diagonal with process noise.
- It appends the diagonal and fits the chain ladder again.
A negative CDR is an adverse development, so the loss of the reserve line is minus the CDR. The code also prints the run-off view of the bootstrap (fit), the reserve until everything is paid. The run-off view is wider, because it holds the development of every future year and not only the next year.
tri = Triangle.read_csv(DATA / "genins.csv", "origin", "development", columns="value", comment="#")
one_year = OdpBootstrap(n_sims=N_SIMS, seed=1).one_year(tri, "value", ChainLadder())
cdr = one_year.cdr.total()
reserve = Sampled([-x for x in cdr.draws]) # adverse development is the loss
run_off = OdpBootstrap(n_sims=N_SIMS, seed=1).fit(tri, "value").reserves.total()
print(f"opening reserve {money(sum(one_year.opening_reserve))}")
print(f"one-year: adverse development mean {money(reserve.mean())}, sd {money(math.sqrt(reserve.variance()))}, "
f"99.5% {money(reserve.quantile(0.995))}")
print(f"run-off: reserve sd {money(math.sqrt(run_off.variance()))}, "
f"99.5% {money(run_off.quantile(0.995) - run_off.mean())} above its mean")opening reserve 18.68m
one-year: adverse development mean 0.10m, sd 2.41m, 99.5% 7.44m
run-off: reserve sd 3.00m, 99.5% 9.14m above its mean
3. Property per-risk
The profile has three bands of sum insured. Each band has its bounds, an expected loss and its own MBBEFD exposure curve (Swiss Re c = 2, 3, 4). Within a band, the risks spread evenly between the bounds (spread="uniform"). This puts the mean sum insured of each band at the middle of its bounds. "tilted" keeps the given sums insured as the means.
The reinsurance has two stages:
- a surplus treaty with a 2m retention line and 4 lines (8m capacity)
- inuring to it, a per-risk XL of 3m xs 1m with one paid reinstatement at 100%, pro rata as to time
Two assumptions price the surplus: the original business runs at a 60% loss ratio, and the treaty pays a 35% ceding commission. A surplus treaty takes the same share of the premium of each risk as of its losses. So its ceded premium is its exposure-rated loss over 0.6.
The code sets the premium of the XL below, from its own simulated losses. The ceded losses of the XL do not depend on its premium, and its reinstatement premium is proportional to the premium. So this first run carries a deposit premium of 1 and reports the reinstatement premium per unit of deposit. The simulated losses have uniform dates over the year. So each reinstatement charge is for the part of the year left after the loss.
profile = RiskProfile(
[0.5e6, 3e6, 15e6], [4000, 600, 60],
[Mbbefd.swiss_re(2.0), Mbbefd.swiss_re(3.0), Mbbefd.swiss_re(4.0)],
expected_losses=[2.5e6, 2.0e6, 1.5e6],
lower=[0.1e6, 1e6, 5e6], upper=[1e6, 5e6, 25e6], spread="uniform",
)
retention, lines = 2e6, 4.0
xl_limit, xl_attachment = 3e6, 1e6
original_loss_ratio, ceding_commission = 0.60, 0.35 # assumptions
xl_cost = profile.expected_layer_loss(xl_limit, xl_attachment, retention, lines)
surplus = (Layer.surplus("surplus", retention, lines)
.with_premium_rate(1.0, profile.expected_surplus_loss(retention, lines) / original_loss_ratio)
.with_ceding_commission(ceding_commission))
def per_risk_xl(premium):
return Layer("per_risk_xl", xl_limit, xl_attachment, premium=premium,
reinstatement_rates=[1.0], pro_rata_time=True)
events = profile.simulate(N_SIMS, 4).with_uniform_times()
result = Tower.inuring([[surplus], [per_risk_xl(1.0)]]).apply(events)
gross = result.marginal(("gross", "ground_up"))
net = result.marginal(("net", "retained"))
surplus_loss = result.marginal(("ceded", "surplus"))
xl_loss = result.marginal(("ceded", "per_risk_xl"))
reinstatement_rate = result.marginal(("reinstatement_premium", "per_risk_xl")).mean()
print(f"gross mean {money(gross.mean())}")
print(f"surplus cedes {money(surplus_loss.mean())} (exposure rating {money(profile.expected_surplus_loss(retention, lines))})")
print(f"per-risk XL {money(xl_loss.mean())} (exposure rating {money(xl_cost)})")
print(f"reinstatement premium {reinstatement_rate:.4f} per unit of deposit")
print(f"net mean {money(net.mean())}, 99.5% {money(net.quantile(0.995))}")gross mean 6.03m
surplus cedes 1.50m (exposure rating 1.49m)
per-risk XL 0.46m (exposure rating 0.45m)
reinstatement premium 0.0747 per unit of deposit
net mean 4.07m, 99.5% 14.26m
The simulated cessions agree with exposure rating, which checks the simulation. But the net 99.5% is high. The top band runs to 25m, past the 2m + 8m of the surplus, so its largest risks keep most of a total loss. More lines cut the net tail:
for more in [4.0, 8.0, 12.0]:
alt = Tower.inuring([[Layer.surplus("surplus", retention, more)], [per_risk_xl(1.0)]]).apply(events)
print(f"{more:4.0f} lines: net 99.5% {money(alt.marginal(('net', 'retained')).quantile(0.995))}") 4 lines: net 99.5% 14.26m
8 lines: net 99.5% 8.15m
12 lines: net 99.5% 7.70m
Pricing the XL from its simulated losses: assets at TVaR 99%, and a 10% cost of capital on the capital above the premium. That risk-loaded premium is what the reinsurer should collect in total: the deposit plus the reinstatement premiums that it expects. Those are the deposit times the rate per unit that the run above measured. So the deposit is the risk-loaded premium divided by one plus that rate. This is exact in one step, with no iteration: the price depends only on the ceded losses, and they do not depend on the premium.
The code then applies the tower again with that deposit. So the reinstatement premiums that the cedant pays follow the premium that the notebook prices. For comparison, the code prints the exposure-rated cost over a 70% loss ratio.
xl_price = price(xl_loss, Distortion.tvar(0.99), cost_of_capital=0.10)
xl = per_risk_xl(xl_price.premium / (1 + reinstatement_rate))
tower = Tower.inuring([[surplus], [xl]])
result = tower.apply(events)
reinstated = result.marginal(("reinstatement_premium", "per_risk_xl"))
print(f"risk-loaded premium {money(xl_price.premium)}, capital {money(xl_price.capital)}")
print(f"deposit {money(xl.premium)} + expected reinstatements {money(reinstated.mean())}")
print(f"(exposure-rated cost over a 70% loss ratio: {money(xl_cost / 0.7)})")risk-loaded premium 0.81m, capital 3.51m
deposit 0.75m + expected reinstatements 0.06m
(exposure-rated cost over a 70% loss ratio: 0.64m)
What the reinsurance costs. In each simulated year, the cedant pays:
- the ceded premium of the surplus, less its ceding commission
- the deposit of the XL
- the reinstatement premiums that the losses of that year trigger
The property line net of reinsurance is the retained loss plus that cost. On average, the cedant pays more than it recovers, by the margin of the reinsurers. That difference is the expected cost of the cover.
commission = result.marginal(("ceding_commission", "surplus"))
paid = [surplus.premium - c + xl.premium + r for c, r in zip(commission.draws, reinstated.draws)]
net_of_cost = Sampled([n + p for n, p in zip(net.draws, paid)])
recovered = surplus_loss.mean() + xl_loss.mean()
reinsurance_cost = net_of_cost.mean() - gross.mean()
print(f"surplus premium {money(surplus.premium)} less commission {money(commission.mean())}")
print(f"XL deposit {money(xl.premium)} and reinstatements {money(reinstated.mean())}")
print(f"paid {money(sum(paid) / len(paid))}, recovered {money(recovered)}, expected cost {money(reinsurance_cost)}")surplus premium 2.48m less commission 0.87m
XL deposit 0.75m and reinstatements 0.06m
paid 2.42m, recovered 1.96m, expected cost 0.46m
4. The company
The code joins the three lines into one PredictiveDistribution. Each line has its own simulation, so Iman-Conover reorders the draws to a rank correlation. The correlation is 0.4 between reserve and motor (shared claims inflation) and 0.1 for property. The code then allocates TVaR 99% of the losses of the year by Euler (the CoTVaR of each line). It does this gross and net of the property reinsurance, and the net view includes its cost.
Both views leave out premium income. The premiums of next year are the same gross and net, so the premium lines carry their losses. The reserve is already held, so it carries only its one-year change.
corr = [[1.0, 0.4, 0.1], [0.4, 1.0, 0.1], [0.1, 0.1, 1.0]]
def company(property_line):
parts = PredictiveDistribution.join(
[("reserve", one_component("reserve", reserve)),
("motor", one_component("motor", motor)),
("property", one_component("property", property_line))],
"risk",
).aggregate(["risk"])
return iman_conover(parts, corr, seed=5)
tvar = Distortion.tvar(0.99)
companies, allocations = {}, {}
for label, line in [("gross", gross), ("net", net_of_cost)]:
companies[label] = company(line)
allocations[label] = capital(companies[label], tvar)
print(f"{'':10s}{'gross':>10s}{'net':>10s}")
for i, key in enumerate(companies["gross"].components()):
print(f"{key[0]:10s}{money(allocations['gross'].allocated[i]):>10s}{money(allocations['net'].allocated[i]):>10s}")
print(f"{'total':10s}{money(allocations['gross'].total):>10s}{money(allocations['net'].total):>10s}")
print(f"{'diversif.':10s}{money(allocations['gross'].diversification_benefit()):>10s}"
f"{money(allocations['net'].diversification_benefit()):>10s}")
saved = allocations["gross"].total - allocations["net"].total
retained_only = capital(company(net), tvar).total
print(f"reinsurance cuts the company's TVaR by {money(saved)}, net of its cost")
print(f"it costs {money(reinsurance_cost)} a year, {reinsurance_cost / saved:.1%} of the TVaR it saves")
print(f"(leaving its cost out, the cut would read {money(allocations['gross'].total - retained_only)})") gross net
reserve 2.33m 4.62m
motor 31.35m 34.15m
property 25.65m 12.50m
total 59.33m 51.27m
diversif. 13.64m 11.36m
reinsurance cuts the company's TVaR by 8.06m, net of its cost
it costs 0.46m a year, 5.8% of the TVaR it saves
(leaving its cost out, the cut would read 10.67m)
The charts below show the distribution of the total of the company, gross and net, and the share of each line in TVaR 99%.
import matplotlib.pyplot as plt
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(11, 4))
for label in ["gross", "net"]:
ax1.hist([x / 1e6 for x in companies[label].total().draws], bins=80,
histtype="step", density=True, label=label)
ax1.set_xlabel("company loss (m)")
ax1.set_title("Year's total loss")
ax1.legend()
names = [k[0] for k in companies["gross"].components()]
x = range(len(names))
ax2.bar([i - 0.2 for i in x], [a / 1e6 for a in allocations["gross"].allocated], 0.4, label="gross")
ax2.bar([i + 0.2 for i in x], [a / 1e6 for a in allocations["net"].allocated], 0.4, label="net")
ax2.set_xticks(list(x), names)
ax2.set_ylabel("CoTVaR 99% (m)")
ax2.set_title("TVaR 99% by line")
ax2.legend()
plt.tight_layout()
plt.show()
Reading the result
- Motor dominates the tail, gross and net: it carries a whole year of claims and their uncertainty.
- The reserve’s one-year risk is small beside it. The opening reserve is already held, so only its deterioration over the year needs capital. That deterioration is narrower than the spread of the run-off view.
- Reinsurance cuts property’s CoTVaR by about half, even after its cost. The company’s TVaR falls by less than that, because property’s tail was partly diversified already.
- Reserve and motor take more of the net TVaR than of the gross. After reinsurance covers the extreme years of property, reserve and motor drive the worst years of the company.
- The reinsurance costs less than the cost of holding the capital that it frees. Here, its expected cost is about 6% of the TVaR it removes, below the 10% cost of capital in the XL price. That is about 0.46m a year against 10% of 8.06m, about 0.81m. Leaving the cost out would overstate the saving by about what the cedant pays for the cover. A fixed premium adds in full to TVaR.