Skip to contents

Rendered from docs/guides/a-first-course.qmd. The code runs each time the site is built, so the output below is current.

Read this page first. It is for a student or a new analyst who knows what a premium and a claim are. It goes from a table of premium and losses to a price, and from prices to decisions. Each idea has a small example that you can run.

  1. The ideas (sections 1 to 7): loss distributions, the aggregate loss, price against expected loss, distortions, diversification and allocation.
  2. Two decisions (sections 8 and 9): write a new unit, and choose a treaty.
  3. The checklist (section 10): ten steps from data to a quote, with a template for your own data.

This page is the R twin of the Python guide a-first-course.md, with the same sections, examples and numbers. R/prospicio/tests/test-guides.R checks that each R chunk prints exactly the text below it. Money is in millions of a synthetic currency. All examples are synthetic. The appendix defines the terms.

Part 1. The ideas

1. A loss is a distribution

Start with two small units. In a year, unit A loses 0, 4 or 10 with probability 1/2, 1/4 and 1/4. Unit B loses 0, 2 or 40 with the same probabilities. The units are independent, so the chances in 16 of a pair are the product of the chances in 4: the pair (0, 0) has 2 times 2 = 4. Each pair, repeated as many times as its chances, gives sixteen equally likely years.

sampled() holds equally likely outcomes. Read risk_measure(x, TVAR75) as the 75% TVaR of x (TVaR is also a distortion, section 5).

library(prospicio)
library(gt)

A <- list(outcome = c(0, 4, 10), chances = c(2, 1, 1))   # chances in 4
B <- list(outcome = c(0, 2, 40), chances = c(2, 1, 1))
pairs <- expand.grid(j = 1:3, i = 1:3)                    # each outcome of A with each of B
times <- A$chances[pairs$i] * B$chances[pairs$j]
rows <- cbind(A = rep(A$outcome[pairs$i], times),         # 16 equally likely years
              B = rep(B$outcome[pairs$j], times))
unit_a <- sampled(rows[, "A"])
unit_b <- sampled(rows[, "B"])
both <- sampled(rows[, "A"] + rows[, "B"])
TVAR75 <- distortion("tvar", 0.75)

units <- list(A = unit_a, B = unit_b, "A + B" = both)
tails <- data.frame(
  unit = names(units),
  mean = vapply(units, mean, 0),
  `VaR 75%` = vapply(units, function(x) quantile(x, 0.75), 0),
  `TVaR 75%` = vapply(units, function(x) risk_measure(x, TVAR75), 0),
  check.names = FALSE, row.names = NULL
)
gt(tails, rowname_col = "unit") |>
  tab_header("Mean and 75% tail measures of two independent units", "Millions") |>
  fmt_number(columns = c("mean", "VaR 75%", "TVaR 75%"), decimals = 2)
Mean and 75% tail measures of two independent units
Millions
mean VaR 75% TVaR 75%
A 3.50 4.00 10.00
B 10.50 2.00 40.00
A + B 14.00 12.00 43.50

The means add: 3.5 + 10.5 = 14. The tails do not. B loses 40 in one year in four, above the 75% point, so its VaR is 2 and its TVaR is 40. A VaR shows where the bad years start, a TVaR how bad they are. The TVaR of the book is less than 50, the sum for A and B, because their worst years do not always occur together.

2. Adding independent risks

The loss of the book is the loss of A plus the loss of B. For independent units, the probability of a total is a sum over the pairs that give it. A total of 0 needs both units at 0: 1/2 times 1/2 = 4/16. capital_portfolio() does this for any matrix of simulated or listed outcomes.

port <- capital_portfolio(rows)
totals <- data.frame(total = sprintf("%.0f", port@totals), chances = as.integer(round(16 * port@probs)))
gt(totals, rowname_col = "total") |>
  tab_header("The nine totals of the book", "Chances in 16") |>
  fmt_integer(columns = "chances")
The nine totals of the book
Chances in 16
chances
0 4
2 2
4 2
6 1
10 2
12 1
40 2
44 1
50 1

This calculation is a convolution. Thousands of claims need a tool, the next section.

3. The aggregate loss: count times severity, by FFT

A real line has a random number of claims (the frequency) and a random size for each claim (the severity). Their sum for the year is the aggregate loss. discretize() puts the severity on a grid of equally spaced points, and compound_distribution(..., method = "fft") adds the claims with the fast Fourier transform (FFT). Here the mean claim is 1 with a CV of 1.5, and the mean count is 10 claims a year.

severity <- discretize(lognormal_from_mean_cv(1, 1.5), 0.05, 801, "rounding")   # a 0.05 step, up to 40
year <- compound_distribution(poisson_count(10), severity, 2^12, method = "fft") # totals up to 204.8
report <- year@report
cat(sprintf("mean claim %.3f, mean year %.2f, sd %.2f\n", mean(severity), mean(year), sqrt(variance(year))))
## mean claim 0.999, mean year 9.99, sd 5.65
cat(sprintf("99%% VaR %.2f, 99%% TVaR %.2f\n", quantile(year, 0.99), TVaR(year, 0.99)))
## 99% VaR 28.70, 99% TVaR 34.91
cat(sprintf("aliasing error below 1e-12: %s, tail mass below 1e-12: %s\n",
            report$aliasing_error < 1e-12, report$tail_mass < 1e-12))
## aliasing error below 1e-12: TRUE, tail mass below 1e-12: TRUE

The right tail of the year is long: the 99% VaR is almost three times the mean.

library(ggplot2, exclude = "layer")   # keeps prospicio's layer()
n_pts <- length(year@probs)
density <- data.frame(x = year@step * (seq_len(n_pts) - 1), d = year@probs / year@step)
marks <- data.frame(x = c(mean(year), quantile(year, 0.99), TVaR(year, 0.99)),
                    mark = c("mean", "99% VaR", "99% TVaR"))
ggplot(density, aes(x, d)) +
  geom_line(aes(colour = "aggregate loss of the year")) +
  geom_vline(aes(xintercept = x, linetype = mark), data = marks, colour = "grey50") +
  coord_cartesian(xlim = c(0, 50), expand = FALSE) +
  labs(x = "loss in the year (millions)", y = "probability density", colour = NULL, linetype = NULL,
       title = "The aggregate loss: 10 claims a year on average, CV 1.5 each") +
  theme(legend.position = "top")
0.000.020.040.060.0801020304050loss in the year (millions)probability density99% TVaR99% VaRmeanaggregate loss of the yearThe aggregate loss: 10 claims a year on average, CV 1.5 each

Two checks are important. The FFT wraps any probability past the end of the grid back to the start (aliasing). The tail mass is the probability that stays past the grid. Both must be very small, or the tail that you price is wrong. If they are not, use more points or a larger step; audit_grid() selects them for you (section 10).

4. Why a price must exceed the mean

Go back to the book of section 1. An insurer that charges only the expected loss, 14, makes no profit on average, and it still needs capital for the bad years. The owners supply that capital only for a return. Let the assets be the 75% TVaR, 43.5, and let the owners want 10%. Then the premium P must give a margin of 10% of the capital: P - 14 = 10% of (43.5 - P).

The pricing pentagon solves this equation. It connects loss, premium, margin, capital and assets; pentagon() takes any three and sets the other two.

book <- pentagon(loss = mean(both), assets = risk_measure(both, TVAR75), return_on_capital = 0.10)
cat(sprintf("loss %.2f  premium %.2f  margin %.2f  capital %.2f  assets %.2f  loss ratio %.1f%%\n",
            book[["loss"]], book[["premium"]], book[["margin"]], book[["capital"]], book[["assets"]],
            100 * book[["loss_ratio"]]))
## loss 14.00  premium 16.68  margin 2.68  capital 26.82  assets 43.50  loss ratio 83.9%

The price is above the mean because capital has a cost: a riskier cover needs more capital, so more margin. The pentagon section of the price guide has the formula.

5. What a distortion is

A distortion prices the loss directly, with no capital standard. It replaces each probability s of a loss above a value with a larger probability, g(s), so bad outcomes count for more than their probability. The proportional hazard distortion is g(s) = s to the power 0.5. For four equally likely outcomes it gives one weight to each outcome, smallest first (distortion_weights()). The price is the weighted sum.

ph <- distortion("proportional_hazard", 0.5)
cat("g(s) at s = 0.25, 0.5, 0.75: ",
    paste(sprintf("%.3f", distortion_g(ph, c(0.25, 0.5, 0.75))), collapse = ", "), "\n", sep = "")
## g(s) at s = 0.25, 0.5, 0.75: 0.500, 0.707, 0.866
w <- distortion_weights(ph, 4)
cat("weights of 4 equally likely outcomes, smallest first: ",
    paste(sprintf("%.3f", w), collapse = ", "), "\n", sep = "")
## weights of 4 equally likely outcomes, smallest first: 0.134, 0.159, 0.207, 0.500
cat(sprintf("A as 0, 0, 4, 10 by hand: %.2f\n", w[3] * 4 + w[4] * 10))
## A as 0, 0, 4, 10 by hand: 5.83

The distortion prices a chance of one in four as one in two, so the worst of four outcomes gets weight 0.5, not 0.25. The prices:

ph_prices <- data.frame(
  unit = names(units),
  `expected loss` = vapply(units, mean, 0),
  price = vapply(units, function(x) risk_measure(x, ph), 0),
  check.names = FALSE, row.names = NULL
)
ph_prices <- rbind(ph_prices, data.frame(unit = "A's plus B's", `expected loss` = sum(ph_prices[1:2, 2]),
                                         price = sum(ph_prices[1:2, 3]), check.names = FALSE))
gt(ph_prices, rowname_col = "unit") |>
  tab_header("Proportional hazard price, g(s) = s^0.5", "Millions") |>
  fmt_number(columns = c("expected loss", "price"), decimals = 2)
Proportional hazard price, g(s) = s^0.5
Millions
expected loss price
A 3.50 5.83
B 10.50 20.41
A + B 14.00 25.41
A's plus B's 14.00 26.24

The book costs less than A and B priced apart: pricing the two units together already gives a discount.

In the figure, the grey line is no distortion. Proportional hazard lies above it everywhere. The TVaR curve rises straight to 1 at s = 0.25, so all the weight is on the worst quarter.

ss <- seq(0, 1, by = 0.005)
curves <- data.frame(
  s = rep(ss, 2),
  g = c(distortion_g(ph, ss), distortion_g(TVAR75, ss)),
  curve = rep(c("proportional hazard 0.5", "TVaR 75%"), each = length(ss))
)
ggplot(curves, aes(s, g)) +
  geom_line(aes(colour = curve)) +
  geom_abline(slope = 1, intercept = 0, colour = "grey75") +
  annotate("text", x = 0.75, y = 0.68, label = "no distortion, g(s) = s", colour = "grey50", angle = 28) +
  labs(x = "s, the probability of a loss above a value", y = "g(s), the distorted probability",
       colour = NULL, title = "A distortion raises the probability of bad outcomes") +
  theme(legend.position = "top")
no distortion, g(s) = s0.000.250.500.751.000.000.250.500.751.00s, the probability of a loss above a valueg(s), the distorted probabilityproportional hazard 0.5TVaR 75%A distortion raises the probability of bad outcomes

6. Why a book’s price is not the sum of its parts

A book is also cheaper than its parts because it needs less capital. price_stand_alone() prices each unit as a separate book, with assets at its own 90% VaR, and compares them with the full book, with assets at the 90% VaR of the book. It returns one row for each unit, a total row for the book and a sum row for the parts. This section uses a VaR standard, not the 75% TVaR of section 4. A VaR standard leaves the book a small chance of default, and the section shows the effect of that chance.

sa <- price_stand_alone(port, ph, 0.9)
parts <- sa[sa$unit == "sum", ]
whole_book <- sa[sa$unit == "total", ]
stand_alone <- data.frame(
  price = c(paste(sa$unit[1:2], "alone"), "sum of the parts", "the book", "diversification benefit"),
  assets = c(sa$assets[1:2], parts$assets, whole_book$assets, parts$assets - whole_book$assets),
  premium = c(sa$premium[1:2], parts$premium, whole_book$premium, parts$premium - whole_book$premium)
)
gt(stand_alone, rowname_col = "price") |>
  tab_header("Stand-alone and book prices at the 90% VaR standard", "Proportional hazard 0.5, millions") |>
  fmt_number(columns = c("assets", "premium"), decimals = 2)
Stand-alone and book prices at the 90% VaR standard
Proportional hazard 0.5, millions
assets premium
A alone 10.00 5.83
B alone 40.00 20.41
sum of the parts 50.00 26.24
the book 44.00 23.91
diversification benefit 6.00 2.34

Alone, A holds 10 and B holds 40, a sum of 50. The book total reaches 50 in one year in sixteen only, so at the 90% standard the book holds 44.

The premium decreases in two steps:

  1. The distortion alone decreases the 26.24 of the parts to 25.41 (section 5). That 0.83 is pure pooling.
  2. With assets of 44, the book can pay at most 44 (limited liability), so its premium prices that smaller loss: 23.91. That 1.50 is not pooling: the book defaults in the one year in sixteen with a total of 50, and its policyholders bear the 6 that it cannot pay.

The full difference of 2.34 is the diversification benefit. The next section asks which unit gets it.

7. The main allocation methods

To judge each unit, an analyst splits the premium and the assets of the book. Each method answers a different question. capital_allocation() splits the 75% TVaR of the book, 43.5, by four methods. natural_price() splits the proportional hazard premium by the natural allocation: each unit has the book’s distortion weights, outcome by outcome, so the unit premiums add up to the book’s.

pd <- predictive_distribution(rows, data.frame(unit = c("A", "B")))
by_method <- lapply(c("euler", "covariance", "shapley", "marginal"), function(method) {
  al <- capital_allocation(pd, TVAR75, method)$by_component
  data.frame(method = method, A = al$allocated[1], B = al$allocated[2], sum = sum(al$allocated))
})
al <- capital_allocation(pd, TVAR75, "euler")$by_component
natural <- natural_price(port, ph)
alloc <- do.call(rbind, c(by_method, list(
  data.frame(method = "stand-alone", A = al$standalone[1], B = al$standalone[2], sum = sum(al$standalone)),
  data.frame(method = "natural PH (premium)", A = natural$premium[1], B = natural$premium[2],
             sum = natural$premium[3])
)))
gt(alloc, rowname_col = "method") |>
  tab_header("Allocation of the book's 75% TVaR of assets, 43.50, to units A and B",
             "Millions; the last row splits the premium, not the assets") |>
  fmt_number(columns = c(A, B, sum), decimals = 2)
Allocation of the book's 75% TVaR of assets, 43.50, to units A and B
Millions; the last row splits the premium, not the assets
A B sum
euler 3.50 40.00 43.50
covariance 2.37 41.13 43.50
shapley 6.75 36.75 43.50
marginal 3.50 33.50 37.00
stand-alone 10.00 40.00 50.00
natural PH (premium) 5.05 20.36 25.41
Method The question it answers
Euler (coTVaR) What does each unit lose, on average, in the worst years of the book? This is the coTVaR of the unit. In those years the mean loss of A is 3.5, its own mean
Covariance How much does each unit move with the total? It can give a unit less than its mean
Shapley What does each unit add, on average over all orders in which you can build the book?
Marginal How much does the TVaR of the book decrease without the unit? The parts do not add up to the total (37 of 43.5)
Natural allocation The share of each unit in the distorted price, outcome by outcome. The shares add up, and A pays 5.05 for an expected loss of 3.5

No method is correct for all questions. Select the method for the question, and say which you used. Never compare the return of one unit under one method with that of another unit under a different method. Section 8 of choosing a method runs these methods on a simulated book; the price allocation guide has more.

Part 2. Two decisions

8. Should we write a new unit?

An insurer writes motor and home. A broker offers a block of storm-exposed commercial property for a premium of 7.3. Should the insurer write it? We ask the same question for a second insurer that writes motor and liability.

The FFT gives the annual loss of each line from a count and a claim size capped at the policy limit:

STEP <- 0.1
POINTS <- 2^12

line_loss <- function(frequency, severity, cap) {
  # A line's annual loss on the grid: claims capped at the policy limit, then the FFT.
  claims <- discretize(severity, STEP, round(cap / STEP) + 1, "rounding")
  compound_distribution(frequency, claims, POINTS, method = "fft")
}

motor <- line_loss(negative_binomial_count_from_mean_variance(100, 150), lognormal_from_mean_cv(0.4, 1), 10)
home <- line_loss(poisson_count(8), lognormal_from_mean_cv(1.5, 2.5), 40)
liability <- line_loss(poisson_count(3), lognormal_from_mean_cv(3, 2), 40)
storm <- line_loss(poisson_count(4), lognormal_from_mean_cv(1.5, 2.5), 40) # the new unit
all_lines <- list(motor = motor, home = home, liability = liability, "new unit" = storm)
lines_t <- data.frame(
  line = names(all_lines),
  mean = vapply(all_lines, mean, 0),
  `99% VaR` = vapply(all_lines, function(g) quantile(g, 0.99), 0),
  check.names = FALSE, row.names = NULL
)
gt(lines_t, rowname_col = "line") |>
  tab_header("Annual loss of each line", "Millions") |>
  fmt_number(columns = "mean", decimals = 2) |>
  fmt_number(columns = "99% VaR", decimals = 1)
Annual loss of each line
Millions
mean 99% VaR
motor 40.03 56.1
home 11.76 48.2
liability 8.73 45.9
new unit 5.88 35.8

The lines are not independent. A storm hits home and commercial property in the same year, so the new unit has a copula correlation of 0.7 with home. Liability has no relation to the weather: 0. Motor has 0.1 with all lines. copula_simulate() draws 10,000 years from the lines, joined by a gaussian_copula(), a standard method to put dependence on given distributions. Its correlation is that of the normal scores behind the draws. The correlation of the losses is smaller. The function runs the same Rust code with the same seed as the Python guide, so all numbers below are the same.

First, the book of today. The insurer holds assets at the 99% TVaR of its total and wants a 10% return on capital. calibrate_portfolio() finds the Wang distortion that gives exactly that premium (Wang has one parameter, lambda: a higher lambda makes risk more expensive). We keep it as the price of risk of the company, the charge of its investors for risk of any type.

N <- 10000
SEED <- 2026
RETURN <- 0.10
TAIL <- distortion("tvar", 0.99) # the capital standard: assets = 99% TVaR of the book's total

book_of <- function(lines, correlation, keys) {
  # Simulate the lines joined by a Gaussian copula: the draws, the portfolio and its assets.
  pd <- copula_simulate(gaussian_copula(correlation), lines, N, SEED, keys = data.frame(line = keys))
  list(pd = pd, port = capital_portfolio(pd), assets = risk_measure(pd, TAIL))
}

two <- book_of(list(motor, home), rbind(c(1, 0.1), c(0.1, 1)), c("motor", "home"))
house <- calibrate_portfolio(two$port, "wang", assets = two$assets, return_on_capital = RETURN)
today <- natural_price(two$port, house, assets = two$assets)
cat(sprintf("motor + home: assets %.1f, Wang lambda %.3f\n", two$assets, house@parameters[["lambda"]]))
## motor + home: assets 100.5, Wang lambda 0.365
book_t <- data.frame(line = today$unit, loss = today$loss, premium = today$premium,
                     capital = today$capital, return = today$return_on_capital)
gt(book_t, rowname_col = "line") |>
  tab_header("The book of today, calibrated to a 10% return", "Millions") |>
  fmt_number(columns = c("loss", "premium", "capital"), decimals = 2) |>
  fmt_percent(columns = "return", decimals = 1)
The book of today, calibrated to a 10% return
Millions
loss premium capital return
motor 40.10 41.56 16.97 8.6%
home 11.73 14.69 27.24 10.9%
total 51.83 56.25 44.21 10.0%

Motor is large but steady, and gets little capital. Home has a heavy tail, and gets most of the capital.

Now add the new unit to each book, and price the larger book with the same distortion. The marginal premium is the increase in the Wang premium of the book. A lower premium pays the owners less than the company’s price of risk. The table also shows the allocated premium, the premium that keeps the larger book at a flat 10% on its 99% TVaR assets, and two splits of the assets.

OFFERED <- 7.3
books <- list( # the two lines, then the new unit's copula correlation to each
  "motor + home" = list(lines = list(motor, home), new = c(0.1, 0.7)),
  "motor + liability" = list(lines = list(motor, liability), new = c(0.1, 0))
)
results <- list()
for (name in names(books)) {
  b <- books[[name]]
  keys <- strsplit(name, " + ", fixed = TRUE)[[1]]
  two <- book_of(b$lines, rbind(c(1, 0.1), c(0.1, 1)), keys)
  house <- calibrate_portfolio(two$port, "wang", assets = two$assets, return_on_capital = RETURN) # its own book
  three <- book_of(c(b$lines, list(storm)),
                   rbind(c(1, 0.1, b$new[1]), c(0.1, 1, b$new[2]), c(b$new[1], b$new[2], 1)), c(keys, "new"))
  before <- natural_price(two$port, house, assets = two$assets)
  before <- before[before$unit == "total", ]
  after <- natural_price(three$port, house, assets = three$assets)
  after_total <- after[after$unit == "total", ]
  results[[name]] <- c(
    "expected loss" = after$loss[3],
    "allocated premium" = after$premium[3],
    "marginal premium" = after_total$premium - before$premium,
    "premium for 10%" = pentagon(loss = after_total$loss, assets = three$assets,
                                 return_on_capital = RETURN)[["premium"]] - before$premium,
    "allocated assets" = after$assets[3],
    "Shapley assets" = capital_allocation(three$pd, TAIL, "shapley")$by_component$allocated[3],
    "marginal assets" = three$assets - two$assets,
    "return at 7.3" = pentagon(loss = after_total$loss, premium = before$premium + OFFERED,
                               assets = three$assets)[["return_on_capital"]]
  )
}

cols <- names(results)
new_unit <- data.frame(measure = names(results[[1]]), as.data.frame(results, check.names = FALSE),
                       check.names = FALSE, row.names = NULL)
gt(new_unit, rowname_col = "measure") |>
  tab_header("The new unit in each book", sprintf("Millions; offered premium %g", OFFERED)) |>
  fmt_number(columns = all_of(cols), rows = 1:7, decimals = 2) |>
  fmt_percent(columns = all_of(cols), rows = 8, decimals = 1)
The new unit in each book
Millions; offered premium 7.3
motor + home motor + liability
expected loss 5.79 5.82
allocated premium 7.72 7.19
marginal premium 7.47 6.61
premium for 10% 8.11 6.32
allocated assets 27.87 18.96
Shapley assets 34.92 25.35
marginal assets 31.42 11.26
return at 7.3 8.7% 12.2%
for (name in names(results)) {
  verdict <- if (OFFERED >= results[[name]][["marginal premium"]]) "write" else "decline"
  cat(sprintf("offered %.2f in %s: %s\n", OFFERED, name, verdict))
}
## offered 7.30 in motor + home: decline
## offered 7.30 in motor + liability: write

The decision. The same unit at the same price gets opposite answers. In the motor and home book it adds 31.42 of assets, because its storms occur with the storms of home, and the Wang premium rises by 7.47: 7.3 is too little, so decline or ask for at least 7.5. In the motor and liability book it adds only 11.26 of assets and the Wang premium rises by 6.61: 7.3 is enough, so write it.

The two criteria in the table do not agree, so select the one that controls the decision. A flat 10% on the assets of the larger book (the constant cost of capital distortion) prices each unit of extra capital the same. Wang charges less for the far tail and more for the moderate years. The storm adds much tail to the motor and home book, so the flat hurdle asks more than Wang. It adds little tail to the motor and liability book, so the hurdle asks less.

This page uses the calibrated Wang price, because it prices all risks on the same terms. Say so when you report the decision. An insurer that uses the flat hurdle should ask for 8.11 for motor and home.

There are two lessons:

  1. The price of a unit depends on the book that it joins. There is no single correct premium for it.
  2. The allocated premium is not the marginal premium. An allocation shares the diversification of the full book. The marginal premium measures only the change that the unit causes, so use it to add or remove a unit.

9. Choosing a treaty for one cedant

A cedant writes 100 of premium. It expects 40 claims a year (negative binomial, variance 80), with mean 1.3 and CV 3, capped at a policy limit of 25. It must select a reinsurance structure.

This cedant measures capital as a solvency regulator does: the 99.5% VaR of its yearly cost minus the mean. Its owners want 16% on that capital. The reinsurer prices with a 10% return on its own 99% TVaR, then adds expenses and brokerage. Reinsurance pays when it costs less than 16% of the capital that it releases.

PREMIUM <- 100
LIMIT <- 25
frequency <- negative_binomial_count_from_mean_variance(40, 80)
claims <- discretize(lognormal_from_mean_cv(1.3, 3), STEP, round(LIMIT / STEP) + 1, "rounding") # capped at 25
gross <- compound_distribution(frequency, claims, POINTS, method = "fft")
HURDLE <- 0.16 # the cedant's cost of capital

cedant_capital <- function(g) {
  # The cedant's capital: the 99.5% VaR of its cost less the mean.
  quantile(g, 0.995) - mean(g)
}

GROSS_CAPITAL <- cedant_capital(gross)
cat(sprintf("gross: expected loss %.2f, 99.5%% VaR %.1f, capital %.2f\n",
            mean(gross), quantile(gross, 0.995), GROSS_CAPITAL))
## gross: expected loss 49.28, 99.5% VaR 114.8, capital 65.52
cat(sprintf("aliasing error below 1e-12: %s\n", gross@report$aliasing_error < 1e-12))
## aliasing error below 1e-12: TRUE

Excess of loss: which attachment and limit?

tower_on_grid() gives the annual loss of a layer (ceded) and the net loss of the cedant (net) on the same grid. risk_loaded_price() gives the risk premium of the reinsurer. technical_quote() adds 5% expenses and 10% brokerage to it. In the tables, ceded is the expected loss that the layer pays, premium is what the cedant pays for it, cost is the premium minus the expected recoveries, and saved is the capital that the cedant saves. Cost % is the cost per unit of capital saved. Value is 16% of the capital saved minus the cost; a positive value means that the cover costs less than the capital.

ROWS <- list()

record <- function(name, ceded_loss, premium, cost, saved) {
  ROWS[[name]] <<- c(ceded = ceded_loss, premium = premium, cost = cost, saved = saved)
}

structure_table <- function(names, title, drop = character()) {
  # The recorded structures as a table, with the cost per unit of capital saved and the value.
  df <- do.call(rbind, lapply(names, function(n) {
    r <- ROWS[[n]]
    data.frame(structure = n, ceded = r[["ceded"]], premium = r[["premium"]], cost = r[["cost"]],
               saved = r[["saved"]], `cost %` = r[["cost"]] / r[["saved"]],
               value = HURDLE * r[["saved"]] - r[["cost"]], check.names = FALSE)
  }))
  df <- df[, setdiff(names(df), drop)]
  numbers <- setdiff(names(df), c("structure", "cost %"))
  gt(df, rowname_col = "structure") |>
    tab_header(title, "Millions; value = 16% of the capital saved, minus the cost") |>
    fmt_number(columns = all_of(numbers), decimals = 2) |>
    fmt_percent(columns = "cost %", decimals = 1)
}

xl_quotes <- list()
for (terms in list(c(23, 2), c(20, 5), c(10, 5), c(15, 10))) {
  name <- sprintf("XL %gx%g", terms[1], terms[2])
  xl <- xol_layer(name, terms[1], terms[2])
  grids <- tower_on_grid(reinsurance_tower(list(xl)), frequency, claims, POINTS)
  layer_loss <- grids$ceded[[1]]
  q <- technical_quote(risk_loaded_price(layer_loss, TAIL, cost_of_capital = RETURN),
                       expenses = 0.05, brokerage = 0.10, limit = terms[1])
  xl_quotes[[name]] <- list(quote = q, ceded = layer_loss)
  record(name, mean(layer_loss), q$premium, q$premium - mean(layer_loss), GROSS_CAPITAL - cedant_capital(grids$net))
}
structure_table(names(ROWS), "Excess of loss: which attachment and limit?")
Excess of loss: which attachment and limit?
Millions; value = 16% of the capital saved, minus the cost
ceded premium cost saved cost % value
XL 23x2 20.91 30.52 9.61 42.89 22.4% −2.75
XL 20x5 10.67 17.26 6.59 29.73 22.2% −1.84
XL 10x5 8.46 13.07 4.61 22.64 20.3% −0.98
XL 15x10 4.72 8.76 4.03 17.88 22.6% −1.17

A lower attachment saves more capital, but costs more. Each layer costs 20% to 23% of the capital that it releases, above the 16% of the cedant. The 10x5 layer has the best value, still negative.

Quota share with a sliding-scale commission

A quota share cedes a fixed share of each claim and of the premium, here 25%. The reinsurer pays a ceding commission for the expenses of the cedant. The technical commission is the ceded premium left after the risk premium of the reinsurer, 2% expenses and 1.5% brokerage (section 4 of the price guide).

A sliding scale pays more commission when the ceded loss ratio is low, and less when it is high. Here the scale has the same expected commission as the flat commission.

CESSION <- 0.25
ceded_premium <- CESSION * PREMIUM
qs <- with_premium_rate(quota_share("QS 25%", CESSION), 1, PREMIUM)
qs_ceded <- tower_on_grid(reinsurance_tower(list(qs)), frequency, claims, POINTS)$ceded[[1]]
risk_premium <- risk_loaded_price(qs_ceded, TAIL, cost_of_capital = RETURN)$premium
technical <- 1 - risk_premium / ceded_premium - 0.02 - 0.015 # less the reinsurer's expenses and brokerage
flat <- with_ceding_commission(qs, technical)

COMMISSION <- c(0.40, 0.25) # 40% at a loss ratio of 45% or less, 25% at 65% or more
LOSS_RATIO <- c(0.45, 0.65)
expected <- tower_on_grid(reinsurance_tower(list(with_sliding_scale(qs, COMMISSION, LOSS_RATIO))),
                          frequency, claims, POINTS)$expected_ceding_commission[[1]]
shift <- technical - expected / ceded_premium
slide <- with_sliding_scale(qs, COMMISSION + shift, LOSS_RATIO)
cat(sprintf("technical commission %.1f%%; the scale runs from %.1f%% to %.1f%%\n",
            100 * technical, 100 * (COMMISSION[1] + shift), 100 * (COMMISSION[2] + shift)))
## technical commission 41.0%; the scale runs from 46.2% to 31.2%
outcomes <- (seq_along(gross@probs) - 1) * gross@step
for (label in c("flat", "sliding")) {
  terms <- if (label == "flat") flat else slide
  result <- ceded_premium - ceding_commission_for(terms, CESSION * outcomes) - CESSION * outcomes
  m <- sum(result * gross@probs)
  s <- sqrt(sum((result - m)^2 * gross@probs))
  cat(sprintf("reinsurer, %-7s: expected result %.2f, sd %.2f\n", label, m, s))
}
## reinsurer, flat   : expected result 2.44, sd 4.98
## reinsurer, sliding: expected result 2.44, sd 3.66
ratios <- c(0.4, 0.5, 0.6, 0.7, 0.8)
scale_t <- data.frame(
  `loss ratio` = sprintf("%.0f%%", 100 * ratios),
  flat = ceding_commission_for(flat, ratios * ceded_premium) / ceded_premium,
  sliding = ceding_commission_for(slide, ratios * ceded_premium) / ceded_premium,
  check.names = FALSE
)
gt(scale_t, rowname_col = "loss ratio") |>
  tab_header("Ceding commission by ceded loss ratio", "Share of the ceded premium") |>
  fmt_percent(columns = c("flat", "sliding"), decimals = 1)
Ceding commission by ceded loss ratio
Share of the ceded premium
flat sliding
40% 41.0% 46.2%
50% 41.0% 42.5%
60% 41.0% 35.0%
70% 41.0% 31.2%
80% 41.0% 31.2%

The sliding commission falls from 46.2% to 31.2% as the loss ratio rises from 45% to 65%. The expected result of the reinsurer is 2.44 for both commissions, but its standard deviation falls from 4.98 to 3.66: in a bad year it pays less commission, so the cedant takes back a part of the bad years. The sliding scales of the price guide show how much more commission a reinsurer can give for that. map_grid() turns each gross outcome into the cost of the cedant in that outcome:

for (label in c("QS 25% flat", "QS 25% slide")) {
  terms <- if (label == "QS 25% flat") flat else slide
  net_cost <- map_grid(gross, function(x) {
    (1 - CESSION) * x + ceded_premium - ceding_commission_for(terms, CESSION * x)
  })$grid
  record(label, mean(qs_ceded), ceded_premium * (1 - technical), mean(net_cost) - mean(gross),
         GROSS_CAPITAL - cedant_capital(net_cost))
}
structure_table(c("QS 25% flat", "QS 25% slide"), "Quota share, flat and sliding commission")
Quota share, flat and sliding commission
Millions; value = 16% of the capital saved, minus the cost
ceded premium cost saved cost % value
QS 25% flat 12.32 14.76 2.44 16.34 14.9% 0.18
QS 25% slide 12.32 14.76 2.44 13.94 17.5% −0.21

Here “premium” is the ceded premium minus the expected commission, and the cost is the expected result of the reinsurer for both commissions. The flat commission releases 16.34 of capital, the scale only 13.94: under the scale, the cedant still pays for its bad years through a lower commission.

Reinstatements

A real excess of loss layer limits how often it pays in a year. With one reinstatement, the 10x5 layer pays a maximum of 20 a year. A paid reinstatement charges extra premium when a loss uses the limit, so a part of the price comes after the losses. Annual terms need the claims year by year, so this chunk simulates 10,000 years with simulate_events() and applies the layer with apply_tower().

Both versions have the expected premium of the 10x5 technical premium above. When the reinstatement is free, all of it is deposit. When it is paid at 100%, the deposit is smaller and the expected reinstatement premium supplies the rest.

simulated <- simulate_events(frequency, claims, N, 7)
technical_xl <- xl_quotes[["XL 10x5"]]$quote$premium

cedant_cost <- function(deposit, rates) {
  # Gross and the cedant's cost (net loss, deposit and reinstatement premium) in each simulated year.
  cover <- xol_layer("10x5", 10, 5, premium = deposit, reinstatement_rates = rates)
  years <- draw_matrix(apply_tower(reinsurance_tower(list(cover)), simulated))
  # the columns: gross, ceded, net, reinstatement premium
  list(gross = sampled(years[, 1]), cost = sampled(years[, 3] + deposit + years[, 4]),
       reinstatement = mean(years[, 4]))
}

rp <- cedant_cost(technical_xl, 1)$reinstatement
paid_deposit <- technical_xl / (1 + rp / technical_xl) # the same expected premium, part paid after losses
reinstated <- do.call(rbind, lapply(list(list("free", technical_xl, 0), list("paid at 100%", paid_deposit, 1)),
                                    function(version) {
  r <- cedant_cost(version[[2]], version[[3]])
  data.frame(reinstatement = version[[1]], deposit = version[[2]], `expected reinstatement premium` = r$reinstatement,
             `capital saved` = cedant_capital(r$gross) - cedant_capital(r$cost), check.names = FALSE)
}))
gt(reinstated, rowname_col = "reinstatement") |>
  tab_header("The 10x5 layer with one reinstatement", "Millions; the same expected premium in both rows") |>
  fmt_number(columns = c("deposit", "expected reinstatement premium", "capital saved"), decimals = 2)
The 10x5 layer with one reinstatement
Millions; the same expected premium in both rows
deposit expected reinstatement premium capital saved
free 13.07 0.00 12.06
paid at 100% 8.19 4.88 8.74

Without an annual limit, the layer saves about 22 of capital (22.64 on the grid, 22.26 on these simulated years). The annual limit cuts this to 12.06, because the losses of the layer exceed 20 in the worst years. A paid reinstatement cuts it to 8.74: the cedant pays the reinstatement premium in the same years that it wants protection.

The two rows compare only the two versions. A layer with an annual limit pays less than the unlimited 10x5, so its price is lower, and the decision table below omits them. The reinstatements section of the price guide prices them.

The decision

The structures in order of value, best first:

value <- vapply(ROWS, function(r) HURDLE * r[["saved"]] - r[["cost"]], 0)
order_by_value <- names(ROWS)[order(-value)]
structure_table(order_by_value, "The six structures in order of value", drop = c("ceded", "premium"))
The six structures in order of value
Millions; value = 16% of the capital saved, minus the cost
cost saved cost % value
QS 25% flat 2.44 16.34 14.9% 0.18
QS 25% slide 2.44 13.94 17.5% −0.21
XL 10x5 4.61 22.64 20.3% −0.98
XL 15x10 4.03 17.88 22.6% −1.17
XL 20x5 6.59 29.73 22.2% −1.84
XL 23x2 9.61 42.89 22.4% −2.75

The last line reprices 10x5 with the loads of the quota share (2% expenses and 1.5% brokerage, not 15%) to show how much of the difference they explain.

cat(sprintf("buy: %s\n", order_by_value[1]))
## buy: QS 25% flat
xl <- xl_quotes[["XL 10x5"]]
cheap <- technical_quote(risk_loaded_price(xl$ceded, TAIL, cost_of_capital = RETURN),
                         expenses = 0.02, brokerage = 0.015, limit = 10)
cost <- cheap$premium - mean(xl$ceded)
cat(sprintf("XL 10x5 at the quota share's loads: premium %.2f, cost %.2f, value %.2f\n",
            cheap$premium, cost, HURDLE * ROWS[["XL 10x5"]][["saved"]] - cost))
## XL 10x5 at the quota share's loads: premium 11.51, cost 3.05, value 0.57

With these inputs, the cedant should buy the 25% quota share at a flat commission. It is the only structure that releases capital for less than the 16% that the owners charge. The sliding scale gives back a part of that relief.

Most of the difference from the excess of loss layers is the frictional load: the layers carry 15% for expenses and brokerage, the quota share 3.5%. At the loads of the quota share, 10x5 has a value of 0.57, the best of all. The decision depends on the real charge of the excess of loss market. Get a firm quote for 10x5 before you sign the quota share.

A higher cost of capital for the cedant, or a TVaR standard that weights the tail more, favours the excess of loss. Repeat the comparison with your own numbers. Do not reuse this result for another cedant. What the reinsurer decides shows the other side.

Part 3. The checklist

10. Ten steps from data to a quote

Step Call Check Usual mistake
1. Premium at today’s rate level, losses trended rate_level(), trend_fit(), trend_factor() On-level factors decrease toward recent years Trending premium and losses with the same factor, or forgetting the rate changes
2. Develop losses to ultimate triangle(), chain_ladder(). For large losses: development_pattern_from_history(), trend_large_losses() Compare with bornhuetter_ferguson() on the youngest years Developing a layer with ground-up factors (use excess_pattern())
3. Severity and frequency severity_fit(), goodness_of_fit(), poisson_count(), negative_binomial_count(), truncated_distribution() Fit above the reporting threshold. Censor claims at their policy limit A ground-up severity with a count of claims above the threshold, or a Poisson count when the variance is larger than the mean
4. Aggregate distribution compound_distribution(method = "fft"), audit_grid() g@report$aliasing_error, g@report$tail_mass A grid too short for the tail
5. Contract terms xol_layer(), reinsurance_tower(), then tower_on_grid() or apply_tower() on_points Annual terms (reinstatements, aggregate limits) on the grid. Then net is NULL, so simulate and use apply_tower()
6. Expected loss two ways, blended Experience: burning_cost(). Exposure: risk_profile(), mbbefd(). Blend: limited_fluctuation_credibility(), credibility_weighted() The two estimates are in a plausible range of each other Full credibility for a layer with a small number of claims
7. Capital standard distortion("tvar", p), portfolio_assets(), assets_for_epd() The same standard for all options that you compare Comparing one option on VaR with another on TVaR
8. Distortion calibrated calibrate_portfolio(), calibrate_distortion() The calibrated book earns its target return Calibrating to a premium on uncapped losses, then pricing with capped assets
9. Allocation natural_price(), capital_allocation() Allocations add up to the total of the book Comparing returns by line under different methods
10. Quote and sensitivity technical_quote(), implied_quote() Rate on line and return at the market price Quoting the technical premium without a comparison with the market rate on line for similar layers

The submission evaluation notebook (Python) runs these steps on a synthetic submission.

The template below runs the ten steps for one excess of loss layer. It needs two files of your own:

  • my_premium.csv, one row for each accident year: year, earned_premium.
  • my_losses.csv, one row for each claim and development age: claim_id, accident_year, development (in months: 12, 24, …) and incurred (cumulative). List each claim at each age up to the latest. When a value did not change, repeat it. If you do not, the summed triangle is wrong.

Change each value marked “yours” and check the output of each step. The tests do not run the template.

library(prospicio)

VALUATION <- 2026; FUTURE <- 2027.5; LOSS_TREND <- 0.05   # yours: valuation date, mid-point of the period priced, trend
FUTURE_PREMIUM <- 120                                     # yours: subject premium of the period priced
THRESHOLD <- 1; POLICY_LIMIT <- 25                        # yours: reporting threshold of large claims, policy limit
ATTACHMENT <- 5; LIMIT <- 10                              # the layer priced
premium <- read.csv("my_premium.csv")
losses <- read.csv("my_losses.csv")
years <- premium$year
COUNT_IBNR <- rep(1, length(years))                       # yours: large-claim count development factor by year

# 1. Premium at today's rate level (the losses are trended in step 2)
on_level <- premium$earned_premium * vapply(years, function(y) {
  rate_level(c(2023, 2025), c(0.05, 0.03), start = y, end = y + 1, term = 1)$on_level_factor  # yours
}, 0)

# 2. Develop to ultimate: the ground-up triangle, and each large claim's IBNER from the claims' own histories
cells <- stats::aggregate(incurred ~ accident_year + development, data = losses, FUN = sum)
tri <- triangle(cells, origin = "accident_year", development = "development", columns = "incurred")
cl <- chain_ladder(tri, "incurred")
print(round(cl@ultimate / on_level, 3))                   # ultimate loss ratios
losses$age <- losses$development / 12 - 0.5               # years since a mid-year accident
ibner <- development_pattern_from_history(
  data.frame(id = losses$claim_id, age = losses$age, amount = losses$incurred), ages = sort(unique(losses$age))
)
latest <- losses[order(losses$development), ]
latest <- latest[!duplicated(latest$claim_id, fromLast = TRUE), ]
prepared <- trend_large_losses(                           # developed (IBNER) and trended
  data.frame(id = latest$claim_id, accident = latest$accident_year + 0.5, amount = latest$incurred),
  rate = LOSS_TREND, to = FUTURE, threshold = THRESHOLD, valuation = VALUATION, development = ibner
)
complete_above <- prepared$complete_above                 # every year is complete above this trended size

# 3. Severity of the large claims above that size, and their yearly count at next year's premium
trended <- prepared$losses$trended[match(latest$claim_id, prepared$losses$id)]
large <- data.frame(year = latest$accident_year, size = trended,
                    capped = latest$incurred >= POLICY_LIMIT)[trended > complete_above, ]   # capped: censored
floors <- rep(complete_above, nrow(large))
fit <- severity_fit("lognormal", large$size, reporting_thresholds = floors, censored = large$capped)
gof <- goodness_of_fit(fit$distribution, large$size, reporting_thresholds = floors, censored = large$capped)
print(fit$parameters)
cat("largest gap to the data:", round(gof$max_distance, 3), "\n")
counts <- FUTURE_PREMIUM * COUNT_IBNR * as.vector(table(factor(large$year, levels = years))) / on_level
frequency <- negative_binomial_count_from_mean_variance(mean(counts), max(var(counts), 1.01 * mean(counts)))
severity <- truncated_distribution(fit$distribution, lower = complete_above)   # the count is of claims above it

# 4. Aggregate distribution, with the grid chosen and checked
audit <- audit_grid(frequency, severity)
claims <- discretize(severity, audit$step, round(POLICY_LIMIT / audit$step) + 1, "rounding")   # capped at the limit
agg <- compound_distribution(frequency, claims, 2^audit$log2, method = "fft")
stopifnot(agg@report$aliasing_error < 1e-6, agg@report$tail_mass < 1e-6)   # else more points or a larger step

# 5. Contract terms
tower <- reinsurance_tower(list(xol_layer("layer", LIMIT, ATTACHMENT)))
layer_loss <- tower_on_grid(tower, frequency, claims, 2^audit$log2)$ceded[["layer"]]

# 6. Expected loss two ways, blended by credibility
burn <- burning_cost(prepared, tower, years, premium = on_level, development = COUNT_IBNR)
experience <- burn$loss_cost[1] * FUTURE_PREMIUM          # the layer's loss cost on on-level premium, at next year's
exposure <- mean(layer_loss)                              # yours: a stand-in; use a risk_profile() or an exposure curve
z <- limited_fluctuation_credibility(sum(large$size > ATTACHMENT),
                                     credibility_standard(0.90, 0.05)[["frequency"]])
blended <- credibility_weighted(experience, z, exposure)
cat(sprintf("experience %.3f, exposure %.3f, credibility %.2f, blended %.3f\n", experience, exposure, z, blended))

# 7 to 9. Capital standard and price of risk (for a book: calibrate_portfolio() and natural_price(), section 8)
TAIL <- distortion("tvar", 0.99)
risk <- risk_loaded_price(layer_loss, TAIL, cost_of_capital = 0.10)
scale <- blended / mean(layer_loss)                       # moves the modelled layer loss to the blended estimate

# 10. Quote and sensitivity. Scaling loss, premium and assets together leaves every return unchanged.
quote <- technical_quote(risk, expenses = 0.05, brokerage = 0.10, limit = LIMIT)
cat(sprintf("technical premium %.3f, rate on line %.1f%%\n", quote$premium * scale,
            100 * quote$premium * scale / LIMIT))
for (market in c(0.8, 1, 1.2)) {
  cat(sprintf("at %.0f%% of technical: return on capital %.1f%%\n", 100 * market,
              100 * implied_quote(quote, market * quote$premium)$return_on_capital))
}

Replace these three simplifications in the template:

  1. The exposure estimate is the same model that the experience fits, so the credibility blend has nothing independent to blend. Use an exposure rating instead: a risk_profile() with an exposure curve, as in that guide.
  2. The count development factors are 1 by default, correct only for mature years.
  3. The layer is developed with the IBNER of each claim, not with ground-up factors.

Where to go next

Appendix: terms

  • Loss distribution: what a cover can pay in a year, with the probability of each amount. Its mean is the expected loss. Its coefficient of variation (CV) is the standard deviation divided by the mean.
  • VaR (value at risk) at 99%: the loss that only 1% of years exceed.
  • TVaR (tail value at risk) at 99%: the average loss in the worst 1% of years. It is never smaller than the VaR.
  • Assets: the money available to pay claims. A capital standard sets the amount, for example the 99% TVaR of the loss. In a year with a larger loss, the company defaults and the policyholders bear the rest (limited liability).
  • Premium and margin: the premium pays part of the assets. The margin is the premium minus the expected loss, the reward of the owners.
  • Capital: assets minus premium, supplied by the owners. Cost of capital: the return that the owners want on it, here 10% a year.
  • Distortion: a rule that prices a loss. It gives bad outcomes more weight than their probability (section 5).
  • Allocation: a split of the premium or capital of a book between its units.
  • Cedant: an insurer that buys reinsurance.
  • Layer: the part of each loss that an excess of loss contract pays, written limit x attachment (also called the retention). The layer 10x5 pays the part of each loss between 5 and 15.
  • Risk premium: the expected loss plus the margin for capital. Technical premium: the risk premium plus expenses and brokerage. Rate on line: the premium of a layer divided by its limit.
  • On-level premium: past premium at the rates of today. IBNR: claims incurred but not yet reported. A censored claim is capped by a policy limit: you know only that its true size is at least the cap.

The glossary of the price guide has more reinsurance words.