A reading path through the guides
reading_path.RmdRendered from examples/reading_path.qmd.
The code runs each time the site is built, so the output below is
current.
The guides
explain prospicio one topic at a time. Most of them reproduce a
published text. This document is a map to the guides, in R. It is the R
twin of reading_path.ipynb,
with the same data, seeds and models. Every number that it prints agrees
with the notebook.
It takes one small synthetic book through the stations of an actuary, from claims data to capital. At each station it runs a few lines of prospicio. It then names the guides to read next and the question that each guide answers.
The book has two lines, with money in millions of a synthetic currency:
- Property: seven years of ground-up claims. A known claim count and severity give the claims, so you can check the fits against the truth. This line carries the severity, the claim count, the annual aggregate, a per-risk excess of loss layer and the rate indication.
- Casualty: a seven by seven paid triangle, for the reserve and its uncertainty.
The stations:
- Severity and claim count
- The annual aggregate distribution
- A reinsurance layer: exposure and experience rating, then a price
- A ratemaking indication
- Reserving: chain ladder, Mack, the ODP bootstrap
- Risk loads, distortions and capital allocation
- Where to go next: Bayesian models and GLMs
Every chunk has a seed, and the whole document runs in a few seconds.
To run it, install the R package (remotes::install_github,
see R/prospicio/bootstrap.R). Then render it from anywhere
in the repository with
quarto render examples/reading_path.qmd. The document reads
no data files. The links go to the Python guides. Most guides have an R
twin of the same name, a .qmd beside them.
The book
The property claims come from a negative binomial count and a lognormal severity. The count has mean 400 and variance 600 a year. The severity has mean 0.02 and CV 3. In practice these are unknown. Here they are known, so each station can show how far its estimate is from the truth.
# Money is in millions of a synthetic currency.
YEARS <- 2018:2024 # seven accident years
TRUE_COUNT <- negative_binomial_count_from_mean_variance(400, 600) # property claims a year
TRUE_SEVERITY <- lognormal_from_mean_cv(0.02, 3) # one property claim, ground up
counts <- draws(TRUE_COUNT, length(YEARS), 2718)
claims <- draws(TRUE_SEVERITY, sum(counts), 6043)
by_year <- split(claims, rep(YEARS, counts))
for (k in seq_along(YEARS)) {
xs <- by_year[[k]]
cat(sprintf("%d: %d claims, total %.2fm, largest %.2fm\n", YEARS[k], counts[k], sum(xs), max(xs)))
}## 2018: 404 claims, total 8.01m, largest 0.82m
## 2019: 391 claims, total 8.39m, largest 1.66m
## 2020: 435 claims, total 7.62m, largest 0.60m
## 2021: 448 claims, total 6.63m, largest 0.24m
## 2022: 402 claims, total 7.12m, largest 0.46m
## 2023: 459 claims, total 10.31m, largest 0.70m
## 2024: 423 claims, total 9.38m, largest 1.30m
1. Severity and claim count
The code fits a maximum likelihood lognormal to all the claims. It
chooses a claim count by its dispersion. claim_count
returns a Poisson when the variance equals the mean, and a negative
binomial when the variance is larger.
fit <- severity_fit("lognormal", claims)
severity <- fit$distribution
yearly_mean <- mean(counts)
yearly_var <- var(counts)
count <- claim_count(yearly_mean, yearly_var / yearly_mean)
count_family <- if (S7::S7_inherits(count, negative_binomial_count)) "NegativeBinomial" else "Poisson"
cat(sprintf("severity: fitted mean %.4fm, cv %.2f (truth %.4fm, cv 3.00)\n",
mean(severity), sqrt(variance(severity)) / mean(severity), mean(TRUE_SEVERITY)))## severity: fitted mean 0.0194m, cv 2.90 (truth 0.0200m, cv 3.00)
cat(sprintf("claim count: mean %.1f, dispersion %.2f -> %s (truth 400.0, dispersion 1.50)\n",
yearly_mean, yearly_var / yearly_mean, count_family))## claim count: mean 423.1, dispersion 1.53 -> NegativeBinomial (truth 400.0, dispersion 1.50)
Seven years are enough for the severity, but not for the count: its dispersion rests on seven numbers.
Read next.
- Severity and frequency: which severity family and which count family to use, and how to fit them, with censoring, truncation, splices and mixtures.
- Distributions for actuaries: claim size: limited expected values, fits to grouped, censored and truncated data, excess layers, the leveraging effect of inflation and increased limit factors (Bahnemann, CAS Monograph 2).
- Distributions for actuaries: counts and aggregates: Poisson, mixed Poisson and negative binomial counts, and what contagion does to a count (Bahnemann, chapters 3 and 4).
2. The annual aggregate distribution
The total loss of the year combines the count and the severity. The severity goes on a grid of step 0.01, censored at a policy limit of 2. The FFT gives the annual distribution on that grid. The compound moments and a simulation are two checks.
STEP <- 0.01
POINTS <- 2^12
POLICY_LIMIT <- 2
severity_grid <- discretize(severity, STEP, round(POLICY_LIMIT / STEP) + 1, "rounding")
annual <- compound_distribution(count, severity_grid, POINTS, method = "fft")
moments <- compound_moments(count, severity_grid)
simulated <- total(total(simulate_events(count, severity_grid, 4000, 9157)))
cat(sprintf("FFT: mean %.3f, sd %.3f, 99%% %.2f, 99.5%% %.2f\n",
mean(annual), sqrt(variance(annual)), quantile(annual, 0.99), quantile(annual, 0.995)))## FFT: mean 7.953, sd 1.177, 99% 11.19, 99.5% 11.63
cat(sprintf("moments: mean %.3f, sd %.3f, skew %.3f\n",
moments[["mean"]], sqrt(moments[["variance"]]), moments[["skew"]]))## moments: mean 7.953, sd 1.177, skew 0.558
cat(sprintf("simulation: mean %.3f, 99%% %.2f (4,000 years)\n", mean(simulated), quantile(simulated, 0.99)))## simulation: mean 7.953, 99% 11.15 (4,000 years)
The three agree on the mean. The 99% of the simulation is within its sampling error of the FFT value.
Read next.
- Aggregate distributions: FFT, Panjer, simulation or moments, how to size the grid, and when each is exact, fast or unsafe.
-
prospicio
for aggregate users: the same methods as Mildenhall’s
aggregatepackage, side by side, for a reader who knows that package.
3. A reinsurance layer
The layer is a per-risk excess of loss layer of 1.5 xs 0.5 on the property line. Exposure rating prices it from the fitted severity curve (the expected count times the layer average of the severity). Experience rating prices it from the claims that reached it (the burning cost). Only a few claims pierce 0.5. So the experience gets little credibility, and the blend is near the exposure figure.
LIMIT <- 1.5
ATTACHMENT <- 0.5
tower <- reinsurance_tower(list(xol_layer("1.5 xs 0.5", LIMIT, ATTACHMENT)))
layer_annual <- tower_on_grid(tower, count, severity_grid, POINTS)$ceded[[1]]
exposure_loss <- layer(collective_model(count, severity), LIMIT, ATTACHMENT)
in_layer <- pmin(pmax(claims - ATTACHMENT, 0), LIMIT)
n_layer <- sum(claims > ATTACHMENT)
experience_loss <- sum(in_layer) / length(YEARS)
standard <- credibility_standard(0.90, 0.05)[["frequency"]]
z <- limited_fluctuation_credibility(n_layer, standard)
selected <- credibility_weighted(experience_loss, z, exposure_loss)
cat(sprintf("exposure (fitted curve) %.4f, on the grid %.4f\n", exposure_loss, mean(layer_annual)))## exposure (fitted curve) 0.2383, on the grid 0.2382
cat(sprintf("experience (burning cost) %.4f from %d claims, credibility %.3f\n", experience_loss, n_layer, z))## experience (burning cost) 0.4111 from 7 claims, credibility 0.080
## selected expected layer loss 0.2522
The price backs the layer with capital at its 99% TVaR and asks for a 10% return on that capital. The pentagon (loss, margin, premium, capital, assets) gets all five quantities from three of them:
pg <- pentagon(loss = selected, assets = TVaR(layer_annual, 0.99), return_on_capital = 0.10)
cat(sprintf("layer: loss %.4f, margin %.4f, premium %.4f (%s rate on line), capital %.3f\n",
pg[["loss"]], pg[["margin"]], pg[["premium"]], pct(pg[["premium"]] / LIMIT, 2), pg[["capital"]]))## layer: loss 0.2522, margin 0.1777, premium 0.4299 (28.66% rate on line), capital 1.777
Read next.
- What a reinsurance price is: the technical premium of an excess of loss layer and a quota share, reinstatements, and a contract alone and in a book.
- Experience and exposure rating: how to prepare losses as-if (development, trend, index clauses), the burning cost, exposure curves and risk profiles, and how to blend the two by credibility (after Clark).
- Choosing a method: which tool for which cover.
4. A ratemaking indication
The code applies the loss ratio method to the property line:
- It brings earned premium to the current rate level.
- It trends losses two years at 4% a year to the period that the new rates cover.
- It loads losses 8% for LAE.
Property claims are short tailed, so the code takes the claims as fully developed. The indicated change compares the projected loss and LAE ratio with the permissible ratio (20% variable expense, 5% profit, 8% fixed expense). With nearly 3,000 claims, the experience is fully credible under the classical standard of 1,082 claims.
earned <- c(12.1, 12.6, 13.0, 13.5, 13.9, 14.4, 14.8)
on_level <- c(1.12, 1.09, 1.07, 1.05, 1.03, 1.01, 1.00)
reported <- vapply(by_year, sum, numeric(1))
experience <- loss_ratio_experience(
earned_premium = earned, losses = reported, on_level_factor = on_level,
development = 1, loss_trend = 1.04^2, lae_factor = 1.08
)
VARIABLE <- 0.20
PROFIT <- 0.05
FIXED <- 0.08
change <- indicated_change(experience$loss_ratio, VARIABLE, PROFIT, fixed_ratio = FIXED)
z_rate <- limited_fluctuation_credibility(sum(counts), standard)
cat(sprintf("projected loss and LAE ratio by year %s
", paste(pct(experience$by_year$loss_ratio), collapse = " ")))## projected loss and LAE ratio by year 69.1% 71.4% 64.0% 54.6% 58.1% 82.8% 74.0%
cat(sprintf("all years %s; permissible %s\n", pct(experience$loss_ratio),
pct(permissible_loss_ratio(VARIABLE, PROFIT, fixed_ratio = FIXED))))## all years 67.8%; permissible 67.0%
cat(sprintf("indicated change %s%s, credibility %.2f (%s claims)\n", if (change >= 0) "+" else "",
pct(change), z_rate, format(sum(counts), big.mark = ",")))## indicated change +1.1%, credibility 1.00 (2,962 claims)
Read next.
- Ratemaking with Werner and Modlin: each step of the overall indication (premium at the current rate level by the parallelogram method, trend, development, expenses and the permissible loss ratio, credibility and its complements).
- Werner and Modlin’s indications: the three worked indications of the book end to end, and increased limits and deductibles.
5. Reserving
The casualty line has a paid triangle. The chain ladder gives the ultimate by accident year. Mack’s formula gives the standard error of the reserve without a distributional assumption. The ODP bootstrap gives a distribution of the reserve.
paid <- list( # casualty, cumulative paid by accident year, ages 12, 24, ... months
c(2.41, 4.22, 5.27, 5.90, 6.20, 6.32, 6.40),
c(2.66, 5.19, 7.16, 8.59, 9.45, 9.92),
c(2.52, 4.54, 5.54, 6.04, 6.40),
c(2.90, 5.86, 7.91, 9.18),
c(3.05, 5.18, 6.73),
c(3.21, 6.03),
c(3.40)
)
tri <- triangle(
data.frame(origin = rep(YEARS, lengths(paid)),
age = unlist(lapply(paid, function(row) 12 * seq_along(row))),
paid = unlist(paid)),
origin = "origin", development = "age", columns = "paid"
)
cl <- chain_ladder(tri, "paid")
cat(sprintf("age-to-age %s
", paste(sprintf("%.3f", cl@ldf), collapse = " ")))## age-to-age 1.852 1.305 1.148 1.074 1.038 1.013
## ultimate 6.40 10.05 6.73 10.36 8.72 10.20 10.65
## chain ladder reserve 15.03m
mk <- mack(tri, "paid")
boot <- total(odp_bootstrap(tri, "paid", n_sims = 2000, seed = 4471)@reserves)
cat(sprintf("Mack: reserve %.2fm, standard error %.2fm, cv %.3f\n", mk@total_reserve, mk@total_standard_error, mk@total_cv))## Mack: reserve 15.03m, standard error 2.01m, cv 0.134
cat(sprintf("ODP bootstrap: mean %.2fm, sd %.2fm, 99.5%% %.2fm (2,000 simulations)\n",
mean(boot), sqrt(variance(boot)), quantile(boot, 0.995)))## ODP bootstrap: mean 14.96m, sd 1.94m, 99.5% 20.13m (2,000 simulations)
Mack and the bootstrap give a similar result: a reserve of about 15 with a CV near 13%.
Read next.
- Reserving methods: which method to use when (chain ladder, Bornhuetter-Ferguson, Cape Cod, Mack, the bootstraps, tails and the one-year view), with the uncertainty of the reserve as a distribution.
- Reserving with Friedland’s techniques: development, expected claims, Bornhuetter-Ferguson, Benktander and Cape Cod on the data of the CAS text itself.
- Taylor and McGuire’s ODP GLM: the chain ladder as an over-dispersed Poisson GLM, its prediction error and the bootstrap, and the reduced models (CAS Monograph 3).
- Excess-layer loss development: layer factors derived from the dense ground-up triangle and a claim size distribution, blended with the data of the layer itself by credibility, and the layer share as a Bayesian Bornhuetter-Ferguson prior.
6. Risk loads, distortions and capital allocation
The two lines go into one book as independent units on the same grid. The property unit is the annual loss from station 2. The casualty unit is the reserve risk from station 5, a gamma with the mean and CV from Mack. Assets at the 99% VaR of the book back it, and these assets are less than the sum of the two VaRs. The code calibrates each of five distortion families to a 10% return on the capital of the book. So all five charge the same total margin, and the natural allocation splits that margin between the lines.
reserve_risk <- gamma_from_mean_cv(mk@total_reserve, mk@total_cv)
reserve_grid <- discretize(reserve_risk, STEP, POINTS, "rounding")
book <- capital_portfolio(list(property = annual, `casualty reserve` = reserve_grid))
alone <- quantile(annual, 0.99) + quantile(reserve_grid, 0.99)
cat(sprintf("99%% VaR: units alone %.2fm, together %.2fm\n", alone, portfolio_assets(book, 0.99)))## 99% VaR: units alone 31.29m, together 28.83m
FAMILIES <- c("ccoc", "ph", "wang", "dual", "tvar")
cat(sprintf("%10s %9s %9s %8s\n", "distortion", "property", "reserve", "total"))## distortion property reserve total
for (family in FAMILIES) {
d <- calibrate_portfolio(book, family, p = 0.99, return_on_capital = 0.10)
priced <- natural_price(book, d, p = 0.99)
cat(sprintf("%10s %9.3f %9.3f %8.3f\n", family, priced$margin[1], priced$margin[2],
priced$margin[priced$unit == "total"]))
}## ccoc 0.139 0.394 0.532
## ph 0.137 0.395 0.532
## wang 0.136 0.397 0.532
## dual 0.134 0.398 0.532
## tvar 0.133 0.399 0.532
Here the five distortions split the margin almost the same way, because neither line has a catastrophe tail. They differ when one unit is much more skewed than the other, as the case studies show.
Read next.
- Risk loads and distortions: which risk load or distortion to use, how to calibrate it to quotes, and how to price a contract in a portfolio.
- Pricing Insurance Risk: risk measures: VaR, TVaR and EPD, their properties, and a distortion as a spectral risk measure (Mildenhall and Major, Part I).
- Pricing Insurance Risk: portfolio pricing: the constant cost of capital price, classical premium principles and the calibrated distortions (Part II).
- Pricing Insurance Risk: price allocation and allocation in practice: the classical allocations against the natural allocation, and which question each answers (Part III).
- Pricing Insurance Risk: the case studies: books with a catastrophe unit, gross and net, where the distortions disagree by unit.
- CAS Monograph 15 and its chapter guides on theory, applications, practice and dependence by Iman-Conover: capital modeling and portfolio management (Major and Mildenhall), from risk measures to reinsurance decisions and correlated units.
7. Where to go next
The stations above use closed forms, grids and quick simulations. Two families of guides go further, with fits that take longer than this notebook should:
- Bayesian reserving. Meyers’ models (CAS Monograph 8) go from Mack and the ODP bootstrap to the Bayesian CRC, CSR and CAY models. They test the models by the percentile of the outcome. Compartmental reserving (Gesmann and Morris) models paid and outstanding together, with reporting and payment rates.
- GLMs for rating. GLMs for insurance rating and their validation (CAS Monograph 5) build a multiplicative rating plan and test it. From GLMs to comprehensive pricing and its second part (CAS Monograph 16) add penalized GLMs, GAMs, offsets and lessons from boosting models.
The reading list maps each source text to its guides. The other notebooks here and their R twins are worked analyses that use these pieces together.