Pricing Insurance Risk, Part I: risk measures in prospicio
pir-risk-measures.RmdRendered from docs/guides/pir-risk-measures.qmd.
The code runs each time the site is built, so the output below is
current.
Part I of Stephen Mildenhall and John Major’s Pricing Insurance Risk: Theory and Practice (Wiley, 2022) is chapters 3 to 7. It measures risk before it prices risk: how to represent a risk, what VaR and TVaR are, which properties a risk measure needs, and how spectral (distortion) risk measures join these ideas. This guide runs those chapters in prospicio and shows the book’s value beside each number it prints.
The book’s text and tables belong to the authors, and this guide explains them in new words. Table, example and exercise numbers are the book’s. Related guides:
- Part II, portfolio pricing: Pricing Insurance Risk, Part II.
- The book’s case studies, priced by five distortions and allocated to units: the case studies guide.
- The same method on a ten-year example: CAS Monograph 15 reproduced.
This is the R twin of the Python guide pir-risk-measures.md.
It has the same sections, examples and numbers, because the R package
calls the same Rust code as the Python package. The text under each R
chunk is the output of that chunk.
R/prospicio/tests/test-guides.R runs the chunks in order
and requires each chunk to print exactly that text. To render the page,
install the R package (remotes::install_github, see
R/prospicio/bootstrap.R) and run
quarto render docs/guides/pir-risk-measures.qmd.
library(prospicio)1. Representing a risk: the Simple Discrete Example
Chapter 3 represents a risk as a random variable. Its expected value is a sum of outcomes times probabilities, and also the area under the survival function (the Lee diagram’s horizontal slices).
The running example has two independent policies, losing 0, 8 or 10 and 0, 1 or 90, each with probabilities 1/2, 1/4 and 1/4. The total has nine values with probabilities in sixteenths, so sixteen equally likely draws represent it exactly:
library(gt)
OUTCOMES <- c(0, 1, 8, 9, 10, 11, 90, 98, 100)
SIXTEENTHS <- c(4, 2, 2, 1, 2, 1, 2, 1, 1)
x16 <- rep(OUTCOMES, SIXTEENTHS)
discrete <- sampled(x16)
# E[X] as outcome times probability, and as the sum of S(x_j) times the step to x_(j+1).
two_forms <- function(xs, probs) {
c(sum(xs * probs), sum((1 - cumsum(probs))[-length(xs)] * diff(xs)))
}
probs <- SIXTEENTHS / 16
two_forms_table <- data.frame(
case = c("E[X], Table 3.2", "E[X ^ 80], Table 3.4", "E[X + 100], Table 3.3"),
rbind(two_forms(OUTCOMES, probs), two_forms(pmin(OUTCOMES, 80), probs),
two_forms(c(0, OUTCOMES + 100), c(0, probs))),
prospicio = c(mean(discrete), mean(sampled(pmin(x16, 80))), mean(sampled(x16 + 100))),
book = c(27.25, 23.625, 127.25)
)
names(two_forms_table)[2:3] <- c("by outcome", "by slice")
gt(two_forms_table, rowname_col = "case") |>
tab_header("The expected value, two ways",
"By outcome and by survival slice, then prospicio's mean and the book's value") |>
fmt_number(columns = c("by outcome", "by slice", "prospicio", "book"), decimals = 3, drop_trailing_zeros = TRUE)| The expected value, two ways | ||||
| By outcome and by survival slice, then prospicio's mean and the book's value | ||||
| by outcome | by slice | prospicio | book | |
|---|---|---|---|---|
| E[X], Table 3.2 | 27.25 | 27.25 | 27.25 | 27.25 |
| E[X ^ 80], Table 3.4 | 23.625 | 23.625 | 23.625 | 23.625 |
| E[X + 100], Table 3.3 | 127.25 | 127.25 | 127.25 | 127.25 |
A cap at assets of 80 changes only the outcomes. To add 100 to every outcome, first add a zero outcome (the book’s Step (1)): the survival form integrates from zero and must include the slice from 0 to 100.
In prospicio, a sampled() holds simulations or equally
likely scenarios, a discrete_distribution() values and
probabilities, and a grid_distribution() an evenly spaced
grid, such as the output of an FFT. All three have mean(),
quantile() and TVaR().
risk_measure(x, d) prices a sampled() or a
grid_distribution() with a distortion d.
2. Quantiles and VaR
Chapter 4 defines the p quantile as any x with P(X < x) <= p <= P(X <= x). Where the distribution function jumps, there is one quantile. Where it is flat at p, there is a range of quantiles, and VaR is the lower end. For a fair die (Exercise 38), the 0.1 quantile is 1, and at p = 1/6 every value in [1, 2] is a quantile:
die <- discrete_distribution(1:6, rep(1 / 6, 6))
cat("die: 0.1 quantile", VaR(die, 0.1), " 1/6 quantiles", VaR(die, 1 / 6),
"to", quantile_upper(die, 1 / 6), " (book 1; any value in [1, 2])\n")## die: 0.1 quantile 1 1/6 quantiles 1 to 2 (book 1; any value in [1, 2])
Exercise 49 has ten equally likely outcomes 0, 1, 1, 1, 2, 3, 4, 8, 12 and 25. Its 0.4 quantiles are [1, 2], so its VaR is 1:
ex49 <- discrete_distribution(c(0, 1, 2, 3, 4, 8, 12, 25), c(0.1, 0.3, rep(0.1, 6)))
ps <- c(0.4, 0.41, 0.85, 0.95)
BOOK_VAR <- c(1, 2, NA, 25) # the book: 0.4 quantiles [1, 2]; 25 for any p > 0.9
var_table <- data.frame(
p = sprintf("%.2f", ps),
VaR = sapply(ps, function(p) VaR(ex49, p)),
`upper quantile` = sapply(ps, function(p) quantile_upper(ex49, p)),
`book VaR` = BOOK_VAR,
check.names = FALSE
)
gt(var_table, rowname_col = "p") |>
tab_header("Exercise 49: VaR and the upper quantile") |>
fmt_number(columns = c("VaR", "upper quantile", "book VaR"), decimals = 1) |>
sub_missing(missing_text = "")| Exercise 49: VaR and the upper quantile | |||
| VaR | upper quantile | book VaR | |
|---|---|---|---|
| 0.40 | 1.0 | 2.0 | 1.0 |
| 0.41 | 2.0 | 2.0 | 2.0 |
| 0.85 | 12.0 | 12.0 | |
| 0.95 | 25.0 | 25.0 | 25.0 |
The book gives 25 for any p > 0.9.
VaR() gives the lower quantile, which is VaR in the
book’s sense, and quantile_upper() the upper end of the
range. They are equal where the distribution function jumps across
p. quantile() also gives the lower quantile, on every
distribution. In this guide, VaR is always the lower quantile.
3. Return periods and the PML of a hurricane model
VaR at p is also the 1 / (1 - p) year loss: the 99% VaR is the 100-year loss, and the 99.6% VaR is the 250-year loss (Table 4.1). A probable maximum loss (PML) is either the annual aggregate loss at that return period (an aggregate VaR) or the loss from the largest single event (an occurrence PML).
Example 54 compares the two for US hurricanes: Poisson counts at 1.74 landfalls a year, and a lognormal severity with mean USD 5 billion and sigma 2.58. Table 4.3 gives, by return period, the occurrence PML, the severity quantile, the aggregate VaR by FFT and the book’s quick estimate of the aggregate VaR from the severity alone (Eq. (4.5): the severity quantile at 1 - (1 - p) / 1.74). Each year’s second row is the book’s value, in USD millions:
SIGMA <- 2.58
RATE <- 1.74
hurricane <- lognormal(log(5000) - SIGMA^2 / 2, SIGMA)
annual <- compound_distribution(poisson_count(RATE), discretize(hurricane, 20, 2^21, "rounding"), 2^21,
method = "fft")
BOOK_43 <- rbind( # Table 4.3: occurrence PML, severity VaR, aggregate VaR, estimated VaR
`2` = c(348, 179, 420, 763), `5` = c(3350, 1572, 3940, 3971), `10` = c(9783, 4892, 11080, 10467),
`20` = c(23420, 12490, 25620, 24107), `50` = c(62630, 35870, 66180, 63256),
`100` = c(121162, 72473, 125760, 121714), `250` = c(268049, 167935, 273900, 268492),
`1000` = c(787463, 520108, 794820, 787752)
)
return_periods <- as.numeric(rownames(BOOK_43))
pml <- do.call(rbind, lapply(return_periods, function(yrs) {
p <- 1 - 1 / yrs
ours <- c(occurrence_pml(poisson_count(RATE), hurricane, 1 / yrs)$loss, quantile(hurricane, p),
quantile(annual, p), quantile(hurricane, 1 - (1 - p) / RATE))
unname(rbind(ours, BOOK_43[as.character(yrs), ]))
}))
pml_table <- data.frame(
c(rbind(paste(return_periods, "years"), paste(return_periods, "years, book"))),
pml
)
names(pml_table) <- c("return period", "occurrence PML", "severity VaR", "aggregate VaR", "estimate")
gt(pml_table, rowname_col = "return period") |>
tab_header("Table 4.3: return periods of a hurricane model", "USD millions") |>
fmt_number(columns = c("occurrence PML", "severity VaR", "aggregate VaR", "estimate"), decimals = 0)| Table 4.3: return periods of a hurricane model | ||||
| USD millions | ||||
| occurrence PML | severity VaR | aggregate VaR | estimate | |
|---|---|---|---|---|
| 2 years | 348 | 179 | 420 | 763 |
| 2 years, book | 348 | 179 | 420 | 763 |
| 5 years | 3,350 | 1,572 | 3,940 | 3,971 |
| 5 years, book | 3,350 | 1,572 | 3,940 | 3,971 |
| 10 years | 9,783 | 4,892 | 11,080 | 10,467 |
| 10 years, book | 9,783 | 4,892 | 11,080 | 10,467 |
| 20 years | 23,420 | 12,490 | 25,620 | 24,107 |
| 20 years, book | 23,420 | 12,490 | 25,620 | 24,107 |
| 50 years | 62,630 | 35,870 | 66,180 | 63,256 |
| 50 years, book | 62,630 | 35,870 | 66,180 | 63,256 |
| 100 years | 121,162 | 72,473 | 125,760 | 121,714 |
| 100 years, book | 121,162 | 72,473 | 125,760 | 121,714 |
| 250 years | 268,049 | 167,935 | 273,900 | 268,492 |
| 250 years, book | 268,049 | 167,935 | 273,900 | 268,492 |
| 1000 years | 787,463 | 520,108 | 794,820 | 787,752 |
| 1000 years, book | 787,463 | 520,108 | 794,820 | 787,752 |
Every value agrees to the printed unit. The grid has a step of USD 20 million and 2^21 points; all the book’s aggregate VaRs are multiples of 20.
One printed parameter is wrong:
cat(sprintf("meanlog %.3f (in millions; %.3f in dollars)\n", log(5000) - SIGMA^2 / 2,
log(5000) - SIGMA^2 / 2 + log(1e6)))## meanlog 5.189 (in millions; 19.005 in dollars)
The book prints mu as 21.315, but a mean of USD 5 billion with sigma 2.58 needs 19.005 in dollars, and only that value reproduces the table’s severity column (a median of 179 million). Build the severity from its mean and sigma.
The figure plots the table:
library(ggplot2, exclude = "layer") # keeps prospicio's layer()
years <- as.numeric(rownames(BOOK_43))
probs <- 1 - 1 / years
pml <- rbind(
data.frame(years, loss = quantile(hurricane, probs), series = "severity VaR"),
data.frame(years, loss = sapply(years, function(y) occurrence_pml(poisson_count(RATE), hurricane, 1 / y)$loss),
series = "occurrence PML"),
data.frame(years, loss = quantile(annual, probs), series = "aggregate VaR")
)
pml$series <- factor(pml$series, levels = c("severity VaR", "occurrence PML", "aggregate VaR"))
ggplot(pml, aes(years, loss, colour = series, group = series)) +
geom_line() +
geom_point() +
scale_colour_manual(values = c("grey75", scales::hue_pal()(2))) +
scale_x_log10() + scale_y_log10() +
labs(x = "return period (years)", y = "loss (USD millions)", colour = NULL,
title = "Example 54: hurricane losses by return period") +
theme(legend.position = "top")The occurrence PML is always below the aggregate VaR, and close to it at long return periods, because a bad hurricane year is one bad hurricane. For the same reason, the quick estimate is good in the tail (2% off at 1,000 years) and poor for frequent events (82% off at 2 years).
4. VaR is not subadditive
A risk measure is subadditive if the risk of a sum never exceeds the sum of the risks. The book shows three ways VaR fails this:
- Dependence. Risks that are large in different scenarios can give a sum whose VaR exceeds the sum of their VaRs.
- Skewness, with no dependence. The sum of two independent exponentials with mean 1 is a gamma with shape 2. Below p = 0.7, its VaR is more than twice the VaR of one exponential (Table 4.4).
- A very thick tail. For a Pareto with tail index below 1 (no mean), VaR fails at every high enough p, because one large loss dominates the sum.
Table 4.4 checks the second way:
one <- gamma_distribution(1, 1)
two <- gamma_distribution(2, 1)
BOOK_44 <- c(`0.5` = -0.2921, `0.6` = -0.1897, `0.7` = -0.03127, `0.8` = 0.2246, `0.9` = 0.7155,
`0.95` = 1.248, `0.99` = 2.572, `0.999` = 4.582)
ps <- as.numeric(names(BOOK_44))
sum_table <- data.frame(
p = names(BOOK_44),
`2 VaR(X1)` = unname(2 * quantile(one, ps)),
`VaR(X1 + X2)` = unname(quantile(two, ps)),
difference = unname(2 * quantile(one, ps) - quantile(two, ps)),
book = unname(BOOK_44),
check.names = FALSE
)
gt(sum_table, rowname_col = "p") |>
tab_header("Table 4.4: VaR of a sum against the sum of VaRs",
"Exponential X1 with mean 1; X1 + X2 is a gamma with shape 2") |>
fmt_number(columns = c("2 VaR(X1)", "VaR(X1 + X2)"), decimals = 3) |>
fmt_number(columns = "difference", decimals = 4) |>
fmt_number(columns = "book", decimals = 5, drop_trailing_zeros = TRUE)| Table 4.4: VaR of a sum against the sum of VaRs | ||||
| Exponential X1 with mean 1; X1 + X2 is a gamma with shape 2 | ||||
| 2 VaR(X1) | VaR(X1 + X2) | difference | book | |
|---|---|---|---|---|
| 0.5 | 1.386 | 1.678 | −0.2921 | −0.2921 |
| 0.6 | 1.833 | 2.022 | −0.1897 | −0.1897 |
| 0.7 | 2.408 | 2.439 | −0.0313 | −0.03127 |
| 0.8 | 3.219 | 2.994 | 0.2246 | 0.2246 |
| 0.9 | 4.605 | 3.890 | 0.7155 | 0.7155 |
| 0.95 | 5.991 | 4.744 | 1.2476 | 1.248 |
| 0.99 | 9.210 | 6.638 | 2.5720 | 2.572 |
| 0.999 | 13.816 | 9.233 | 4.5821 | 4.582 |
The differences agree with Table 4.4 to its four significant figures. (In the printed table, the difference for the 0.8 row is one line too low, under 0.999. The columns to its left show which value belongs to which row.) In the figure, twice the exponential VaR crosses the gamma VaR near p = 0.7:
grid <- seq(0.5, 0.999, length.out = 60)
gap <- rbind(
data.frame(p = grid, var = 2 * quantile(one, grid), series = "2 VaR(X1)"),
data.frame(p = grid, var = quantile(two, grid), series = "VaR(X1 + X2)")
)
ggplot(gap, aes(p, var, colour = series)) +
geom_line() +
labs(x = "probability level p", y = "VaR", colour = NULL,
title = "Table 4.4: VaR of a sum against the sum of VaRs") +
theme(legend.position = "top")The worst VaR of a sum: the Rearrangement Algorithm
With known marginals and unknown dependence, the worst possible VaR of the sum is a useful bound. The book’s Rearrangement Algorithm (RA, Puccetti and Rüschendorf) finds it numerically:
- Take the top 1 - p of each marginal.
- Arrange each column in the opposite order to the sum of the other columns.
- Repeat step 2 until the smallest row sum stops increasing.
Exercise 59 asks for the worst 99% VaR of three lognormals with mean 10 and CVs 1, 2 and 3, using 40 points of each at and above its 99th percentile:
STRATA <- 40
top <- sapply(c(1, 2, 3), function(cv) {
quantile(lognormal_from_mean_cv(10, cv), 0.99 + 0.01 * (0:(STRATA - 1)) / STRATA)
})
# Puccetti and Rueschendorf's rearrangement: each column counter-monotonic to the rest,
# from a start with column j rotated by shift * j places.
rearrange <- function(x, shift, eps = 1e-6) {
n <- nrow(x)
for (j in seq_len(ncol(x))) x[, j] <- x[(seq_len(n) - 1 - shift * (j - 1)) %% n + 1, j]
best <- -Inf
repeat {
for (j in seq_len(ncol(x))) {
rest <- rowSums(x) - x[, j]
x[order(rest), j] <- sort(x[, j], decreasing = TRUE)
}
low <- min(rowSums(x))
if (low - best < eps) return(low)
best <- low
}
}
starts <- c(7, 13, 19)
worst <- data.frame(
quantity = c(paste0("99% VaR, CV ", 1:3), "comonotonic sum", paste0("worst VaR, start ", starts)),
prospicio = c(top[1, ], sum(top[1, ]), sapply(starts, function(s) rearrange(top, s))),
book = c(NA, NA, NA, 242.5, 352.8, 352.8, 352.8)
)
gt(worst, rowname_col = "quantity") |>
tab_header("Exercise 59: the worst 99% VaR of a sum") |>
fmt_number(columns = c("prospicio", "book"), decimals = 1) |>
sub_missing(missing_text = "")| Exercise 59: the worst 99% VaR of a sum | ||
| prospicio | book | |
|---|---|---|
| 99% VaR, CV 1 | 49.0 | |
| 99% VaR, CV 2 | 85.6 | |
| 99% VaR, CV 3 | 107.9 | |
| comonotonic sum | 242.5 | 242.5 |
| worst VaR, start 7 | 353.8 | 352.8 |
| worst VaR, start 13 | 353.6 | 352.8 |
| worst VaR, start 19 | 352.9 | 352.8 |
The comonotonic sum agrees with the book. The RA is a heuristic and the book does not give its start, so the worst VaR depends on the start: 352.9 to 353.8 here (column j rotated down by 7, 13 or 19 times j places, so the Python version prints the same numbers), against 352.8 in the book. The conclusion holds: the worst arrangement raises the 99% VaR of the sum by 45% over perfect positive dependence, so comonotonic VaR is not a worst case.
5. TVaR
TVaR at p is the average of the worst 1 - p of outcomes: the integral
of VaR from p to 1, divided by 1 - p. For a standard normal, the book
puts TVaR above VaR by 14.6% of the VaR at p = 0.99, 9% at 0.999 and
6.4% at 0.9999. Base R’s qnorm() and dnorm()
check these values:
ps <- c(0.99, 0.999, 0.9999)
excess_table <- data.frame(
p = as.character(ps),
`TVaR / VaR - 1` = dnorm(qnorm(ps)) / (1 - ps) / qnorm(ps) - 1,
book = c(0.146, 0.09, 0.064),
check.names = FALSE
)
gt(excess_table, rowname_col = "p") |>
tab_header("TVaR above VaR for a standard normal") |>
fmt_number(columns = c("TVaR / VaR - 1", "book"), decimals = 4, drop_trailing_zeros = TRUE)| TVaR above VaR for a standard normal | ||
| TVaR / VaR - 1 | book | |
|---|---|---|
| 0.99 | 0.1457 | 0.146 |
| 0.999 | 0.0896 | 0.09 |
| 0.9999 | 0.0644 | 0.064 |
Exercise 63 shows why the book prefers TVaR. A restaurant bill is lognormal with mean 2,500 and CV 0.2. On a regular night you pay it. On a Pot Luck night one of 25 diners, chosen at random, pays it, so you pay with probability 0.04. The 95% VaR of the Pot Luck bill is zero, so VaR cash is no cash; the 95% TVaR is 0.04 / 0.05 of the mean:
bill <- lognormal_from_mean_cv(2500, 0.2)
var95 <- quantile(bill, 0.95)
tvar95 <- var95 + (mean(bill) - lev(bill, var95)) / 0.05 # TVaR = VaR + E[(X - VaR)+] / (1 - p)
pot_luck <- 0.04 / 0.05 * mean(bill)
shortfall <- (mean(bill) - lev(bill, pot_luck)) / (1 - cdf(bill, pot_luck))
bill_table <- data.frame(
item = c("mu", "sigma", "regular night: VaR", "regular night: TVaR", "Pot Luck: TVaR",
"Pot Luck: P(enough)", "Pot Luck: shortfall when not"),
prospicio = unname(c(bill@meanlog, bill@sdlog, var95, tvar95, pot_luck, cdf(bill, pot_luck), shortfall)),
book = c(7.8044, 0.1980, 3395, 3699, 2000, 0.152, 624)
)
tbl <- gt(bill_table, rowname_col = "item") |>
tab_header("Exercise 63: the restaurant bill")
for (spec in list(list(1:2, 4), list(c(3, 4, 5, 7), 0), list(6, 3))) {
tbl <- fmt_number(tbl, columns = c("prospicio", "book"), rows = spec[[1]], decimals = spec[[2]])
}
tbl| Exercise 63: the restaurant bill | ||
| prospicio | book | |
|---|---|---|
| mu | 7.8044 | 7.8044 |
| sigma | 0.1980 | 0.1980 |
| regular night: VaR | 3,395 | 3,395 |
| regular night: TVaR | 3,699 | 3,699 |
| Pot Luck: TVaR | 2,000 | 2,000 |
| Pot Luck: P(enough) | 0.152 | 0.152 |
| Pot Luck: shortfall when not | 624 | 624 |
All seven values agree. TVaR = VaR + E[(X - VaR)+] / (1 - p), from
the quantile and the limited expected value (lev()). You
can also put the severity on a grid with discretize() and
call TVaR() on the grid.
For a discrete distribution, TVaR takes a fraction of the observation at the quantile (the book’s algorithm in Section 4.3.6). The conditional tail expectation (CTE), E[X | X >= VaR], takes the whole atom, so the two differ (Exercise 49 continued):
ten <- c(0, 1, 1, 1, 2, 3, 4, 8, 12, 25)
ten_s <- sampled(ten)
ps <- c(0.75, 0.85, 0.9)
var <- sapply(ps, function(p) VaR(ten_s, p))
cte_table <- data.frame(
p = as.character(ps),
VaR = var,
TVaR = sapply(ps, function(p) TVaR(ten_s, p)),
`book TVaR` = c(NA, (12 * (0.9 - 0.85) + 2.5) / (1 - 0.85), NA), # the book's TVaR on 0.8 <= p < 0.9
CTE = sapply(var, function(v) mean(ten[ten >= v])),
`book CTE` = c(15, 18.5, 18.5), # Exercise 49 continued
check.names = FALSE
)
gt(cte_table, rowname_col = "p") |>
tab_header("Exercise 49 continued: TVaR and CTE") |>
fmt_number(columns = "VaR", decimals = 1) |>
fmt_number(columns = c("TVaR", "book TVaR", "CTE"), decimals = 3) |>
fmt_number(columns = "book CTE", decimals = 1) |>
sub_missing(missing_text = "")| Exercise 49 continued: TVaR and CTE | |||||
| VaR | TVaR | book TVaR | CTE | book CTE | |
|---|---|---|---|---|---|
| 0.75 | 8.0 | 16.400 | 15.000 | 15.0 | |
| 0.85 | 12.0 | 20.667 | 20.667 | 18.500 | 18.5 |
| 0.9 | 12.0 | 25.000 | 18.500 | 18.5 | |
TVaR is continuous in p; CTE jumps at each observation, where the two are equal. Use TVaR: it is subadditive.
6. VaR, TVaR and EPD in the case studies
Section 4.3.7 tabulates VaR, TVaR and the EPD capital for the case studies, gross and net of reinsurance. The EPD capital is the assets at which the expected policyholder deficit E[(X - a)+] is a given share of the expected loss.
The Tame case has two gamma units with mean 50 and CVs 0.10 and 0.15.
The net book covers unit B with an aggregate 12.91 excess of 56.17 (its
80% to 99% quantiles, Table 7.3). The grid is aggregate’s,
with a step of 1/64 and 2^16 points, and the severity is renormalized as
in the case
studies guide. The EPD rows use the ratio 1 - p:
STEP <- 1 / 64
POINTS <- 2^16
LEVELS <- c(0.9, 0.95, 0.975, 0.99, 0.996, 0.999)
EPDS <- c(0.10, 0.05, 0.025, 0.01, 0.004, 0.001)
# A severity on aggregate's grid: rounded, the mass above the top spread by renormalizing.
discretize_renormalized <- function(severity) {
probs <- discretize(severity, STEP, 2 * POINTS, method = "rounding")@probs[seq_len(POINTS)]
grid_distribution(STEP, probs / sum(probs))
}
# The total of a portfolio as a grid.
total_grid <- function(book) {
probs <- numeric(round(max(book@totals) / STEP) + 1)
idx <- round(book@totals / STEP) + 1
probs <- tapply(book@probs, factor(idx, levels = seq_along(probs)), sum)
grid_distribution(STEP, ifelse(is.na(probs), 0, probs))
}
# The smallest assets with E[(X - a)+] at most ratio times E[X].
epd_assets <- function(grid, ratio) {
keep <- grid@probs > 0
one <- capital_portfolio(cbind(x = (seq_along(grid@probs) - 1)[keep] * STEP), probs = grid@probs[keep])
assets_for_epd(one, ratio)
}
# The net of an aggregate cover of limit excess of attachment, outcome by outcome.
net_of <- function(grid, limit, attachment) {
map_grid(grid, function(x) x - pmin(pmax(x - attachment, 0), limit))$grid
}
# VaR, TVaR and EPD assets by level, for each named grid.
capital_table <- function(rows) {
do.call(rbind, lapply(names(rows), function(name) {
g <- rows[[name]]
out <- rbind(sapply(LEVELS, function(p) quantile(g, p)), sapply(LEVELS, function(p) TVaR(g, p)),
sapply(EPDS, function(e) epd_assets(g, e)))
colnames(out) <- as.character(LEVELS)
data.frame(measure = paste0(name, c(", VaR", ", TVaR", ", EPD")), out, check.names = FALSE)
}))
}
a_unit <- discretize_renormalized(gamma_from_mean_cv(50, 0.10))
b_unit <- discretize_renormalized(gamma_from_mean_cv(50, 0.15))
b_net <- net_of(b_unit, 12.91, 56.17)
tame <- capital_portfolio(list(A = a_unit, B = b_unit))
tame_net <- capital_portfolio(list(A = a_unit, B = b_net))
tame_rows <- list(A = a_unit, B = b_unit, Total = total_grid(tame), `B net` = b_net, Net = total_grid(tame_net))
gt(capital_table(tame_rows), rowname_col = "measure") |>
tab_header("Tame case: VaR, TVaR and EPD capital", "Assets by level p; the EPD ratio is 1 - p") |>
fmt_number(columns = as.character(LEVELS), decimals = 1)| Tame case: VaR, TVaR and EPD capital | ||||||
| Assets by level p; the EPD ratio is 1 - p | ||||||
| 0.9 | 0.95 | 0.975 | 0.99 | 0.996 | 0.999 | |
|---|---|---|---|---|---|---|
| A, VaR | 56.5 | 58.5 | 60.3 | 62.4 | 64.3 | 66.9 |
| A, TVaR | 59.1 | 60.9 | 62.4 | 64.4 | 66.1 | 68.6 |
| A, EPD | 45.5 | 49.0 | 51.8 | 54.7 | 57.2 | 60.5 |
| B, VaR | 59.8 | 62.9 | 65.7 | 69.1 | 72.1 | 76.4 |
| B, TVaR | 64.0 | 66.7 | 69.2 | 72.3 | 75.2 | 79.2 |
| B, EPD | 46.5 | 51.1 | 54.8 | 59.0 | 62.7 | 67.6 |
| Total, VaR | 111.7 | 115.3 | 118.5 | 122.3 | 125.8 | 130.6 |
| Total, TVaR | 116.5 | 119.6 | 122.5 | 126.0 | 129.2 | 133.7 |
| Total, EPD | 90.6 | 97.4 | 102.5 | 108.0 | 112.6 | 118.5 |
| B net, VaR | 56.2 | 56.2 | 56.2 | 56.2 | 59.2 | 63.5 |
| B net, TVaR | 56.5 | 56.8 | 57.5 | 59.4 | 62.3 | 66.3 |
| B net, EPD | 45.3 | 49.2 | 52.0 | 54.2 | 55.4 | 56.1 |
| Net, VaR | 108.9 | 111.4 | 113.5 | 115.9 | 118.2 | 121.2 |
| Net, TVaR | 112.1 | 114.2 | 116.0 | 118.3 | 120.4 | 123.4 |
| Net, EPD | 89.7 | 96.0 | 100.5 | 104.8 | 108.2 | 112.3 |
Table 4.6 prints these values to the unit:
| Row | Book, gross A | B | Total | Book, net B | Net total |
|---|---|---|---|---|---|
| VaR | 56 58 60 62 64 67 | 60 63 66 69 72 76 | 112 115 119 122 126 131 | 56 56 56 56 59 64 | 109 111 113 116 118 121 |
| TVaR | 59 61 62 64 66 69 | 64 67 69 72 75 79 | 117 120 123 126 129 134 | 58 59 59 59 62 66 | 112 114 116 118 120 123 |
| EPD | 45 49 52 55 57 60 | 46 51 55 59 63 68 | 91 97 103 108 113 119 | 45 49 52 54 55 56 | 90 96 101 105 108 112 |
After rounding, every entry agrees (some of ours are on .5, such as the total EPD at 0.1%, 118.5 against 119) except the TVaR of net unit B at 90%, 95% and 97.5%, where the book prints 58, 59 and 59 and prospicio gives 56.5, 56.8 and 57.5.
prospicio’s values are correct, and the book’s own VaR row shows why. Net B is flat at 56.17 from its 80% to its 99% quantile, because the cover absorbs all loss between them. TVaR at 90% is therefore 56.17 plus the expected excess over 56.17, divided by 0.1, and that excess is only the part above the exhaustion point of the cover:
excess <- mean(b_net) - lev(b_net, 56.171875)
cat(sprintf("E[(B net - 56.17)+] = %.4f; TVaR 90%% = %.2f (book 58)\n", excess, 56.171875 + excess / 0.1))## E[(B net - 56.17)+] = 0.0323; TVaR 90% = 56.50 (book 58)
A printed 58 needs an expected excess of about 0.18. The net totals agree, so the error is only in the net unit’s column. Table 4.7 has the same error for net Cat (below). We read it as a defect in the book’s TVaR code for a unit with a large probability mass under a stop loss, at the levels where VaR is on that mass, not as a different convention.
The Cat/Non-Cat case has a gamma Non-Cat unit (mean 80, CV 0.15) and a lognormal Cat unit (mean 20, CV 1). An aggregate cover of 79.64 excess of 41.11 applies to Cat (its 90% to 99.5% quantiles). Example 53 gives a VaR heuristic for a thin-tailed unit added to a thick-tailed unit: the VaR of the total is approximately the mean of the thin unit plus the VaR of the thick unit (Table 4.2):
non_cat <- discretize_renormalized(gamma_from_mean_cv(80, 0.15))
cat_unit <- discretize_renormalized(lognormal_from_mean_cv(20, 1))
cat_net <- net_of(cat_unit, 79.64, 41.11)
cnc <- total_grid(capital_portfolio(list(Cat = cat_unit, NonCat = non_cat)))
cnc_net <- total_grid(capital_portfolio(list(Cat = cat_net, NonCat = non_cat)))
BOOK_42 <- c(`0.5` = 96.1, `0.9` = 126.0, `0.99` = 181.1, `0.999` = 267.2, `0.9999` = 394.0)
ps <- as.numeric(names(BOOK_42))
estimate <- 80 + quantile(cat_unit, ps)
heuristic <- data.frame(
p = names(BOOK_42),
`80 + VaR(Cat)` = unname(estimate),
`VaR(total)` = unname(quantile(cnc, ps)),
book = unname(BOOK_42),
error = unname(estimate / quantile(cnc, ps) - 1),
check.names = FALSE
)
gt(heuristic, rowname_col = "p") |>
tab_header("Table 4.2: the VaR heuristic for a thin plus a thick tail") |>
fmt_number(columns = c("80 + VaR(Cat)", "VaR(total)", "book"), decimals = 1) |>
fmt_number(columns = "error", decimals = 3, force_sign = TRUE)| Table 4.2: the VaR heuristic for a thin plus a thick tail | ||||
| 80 + VaR(Cat) | VaR(total) | book | error | |
|---|---|---|---|---|
| 0.5 | 94.1 | 96.1 | 96.1 | −0.021 |
| 0.9 | 121.1 | 126.0 | 126.0 | −0.039 |
| 0.99 | 178.1 | 181.1 | 181.1 | −0.017 |
| 0.999 | 265.3 | 267.2 | 267.2 | −0.007 |
| 0.9999 | 392.7 | 394.0 | 394.0 | −0.003 |
From the 99% level up, the heuristic is within 2%. The gross rows of Table 4.7 agree. For net Cat, the VaR and the totals agree, but three TVaRs do not, for the reason above:
at_levels <- function(f, g) round(sapply(LEVELS, function(p) f(g, p)))
BOOK_47 <- list( # Table 4.7, at LEVELS
list("net Cat VaR", quantile, cat_net, c(41, 41, 41, 41, 49, 106)),
list("net Cat TVaR", TVaR, cat_net, c(43, 64, 75, 81, 92, 160)),
list("net TVaR", TVaR, cnc_net, c(131, 139, 146, 160, 181, 242)),
list("gross TVaR", TVaR, cnc, c(149, 167, 187, 218, 254, 321))
)
net_names <- vapply(BOOK_47, function(s) s[[1]], "")
net_values <- do.call(rbind, lapply(BOOK_47, function(s) rbind(at_levels(s[[2]], s[[3]]), s[[4]])))
net_table <- data.frame(c(rbind(net_names, paste0(net_names, ", book"))), net_values)
names(net_table) <- c("measure", as.character(LEVELS))
gt(net_table, rowname_col = "measure") |>
tab_header("Table 4.7: net and gross VaR and TVaR", "Cat/Non-Cat case, by level p") |>
fmt_number(columns = as.character(LEVELS), decimals = 0)| Table 4.7: net and gross VaR and TVaR | ||||||
| Cat/Non-Cat case, by level p | ||||||
| 0.9 | 0.95 | 0.975 | 0.99 | 0.996 | 0.999 | |
|---|---|---|---|---|---|---|
| net Cat VaR | 41 | 41 | 41 | 41 | 49 | 106 |
| net Cat VaR, book | 41 | 41 | 41 | 41 | 49 | 106 |
| net Cat TVaR | 43 | 45 | 49 | 62 | 92 | 160 |
| net Cat TVaR, book | 43 | 64 | 75 | 81 | 92 | 160 |
| net TVaR | 131 | 139 | 146 | 160 | 181 | 242 |
| net TVaR, book | 131 | 139 | 146 | 160 | 181 | 242 |
| gross TVaR | 149 | 167 | 187 | 218 | 254 | 321 |
| gross TVaR, book | 149 | 167 | 187 | 218 | 254 | 321 |
Net Cat’s TVaR at 95% cannot be 64 when its VaR is 41.1 from 90% to 99.5%: the integral of VaR from 0.95 to 1 is at most 0.045 times 41.1, plus the tail above the cover. The net book total uses the same net Cat and agrees at every level.
7. Properties of risk measures
Chapter 5 lists the properties a risk measure can have: monotone, translation invariant, positive homogeneous, subadditive (these four make a measure coherent), convex, comonotonic additive and law invariant. Four examples from the book follow.
Bid and ask: a sublinear price has a spread (Example
83). Ins Co. sells a Hot August policy that pays 1 if August is
hot (probability 0.1), and a Cold August policy that pays in the other
90% of years. It prices a Bernoulli risk with probability s at the
square root of s, a proportional hazard distortion with rho 0.5. Both
asks exceed the expected loss. The bid, the price at which Ins Co. takes
the Hot risk from another party, is minus the price of minus the risk,
and it is below the expected loss. distortion_g_dual() is
the dual distortion 1 - g(1 - s), the bid side of the same price:
ph <- distortion("proportional_hazard", 0.5)
hot <- sampled(c(1, rep(0, 9)))
cold <- sampled(c(0, rep(1, 9)))
bid_ask <- data.frame(
price = c("ask, Hot", "ask, Cold", "price of minus Hot", "bid, Hot"),
prospicio = c(risk_measure(hot, ph), risk_measure(cold, ph), risk_measure(sampled(c(-1, rep(0, 9))), ph),
distortion_g_dual(ph, 0.1)),
book = c(0.316, 0.95, -0.05, NA)
)
gt(bid_ask, rowname_col = "price") |>
tab_header("Example 83: bid and ask", "Expected loss of Hot: 0.1") |>
fmt_number(columns = "prospicio", decimals = 3) |>
fmt_number(columns = "book", decimals = 3, drop_trailing_zeros = TRUE) |>
sub_missing(missing_text = "")| Example 83: bid and ask | ||
| Expected loss of Hot: 0.1 | ||
| prospicio | book | |
|---|---|---|
| ask, Hot | 0.316 | 0.316 |
| ask, Cold | 0.949 | 0.95 |
| price of minus Hot | −0.051 | −0.05 |
| bid, Hot | 0.051 | |
The book rounds -0.0513 to -0.05.
First-order dominance is not state by state (Example 102, Bäuerle and Müller). Two states have probabilities 1/3 and 2/3. X is 3 then 1, and Y is 2 then 4. Each quantile of X is at most the same quantile of Y, so every monotone, law-invariant risk measure ranks X below Y, but X is larger than Y in the first state:
x_bm <- discrete_distribution(c(3, 1), c(1 / 3, 2 / 3))
y_bm <- discrete_distribution(c(2, 4), c(1 / 3, 2 / 3))
grid_p <- c(0.1, 0.3, 0.5, 0.7, 0.9)
dominance <- data.frame(
measure = c("VaR X", "VaR Y", "TVaR X", "TVaR Y"),
rbind(sapply(grid_p, function(p) VaR(x_bm, p)), sapply(grid_p, function(p) VaR(y_bm, p)),
sapply(grid_p, function(p) TVaR(x_bm, p)), sapply(grid_p, function(p) TVaR(y_bm, p)))
)
names(dominance)[-1] <- as.character(grid_p)
gt(dominance, rowname_col = "measure") |>
tab_header("Example 102: X ranks below Y at every level p") |>
fmt_number(columns = as.character(grid_p), rows = 1:2, decimals = 1) |>
fmt_number(columns = as.character(grid_p), rows = 3:4, decimals = 3)| Example 102: X ranks below Y at every level p | |||||
| 0.1 | 0.3 | 0.5 | 0.7 | 0.9 | |
|---|---|---|---|---|---|
| VaR X | 1.0 | 1.0 | 1.0 | 3.0 | 3.0 |
| VaR Y | 2.0 | 2.0 | 4.0 | 4.0 | 4.0 |
| TVaR X | 1.741 | 1.952 | 2.333 | 3.000 | 3.000 |
| TVaR Y | 3.481 | 3.905 | 4.000 | 4.000 | 4.000 |
A law-invariant measure sees only these distributions, so the book compares risks by their quantile functions, not by their states.
Variance and the tail disagree (Exercise 103). Risk can increase for every risk-averse agent (higher stop loss premiums at every retention, or equivalently higher TVaR at every level) while the variance does not. A uniform on [0, 2] and a Pareto with tail index 4, rescaled to mean 1, have the same mean. The uniform has the larger variance, the Pareto the larger tail:
uniform <- sampled(((0:49999) + 0.5) / 50000 * 2)
par4 <- pareto(0.75, 4) # minimum 0.75, tail index 4: mean 1, variance 1/8
spread <- data.frame(
statistic = c("mean", "variance", "TVaR 0.99", "TVaR 0.999"),
uniform = c(mean(uniform), 4 / 12, TVaR(uniform, 0.99), TVaR(uniform, 0.999)),
Pareto = c(mean(par4), variance(par4), quantile(par4, 0.99) * 4 / 3, quantile(par4, 0.999) * 4 / 3)
)
tbl <- gt(spread, rowname_col = "statistic") |>
tab_header("Exercise 103: variance against the tail")
for (spec in list(list(c(1, 3, 4), 3), list(2, 4))) {
tbl <- fmt_number(tbl, columns = c("uniform", "Pareto"), rows = spec[[1]], decimals = spec[[2]])
}
tbl| Exercise 103: variance against the tail | ||
| uniform | Pareto | |
|---|---|---|
| mean | 1.000 | 1.000 |
| variance | 0.3333 | 0.1250 |
| TVaR 0.99 | 1.990 | 3.162 |
| TVaR 0.999 | 1.999 | 5.623 |
Variance ranks the uniform as riskier, and TVaR at 99% and above ranks the Pareto as riskier (at tail index 4, the Pareto TVaR is 4/3 of its VaR). No single number ranks all risks.
A convex measure that is not coherent (Example 97). The exponential (entropic) risk measure is log E[exp(theta X)] / theta. It is convex and translation invariant, but it is not positive homogeneous: when you double the risk, the measure more than doubles.
thetas <- c(0.05, 0.2)
entropy <- data.frame(
theta = paste("theta", thetas),
`rho(X)` = sapply(thetas, function(t) entropic_risk(discrete, t)),
`rho(2X)` = sapply(thetas, function(t) entropic_risk(sampled(2 * x16), t)),
`rho(X + 10)` = sapply(thetas, function(t) entropic_risk(sampled(x16 + 10), t)),
check.names = FALSE
)
gt(entropy, rowname_col = "theta") |>
tab_header("Example 97: the entropic measure") |>
fmt_number(columns = c("rho(X)", "rho(2X)", "rho(X + 10)"), decimals = 2)| Example 97: the entropic measure | |||
| rho(X) | rho(2X) | rho(X + 10) | |
|---|---|---|---|
| theta 0.05 | 67.96 | 163.31 | 77.96 |
| theta 0.2 | 89.45 | 188.12 | 99.45 |
It is the classical exponential premium principle (Part II), and it is unbounded for any loss with a thick tail.
8. Spectral risk measures and prospicio’s
distortion()
The book’s main object is the spectral risk measure (SRM), introduced in Section 3.6 and developed in Chapters 10 and 11. An SRM is the expected loss under a survival function distorted by a concave g with g(0) = 0 and g(1) = 1: rho(X) = integral of g(S(x)) dx. The SRMs are exactly the coherent, comonotonic additive, law invariant risk measures (Theorem 3). They have six equivalent representations: a distortion of the survival function, a weighted average of VaRs with increasing weights, a weighted average of TVaRs, a maximum over probability scenarios, and two integral forms.
A prospicio distortion() is a g, and its functions give
these representations:
| Representation | prospicio |
|---|---|
| g applied to the survival function |
distortion_g(d, s),
risk_measure(x, d)
|
| dual (bid) distortion 1 - g(1 - s) | distortion_g_dual(d, s) |
| VaR weights: the weight on each sorted outcome | distortion_weights(d, n) |
| a mass at zero (charge for the maximum) | distortion_mass(d) |
| a mixture of TVaRs |
distortion() kinds "tvar",
"bitvar", "weighted_tvar", and
distortion_mixture()
|
| a probability scenario for a given risk |
distortion_weights() on the sorted sample, or the
natural allocation, natural_price() on a
capital_portfolio()
|
The proportional hazard distortion with rho 0.5 prices the Simple Discrete Example at 51.156 (Table 11.1). Its spectral weights are the risk-adjusted probabilities of the sixteen sorted draws, and their weighted average of the sorted draws gives the same price:
w <- distortion_weights(ph, 16)
price_table <- data.frame(
price = c("PH(0.5) price", "weighted average of sorted outcomes", "TVaR(0.48732) price"),
prospicio = c(risk_measure(discrete, ph), sum(w * sort(x16)),
risk_measure(discrete, distortion("tvar", 0.48732))),
book = c(51.156, NA, 51.156)
)
gt(price_table, rowname_col = "price") |>
tab_header("The Simple Discrete Example under two SRMs") |>
fmt_number(columns = c("prospicio", "book"), decimals = 3) |>
sub_missing(missing_text = "")| The Simple Discrete Example under two SRMs | ||
| prospicio | book | |
|---|---|---|
| PH(0.5) price | 51.156 | 51.156 |
| weighted average of sorted outcomes | 51.156 | |
| TVaR(0.48732) price | 51.156 | 51.156 |
The two SRMs (Exercise 183) give one price for this risk and different prices for all other risks. The weights on the four worst draws, and the mass at zero:
pylist <- function(x) paste0("[", paste(x, collapse = ", "), "]")
cat(pylist(round(w[13:16], 4)), distortion_mass(ph), "\n")## [0.067, 0.0795, 0.1036, 0.25] 0
Example 176 takes the minimum of two distortions, the PH with rho 0.5 and a constant cost of capital (CCoC) of 50%, g(s) = (2 s + 1) / 3. They cross at s = 1/4: the minimum is the PH below it and the CCoC above it. The book finds the TVaR representation: a mass of 2/3 on the mean (TVaR at 0), a mass of 1/12 at TVaR(0.75) and a density over the levels from 0.75 to 1.
mixed <- distortion_minimum(list(ph, distortion("ccoc", 0.5)))
g <- function(s) distortion_g(mixed, s)
cat("g at 0.01, 1/4, 1/2, 1:", pylist(round(g(c(0.01, 0.25, 0.5, 1)), 4)), "\n")## g at 0.01, 1/4, 1/2, 1: [0.1, 0.5, 0.6667, 1]
h <- 1e-6
slope_top <- (g(1) - g(1 - h)) / h
jump <- (g(0.25) - g(0.25 - h)) / h - (g(0.25 + h) - g(0.25)) / h
cat(sprintf("slope at s = 1, the weight on the mean: %.4f (book 2/3)\n", slope_top))## slope at s = 1, the weight on the mean: 0.6667 (book 2/3)
cat(sprintf("drop in slope at s = 1/4, times 1/4: %.4f (book 1/12, the weight on TVaR 0.75)\n", 0.25 * jump))## drop in slope at s = 1/4, times 1/4: 0.0833 (book 1/12, the weight on TVaR 0.75)
The figure shows the three functions:
ccoc <- distortion("ccoc", 0.5)
sgrid <- seq(0, 1, length.out = 201)
curves <- rbind(
data.frame(s = sgrid, g = sgrid, curve = "no distortion, g(s) = s"),
data.frame(s = sgrid, g = distortion_g(ph, sgrid), curve = "PH, rho 0.5"),
data.frame(s = sgrid, g = distortion_g(ccoc, sgrid), curve = "CCoC, 50%"),
data.frame(s = sgrid, g = g(sgrid), curve = "minimum of the two")
)
curves$curve <- factor(curves$curve, levels = unique(curves$curve))
ggplot(curves, aes(s, g, colour = curve)) +
geom_line() +
scale_colour_manual(values = c("grey75", scales::hue_pal()(3))) +
labs(x = "survival probability s", y = "distorted probability g(s)", colour = NULL,
title = "Example 176: the minimum of two distortions") +
theme(legend.position = "top")distortion("ccoc", r) takes the cost of capital r, so
distortion("ccoc", 0.5) is the book’s (2 s + 1) / 3.
aggregate builds the same function from the discount d = r
/ (1 + r).
9. Choosing a risk measure
Chapter 6 separates two uses of a risk measure:
A capital risk measure sets the assets that a company holds: VaR, TVaR or EPD, chosen by a regulator or rating agency and applied to the total. A pricing risk measure sets the premium: an SRM or a classical principle.
Table 6.1 lists the measures and families. Their prospicio names:
| Measure | prospicio |
|---|---|
| mean, VaR, upper quantile |
mean(), quantile() (VaR() on
samples and discrete distributions), quantile_upper()
|
| TVaR |
TVaR() on sampled(),
grid_distribution() and
discrete_distribution(), and
distortion("tvar", p)
|
| EPD and EPD capital |
epd_ratio(port, a),
assets_for_epd(port, ratio) on a
capital_portfolio()
|
| SRMs: CCoC, PH, Wang, dual, TVaR, bi-TVaR, beta, LEP and others |
distortion() kinds |
| exponential (entropic), Esscher |
entropic_risk(), esscher_premium()
|
| classical premium principles |
classical_premium(),
calibrate_classical()
|
| CoVaR, marginal expected shortfall |
covar(),
marginal_expected_shortfall()
|
For practice, the book advises a simple, robust capital measure. VaR is both, and it is the regulator’s choice. A pricing measure must be coherent and comonotonic additive, so that the layers and parts of one risk add up. These conditions point to an SRM. Part II continues from here.