PIR Book Examples in Aggregate

programming
pir
Python code to recreate exhibits from Pricing Insurance Risk book.
Author

Stephen J. Mildenhall

Published

2025-01-15

Main PIR Page

Table 4.3

Pricing Insurance Risk Table 4.3 on page 76 shows estimated occurrence and aggregate PML points for a simple model of US Hurricane Risk. The table is reproduced in using the following code.

import pandas as pd
import numpy as np
import scipy.stats as ss
from aggregate import build

pd.set_option("display.float_format", lambda x: f'{x:,.0f}' if abs(x) > 10 else f'{x:.3f}')

# model parameters
sigma = 2.58
en = 1.74
cv = np.sqrt(np.exp(sigma**2)-1)

# manual severity
sev = ss.lognorm(sigma, scale=np.exp(-sigma**2/2)*5000)

# return periods
Ns = np.array([2, 5, 10, 20, 25, 50, 100, 200, 250, 500, 1000])
Ps = 1 - 1 / Ns
PML = sev.ppf(1 + np.log(Ps) / en)

df = pd.DataFrame({'n': Ns, 'p': Ps, 'Adj p':1 + np.log(Ps) / en,  'Occ PML': PML}).set_index('n')

usw = build(f'''
agg USHurr {en} claims 4000000 xs 0 sev lognorm 5000 cv {cv} poisson
''', bs=20, log2=18, padding=2)

df['Agg PML'] = [usw.q(i) for i in df.p]
df['Sev VaR'] = [sev.isf(1-p) for p in df.p]
df['Est Agg VaR'] = [sev.isf((1-p)/en) for p in df.p]
df['Error'] = df['Est Agg VaR'] / df['Agg PML'] - 1
df.iloc[:, [0, 1, 2, 4, 3, 5, 6]]
Table 1: Estimated occurrence and aggregate PML points for a simple model of US Hurricane risk. Frequency Poisson with mean 1.74. Severity lognormal with mean USD5 billion and σ=2.58. Amounts in USD millions at 2-18 price levels. Return period in n years.
p Adj p Occ PML Sev VaR Agg PML Est Agg VaR Error
n
2 0.500 0.602 348 179 420 763 0.816
5 0.800 0.872 3,350 1,572 3,940 3,971 0.008
10 0.900 0.939 9,783 4,892 11,080 10,467 -0.055
20 0.950 0.971 23,420 12,490 25,620 24,107 -0.059
25 0.960 0.977 30,196 16,412 32,720 30,873 -0.056
50 0.980 0.988 62,630 35,870 66,180 63,256 -0.044
100 0.990 0.994 121,162 72,473 125,760 121,714 -0.032
200 0.995 0.997 222,461 137,948 228,020 222,931 -0.022
250 0.996 0.998 268,049 167,935 273,900 268,492 -0.020
500 0.998 0.999 466,816 300,935 473,500 467,178 -0.013
1000 0.999 0.999 787,463 520,108 794,820 787,752 -0.009