Class TailRisk
Convention: inputs are losses, positive = loss. Confidence c is
the one-sided level (0.975 = 97.5%). With losses sorted ascending,
L(1) <= ... <= L(n):
- VaR is the lower empirical quantile
L(ceil(c·n)), the smallest loss whose empirical CDF reachesc. - ES is the Acerbi-Tasche (2002, eq. 4.4 / Prop. 4.1) estimator
of the tail mean over the worst
w = (1−c)·nobservations, with the fractional boundary weight:ES = ( L(n) + ... + L(n−k+1) + (w − k)·L(n−k) ) / w, k = floor(w)
It is coherent, it is the sample analogue of(1/(1−c))·∫_c^1 VaR_u du, and it never falls below VaR. Whenw < 1it is the worst loss.
Example: losses 1, 2, ..., 1000 at c = 0.975 give w = 25, VaR = 975 and
ES = mean(976..1000) = 988.0. The estimator that also averages the VaR
observation itself (26 points, 987.5) is biased low by about
1/(w+1) of the tail spread, which is 17% at a 250-day window.
c·n and (1−c)·n are snapped to the nearest integer when
within 1e-9 of it, so 0.975·1000 is treated as 975 and not 975.0000000001.
Results are not clamped: a sample whose quantile is a gain returns a
negative VaR. Callers that report "0 if a gain" clamp themselves.
Reference: C. Acerbi and D. Tasche, "On the coherence of expected shortfall", Journal of Banking and Finance 26 (2002) 1487-1503.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordVaR and ES of one sample, both in loss units. -
Method Summary
Modifier and TypeMethodDescriptionstatic doubleexpectedShortfallSorted(double[] sortedLosses, double confidence) Acerbi-Tasche expected shortfall of an ascending sample.static TailRisk.Tailof(double[] losses, double confidence) VaR and ES of an unsorted loss sample.static TailRisk.TailofSorted(double[] sortedLosses, double confidence) VaR and ES of a loss sample already sorted ascending.static doublevarSorted(double[] sortedLosses, double confidence) Lower empirical quantileL(ceil(c·n))of an ascending sample.
-
Method Details
-
of
VaR and ES of an unsorted loss sample. The input is not modified. -
ofSorted
VaR and ES of a loss sample already sorted ascending. -
varSorted
public static double varSorted(double[] sortedLosses, double confidence) Lower empirical quantileL(ceil(c·n))of an ascending sample. -
expectedShortfallSorted
public static double expectedShortfallSorted(double[] sortedLosses, double confidence) Acerbi-Tasche expected shortfall of an ascending sample.
-