Use this guide when
You need more than one year: the surplus of a company over a five-year plan, the probability that it is ruined or breaches its capital requirement within the plan, and how much of that comes from the economy (interest rates and inflation) rather than from the losses. That is dynamic financial analysis (DFA): an economic scenario generator (ESG) simulates the economy, and a projection runs the company’s premium, losses, reserves, assets, tax and capital rules along each economic path.
Terms:
- Short rate: the instantaneous interest rate that a one-factor model simulates (Vasicek, Cox-Ingersoll-Ross or Hull-White); bond prices and the yield curve follow from it.
- Economic inflation and superimposed inflation: the general price index, and the extra growth of claims costs above it (legal, medical). The claims index carries both.
- Ruin: the surplus before any capital injection falls below zero at a year end. Breach: it falls below a required capital.
- Underwriting cycle: the rate adequacy of the premium moving in waves, an AR(2) on its logarithm.
The design note is docs/design/esg-dfa.md; the models’ formulas are in the Rust reference of prospicio-esg and prospicio_aggregate::dfa.
1. The economy
Esg puts a short-rate model, economic inflation (an Ornstein-Uhlenbeck rate) and superimposed inflation (an AR(1)) together, with the correlation of their shocks. Annual steps suffice for a five-year plan; monthly steps are the default.
import numpy as np
from prospicio.esg import Esg, Inflation, Superimposed, Vasicek
esg = Esg(
Vasicek(0.25, 0.035, 0.012, 0.03), # speed, long-run rate, volatility, rate today
inflation=Inflation(0.4, 0.025, 0.01, 0.03),
superimposed=Superimposed(0.01, 0.5, 0.01), # mean, persistence, volatility
correlation=[[1.0, 0.5, 0.2], [0.5, 1.0, 0.3], [0.2, 0.3, 1.0]],
step="annual",
)
SIMS, YEARS = 2_000, 5
scenarios = esg.simulate(YEARS, SIMS, seed=1)
rates = scenarios.short_rates()
claims_index = scenarios.index_levels("claims")
print("shape", rates.shape)
print("mean short rate by year end ", np.round(rates.mean(axis=0), 4))
print("mean claims index by year end", np.round(claims_index.mean(axis=0), 3))
print(f"claims index at year 5: 5% {np.quantile(claims_index[:, -1], 0.05):.3f}, "
f"95% {np.quantile(claims_index[:, -1], 0.95):.3f}")
shape (2000, 6)
mean short rate by year end [0.03 0.0307 0.0316 0.0321 0.0326 0.0331]
mean claims index by year end [1. 1.04 1.079 1.12 1.161 1.204]
claims index at year 5: 5% 1.091, 95% 1.320
Each matrix has one row per path and one column per step from today. Path s draws from its own stream, so it is the same whatever the number of paths or threads. scenarios.curve(s, j) and bond_prices(j) give the yield curve and bond prices on a path, and deflators() the stochastic discount factors.
2. A company along the paths
Projection takes the new losses of each year in today’s money (one row per path), the opening assets, and the plan: premiums, the expense ratio, the opening reserves’ run-off, the payout pattern of new losses, the assets’ bond buckets (share and duration, the rest in cash) and tax. Along each economic path the losses are scaled by the claims index, the reserves by the same index as they are paid, and the assets earn the path’s rates.
from prospicio.distributions import Lognormal
from prospicio.esg import Projection
losses = np.array(Lognormal.from_mean_cv(650.0, 0.25).sample(SIMS * YEARS, seed=2)).reshape(SIMS, YEARS)
plan = dict(
premiums=[1_000.0] * YEARS,
expense_ratio=0.3,
opening_reserves=[400.0, 250.0, 150.0, 100.0, 50.0],
payout=[0.4, 0.3, 0.2, 0.1],
bonds=[(0.6, 5.0)],
tax_rate=0.21,
)
paths = Projection(losses, 2_000.0, **plan).run(scenarios)
surplus = paths.values("surplus")
print(f"opening surplus {paths.opening_surplus:.0f}")
print("mean surplus by year end", np.round(surplus.mean(axis=0)))
print(f"1% of the year-5 surplus {np.quantile(surplus[:, -1], 0.01):.0f}")
print("lines:", ", ".join(paths.lines()))
opening surplus 1050
mean surplus by year end [1093. 1116. 1121. 1110. 1079.]
1% of the year-5 surplus -111
lines: premium, expenses, incurred_losses, reserve_development, investment_income, result, paid, assets, reserves, surplus, tax, dividends, injections, surplus_before_capital
The losses are 65% of premium in today’s money, but the claims index grows about 4% a year, so the margin shrinks year by year and the mean surplus turns down after year 3. values(line) gives any line of the projection by path and year.
3. Ruin and capital breach
ruin(horizon) is the share of paths whose surplus before capital falls below zero at some year end within the horizon, with its binomial standard error. breach(horizon, capital) tests a required capital: an amount, a list by year, or a ratio to premium or to reserves.
def show(label, p):
r, b = p.ruin(5), p.breach(5, ("premium", 0.6))
print(f"{label:12} ruin {r['probability']:.4f} (se {r['standard_error']:.4f}), "
f"breach of 60% of premium {b['probability']:.4f}, mean shortfall {b['shortfall']:.0f}")
show("independent", paths)
independent ruin 0.0150 (se 0.0027), breach of 60% of premium 0.1615, mean shortfall 144
4. Losses that move with the economy
The claims index already moves the losses’ level with the economy. A bad year for inflation is often a bad year for losses beyond that (the same courts, the same supply shortages), which dependence adds: a copula on the ranks of each year’s losses and the path’s index growth. A Gumbel copula puts the dependence in the upper tail, which is where it hurts.
dependent = Projection(losses, 2_000.0, **plan, dependence="gumbel", dependence_parameter=1.5,
dependence_seed=3).run(scenarios)
show("gumbel 1.5", dependent)
print(f"1% of the year-5 surplus {np.quantile(dependent.values('surplus')[:, -1], 0.01):.0f}")
gumbel 1.5 ruin 0.0695 (se 0.0057), breach of 60% of premium 0.2205, mean shortfall 190
1% of the year-5 surplus -759
The losses’ distribution in each year is unchanged; only which path gets which loss moves. The mean surplus hardly changes, but the ruin probability is several times higher and the 1% surplus far lower: the high losses now fall on the paths where the index grew fastest. "gaussian", "t" (with dependence_nu), "clayton", "frank" and "joe" are the other families.
5. The underwriting cycle and capital rules
A Cycle scales each year’s premium by an AR(2) rate adequacy; its period is cycle.period() years. Capital rules pay dividends above a ratio of premium (or reserves) and inject capital up to a floor.
from prospicio.esg import Cycle
cycle = Cycle(0.0, 1.2, -0.6, 0.05, 0.0) # mean, phi1, phi2, volatility, start
print(f"cycle period {cycle.period():.1f} years")
cyclical = Projection(losses, 2_000.0, **plan, cycle=cycle, cycle_seed=4).run(scenarios)
print("premium standard deviation by year", np.round(cyclical.values("premium").std(axis=0), 1))
show("cycle", cyclical)
managed = Projection(losses, 2_000.0, **plan, dividend_above=1.8, inject_below=0.8).run(scenarios)
print("mean injections by year", np.round(managed.values("injections").mean(axis=0), 1))
print(f"ruin with injections up to 80% of premium {managed.ruin(5)['probability']:.4f}")
cycle period 9.2 years
premium standard deviation by year [48.2 79.5 92.3 92.5 91. ]
cycle ruin 0.0260 (se 0.0036), breach of 60% of premium 0.1720, mean shortfall 150
mean injections by year [ 5.7 10.4 17.1 22.4 32.2]
ruin with injections up to 80% of premium 0.0030
The cycle adds premium volatility, and with it ruin. The ruin test reads the surplus before capital, so the injections lower it only because a company topped up in an earlier year starts the next one stronger. Their mean by year is the capital the plan needs from outside.