Chapter 4

Expected Shortfall (ES) is a computed by averating potential losses above a certain level given by the (VaR). It can be shown that the Expected Shortfall at the confidence level p coincides with the (TVaR) defined as the average of losses suffered in the worst (1 − p)% of events. This chapter presents the concept of , including Expected Shortfall and Tail Value at Risk (TVaR), together with experiments based on financial data sets.

4.1 Tail Value at Risk (TVaR) ...... 77 4.2 Conditional Tail Expectation (CTE) ...... 78 4.3 Expected Shortfall (ES) ...... 81 4.4 Market Data vs Gaussian Risk Measures ...... 88 Exercises ...... 97

4.1 Tail Value at Risk (TVaR)

A natural shortcoming of Value at Risk is failing to provide information on p the behavior of probability distribution tails beyond VX . The next figure illustrates the limitations of Value at Risk, namely its inability to capture p † the properties of a probability distribution beyond VX .

† “Value at Risk is like an airbag that works all the time, except when you have a car accident”. - D. Einhorn, fund manager.

77 " This version: June 13, 2021 https://personal.ntu.edu.sg/nprivault/indext.html N. Privault

95% Fig. 4.1: Two distributions having the same Value at Risk VX = 2.145.

The Tail Value at Risk (or Conditional Value at Risk) aims at providing a solution to the tail distribution problem observed with Value at Risk at the level p, by averaging over confidence levels ranging from p to 1. Definition 4.1. The Tail Value at Risk of a X at the level p ∈ (0, 1) is defined by the average

p 1 1 q TV := V dq. (4.1) X 1 − p wp X p Note that since the function p 7−→ VX is non-decreasing, we always have

p 1 1 q 1 1 p p TVX = VX dq > VX dq = VX . 1 − p wp 1 − p wp

4.2 Conditional Tail Expectation (CTE)

Recall that by Lemma 10.14, given an event A such that P(A) > 0, the conditional expectation of X : Ω −→ N given the event A satisfies 1 E[X | A] = E [X1 ] , P(A) A see Section 3.2 for an example. p  Definition 4.2. Consider a random variable X such that P X > VX > 0. The Conditional Tail Expectation of X at the level p ∈ (0, 1) is the quantity

p  p  1   CTE := E X | X > V = E X1 p . X X p  {X>VX } P X > VX The use of the strict inequality “>” in the definition of the Conditional Tail p Expectation allows us to avoid any dependence on P(X = V ), and to con- p X sider risky values strictly beyond VX . The Conditional Tail Expectation is 78 " This version: June 13, 2021 https://personal.ntu.edu.sg/nprivault/indext.html Notes on and Analytics also called Conditional Value at Risk (CVaR).

Examples of Conditional Tail Expectations can be computed as in the fol- lowing R code.

1 library(quantmod) 2 getSymbols("^HSI",from="2013-06-01",to="2014-10-01",src="yahoo") returns <- as.vector(diff(log(Ad(`HSI`)))) 4 library(PerformanceAnalytics) var=VaR(returns, p=.95, method="historical") 6 cte=mean(returns[returns

The next proposition shows by which amount the Conditional Tail Expecta- tion exceeds the Value at Risk. p p Proposition 4.3. For any p ∈ (0, 1] we have CTE > E[X] and CTE > p X X VX with, more precisely, p  p  p  p + p  CTEX = E X | X > VX = VX + E X − VX | X > VX . Proof. We have

 p  1   E X | X > V = E X1 p X p  {X>VX } P X > VX 1  p   p   = E X − V 1 p + V E 1 p p  X {X>VX } X {X>VX } P X > VX 1  p + p p  = p  E X − VX + VX P X > VX P X > VX p 1  p + = VX + p E X − VX P X > VX p  p + p  = VX + E X − VX X > VX . p See Exercise 4.2-(d) for a proof of CTEX > E[X].  p  Next, we check that when P X = VX = 0, the Conditional Tail Expectation coincides with the Tail Value at Risk. Note that in this case we have PX > p  VX > 0 by Proposition 3.9-(b). p  p Proposition 4.4. Assume that P X = V = 0. Then we have CTE = p X X TVX , i.e.

p  p   p  1 1 q p CTEX = E X | X > VX = E X | X > VX = VX dq = TVX . 1 − p wp (4.2) U Proof. By Lemma 3.13 we construct X as X = VX where U is uniformly distributed on [0, 1], with

79 " This version: June 13, 2021 https://personal.ntu.edu.sg/nprivault/indext.html N. Privault

U p p U > p =⇒ VX > VX =⇒ X > VX , and p U p X > VX =⇒ VX > VX =⇒ U > p. p  Since P X = VX = 0 we find that, with probability 1,

U p p p U > p ⇐⇒ U > p ⇐⇒ VX > VX ⇐⇒ X > VX ⇐⇒ X > VX , hence p  p  CTEX = E X | X > VX  U U p  = E VX | VX > VX  U  = E VX | U > p 1  U 1  = E VX {U p} P(U > p) > 1 1 q = V dq. 1 − p wp X

 The next figure shows the location of Value at Risk and Conditional Tail Expectation on a data set. Note that the sign of the data has been changed according to Proposition 3.10.

Fig. 4.2: Value at Risk and Conditional Tail Expectation.

The Conditional Tail Expectation of a Gaussian N (µ, σ2) random variable is computed in the next proposition. Proposition 4.5. Gaussian CTE. Given X 'N (µ, σ2) we have

p σ p σ −(V p)2 2 CTE = µ + φ(V ) = µ + √ e Z / , (4.3) X (1 − p) Z (1 − p) 2π

80 " This version: June 13, 2021 https://personal.ntu.edu.sg/nprivault/indext.html Notes on Financial Risk and Analytics

p where VZ is the Value at Risk of Z 'N (0, 1) at the level p and

1 2 φ(z) = √ e−z /2, x ∈ R, 2π is the standard normal probability density function. p  p  Proof. Using the relation P X > VX = P X > VX = 1 − p, cf. Proposi- tion 3.9, we have

p p CTEX = TVX  p  = E X | X > VX 1   = E X1 p p  {X>VX } P X > VX 1 ∞ 2 2 dx = xe−(x−µ) /(2σ ) √ wV p 2 1 − p X 2πσ µ ∞ 2 2 dx 1 ∞ 2 2 dx = e−(x−µ) /(2σ ) √ + (x − µ)e−(x−µ) /(2σ ) √ wV p 2 wV p 2 1 − p X 2πσ 1 − p X 2πσ 2 µ p σ h 2 2 i∞ = P(X V ) + √ −e−(x−µ) /(2σ ) > X 2 p 1 − p (1 − p) 2πσ VX 2 σ −((V p −µ) σ)2 2 = µ + √ e X / / (1 − p) 2πσ2 σ −(V p)2 2 = µ + √ e Z / (1 − p) 2π σ p = µ + φ(V ), (1 − p) Z

p p due to the rescaling relation VX = µ + σqZ , cf. (3.7). 

4.3 Expected Shortfall (ES)

p There are several variants for the definition of the Expected Shortfall ESX . Next is a frequently used definition. p Definition 4.6. The Expected Shortfall ESX of a random variable X at the level p ∈ (0, 1) is defined by

p p 1  p 1  ESX := VX + E X − VX {X V p } . (4.4) 1 − p > X We also have p  p p P X > VX  p p  ES = V + E X − V X V X X 1 − p X > X

81 " This version: June 13, 2021 https://personal.ntu.edu.sg/nprivault/indext.html N. Privault

p 1  1  p 1  = VX + E X {X V p } − VX E {X V p } 1 − p > X > X p 1  1  p p  = VX + E X {X V p } − VX P X > VX 1 − p > X V p 1  1  X p  = E X {X V p } + 1 − p − P X > VX , 1 − p > X 1 − p and  1  1   p  p p   E X {X V p } = E X | X > VX = TVX if P X = VX = 0,  1 − p > X p  ES = X p  1 V p p   1 p  X    E X {X V } + 1 − p − P X > VX if P X = VX > 0, 1 − p > X 1 − p as shown in the next proposition. Note that by Proposition 3.9-(b) we have p  p  P X > VX > 0 when P X = VX = 0. p  p Proposition 4.7. When P X = V = 0 the Expected Shortfall ES co- X p X incides with the Conditional Tail Expectation CTE and the Tail Value at p X Risk TVX , i.e., we have p  p   p  p ESX = E X | X > VX = E X | X > VX = TVX . p  Proof. By Proposition 3.9, when P X = VX = 0 we have

p p p p = P(X 6 VX ) and 1 − p = P(X > VX ) = P(X > VX ), hence

p 1  1  ESX = E X {X V p } 1 − p > X 1  1  = E X {X>V p } 1 − p X 1   = E X1 p p  {X>VX } P X > VX  p  = E X | X > VX p = TVX , by Proposition 4.4.  p  When P X = VX = 0, we also have

V p p 1  1  p X p  ESX = E X {X V p } + VX − P X > VX 1 − p > X 1 − p V p 1  1  X p  = E X {X>V p } + 1 − p − P X > VX . 1 − p X 1 − p

82 " This version: June 13, 2021 https://personal.ntu.edu.sg/nprivault/indext.html Notes on Financial Risk and Analytics

p Proposition 4.8. The Expected Shortfall ESX can be written as the dis- torted risk measure

p 1 1 q q ES = E[XfX (X)] = V fX (V )dq, (4.5) X 1 − p w0 X X where fX is the distortion function defined by p  1 1 − p − P X > VX fX (x) := 1 p + 1 p 1 p , {x>VX } {P(X=VX )>0} p  {x=VX } 1 − p (1 − p)P X = VX x ∈ R. Proof. We have

V p p 1  1  X p  ESX = E X {X V p } + 1 − p − P X > VX 1 − p > X 1 − p V p 1  1  1 X p  = E X {X V p } + {P(X=V p )>0} 1 − p − P X > VX 1 − p > X X 1 − p " p  !# 1 1 − p − P X > VX = E X 1 p + 1 p 1 p . {X>VX } {P(X=VX )>0} p  {X=VX } 1 − p P X = VX



Note that the distortion function fX is a non-decreasing function that satisfies " p  # 1 1 − p − P X > VX E[fX (X)] = E 1 p + 1 p 1 p {X>VX } {P(X=VX )>0} p  {X=VX } 1 − p P X = VX   1 1  p  = E {X>V p } + 1 − p − P X > VX 1 − p X 1 p p = PX V  + 1 − p − PX V  1 − p > X > X = 1, x ∈ R. (4.6)

The following proposition, see Acerbi and Tasche(2001), shows that in gen- eral, the Expected Shortfall at the level p ∈ (0, 1) coincides with the Tail p Value at Risk TVX . p Proposition 4.9. The Expected Shortfall ES coincides with the Tail Value p X at Risk TVX for any p ∈ (0, 1), i.e. we have

p p 1 1 q ES = TV = V dq. X X 1 − p wp X U Proof. Constructing X as X = VX where U is uniformly distributed on [0, 1] as in Lemma 3.13, by Proposition 3.8 we have

83 " This version: June 13, 2021 https://personal.ntu.edu.sg/nprivault/indext.html N. Privault

U p p U > p =⇒ VX > VX =⇒ X > VX and

p  U p p  U < p and X > VX =⇒ VX 6 VX and X > VX p p  =⇒ X 6 VX and X > VX p =⇒ X = VX .

Hence by (4.4) and the relations   p    1 − p = E 1{U p} and P X V = E 1 p , > > X {X>VX } we have p p  p   V 1 − p − P X V = −V E 1 p − 1{U p} X > X X {X>VX } > p   = −V E 1 p X {X>VX }\{U>p} p   = −V E 1 p X {X>VX }∩{UVX }∩{U

V p p 1  1  X p  ESX = E X {X V p } + 1 − p − P X > VX 1 − p > X 1 − p 1  1  1  1  = E X {X V p } − E X {X V p }∩{U X 1 − p > X 1  U 1  1  U 1  = E VX {V U V p } − E VX {V U V p }∩{U X 1 − p X > X 1  U 1  = E VX {V U V p }∩{U p} 1 − p X > X > 1 = EV U 1  1 − p X {U>p} 1 1 q = V dq, 1 − p wp X p which is the Tail Value at Risk TVX .  As a consequence of Propositions 4.4-4.5 and Proposition 4.9, the Gaussian Expected Shortfall at the level p is also given by

p σ p ES = µ + φ(V ). X (1 − p) Z

84 " This version: June 13, 2021 https://personal.ntu.edu.sg/nprivault/indext.html Notes on Financial Risk and Analytics

p Proposition 4.10. The Expected Shortfall ES and the Tail Value at Risk p X TVX are coherent risk measures. p p Proof. As ESX coincides with TVX for all p ∈ (0, 1) from Proposition 4.9, we can use either Relation (4.4) in Definition 4.6 or Relation (4.1) in Defini- tion 4.1. (i) Monotonicity. If X 6 Y , since Value at Risk is monotone we have p p ESX = TVX 1 1 = V q dq 1 − p wp X 1 1 q 6 VY dq 1 − p wp p = TVY p 6 ESY for all p ∈ (0, 1). (ii) Homogeneity and translation invariance. Similarly, since Value at Risk is satisfies the homogeneity and translation invariance properties, for all µ ∈ R and λ > 0 we have monotone we have

p p ESµ+λX = TVµ+λX 1 1 = V q dq 1 − p wp µ+λX 1 1 = µ + λV q dq 1 − p wp X 1 1 = µ + λ V q dq 1 − p wp X p = µ + λTVY p 6 µ + λESY for all p ∈ (0, 1). (iii) Sub-additivity. We have p p p  (1 − p) ESX+Y − ESX − ESY = E[(X + Y )fX+Y (X + Y )] − E[XfX (X)] − E[Y fY (Y )] = E[X(fX+Y (X + Y ) − fX (X))] − E[Y (fX+Y (X + Y ) − fY (Y ))] p p > VX E[fX+Y (X + Y ) − fX (X)] − VY E[fX+Y (X + Y ) − fY (Y )] p p = VX (1 − p − (1 − p)) − VY (1 − p − (1 − p)) = 0,

p where we have used (4.6) and the facts that, for x < VX , 85 " This version: June 13, 2021 https://personal.ntu.edu.sg/nprivault/indext.html N. Privault

1 1 (1 − p)(fX+Y (x + y) − fX (x)) = {x y>V p } − {x>V p } + X+Y X p 1 − p − P(X + Y > V ) 1 X+Y 1 + {P X Y V p >0} p {x y V p } ( + = X+Y ) + = X+Y P(X + Y = VX+Y ) p  1 − p − P X > VX −1 p 1 p {P(X=VX )>0} p  {x=VX } P X = VX p 1 − p − P(X + Y > V ) 1 1 X+Y 1 = {x y>V p } + {P X Y V p >0} p {x y V p } + X+Y ( + = X+Y ) + = X+Y P(X + Y = VX+Y ) p > 0, x < VX , p and, for x > VX , 1 1 (1 − p)(fX+Y (x + y) − fX (x)) = {x y>V p } − {x>V p } + X+Y X p 1 − p − P(X + Y > V ) 1 X+Y 1 + {P X Y V p >0} p {x y V p } ( + = X+Y ) + = X+Y P(X + Y = VX+Y ) p  1 − p − P X > VX −1 p 1 p {P(X=VX )>0} p  {x=VX } P X = VX 1 1 = {x y>V p } − {x>V p } + X+Y X p 1 − p − P(X + Y > V ) 1 X+Y 1 + {P X Y V p >0} p {x y V p } ( + = X+Y ) + = X+Y P(X + Y = VX+Y ) 1 1 {x y>V p } − {x>V p } 6 + X+Y X 1 + {x y V p } + = X+Y 1 1 = {x y V p } − {x>V p } + > X+Y X p > 0, x < VX .

 Note that in general, the Conditional Tail Expectation is not a coherent risk p  measure when P X = VX > 0.

Performance analytics in R - Expected Shortfall (ES)

1 library(PerformanceAnalytics) 2 ES(returns, p=.95, method="historical")

95% The 95% Expected Shortfall is ESX = −0.02087832. The historical Ex- pected Shortfall can be exactly recovered by the empirical Condtional Tail Expectation (CTE) as

86 " This version: June 13, 2021 https://personal.ntu.edu.sg/nprivault/indext.html Notes on Financial Risk and Analytics

1 mean(returns[returns<(VaR(returns, p=.95, method="historical")[1])],na.rm=TRUE)

The Gaussian Expected Shortfall is given as −0.0191359 by

1 ES(returns, p=.95, method="gaussian") and it can be recovered from (4.3) (after sign inversion) as

p σ p σ −(V p)2 2 ES = µ − φ(V ) = µ − √ e Z / X (1 − p) Z (1 − p) 2π with µ = E[X] and σ2 = Var[X], i.e.

1 q=qnorm(.95, mean=0, sd=1) m=mean(returns,na.rm=TRUE) 3 s=sd(returns,na.rm=TRUE) m-s*dnorm(q)/0.05 with output −0.01916536.

The attached computes the Expected Shortfall and compares its output to the that of the PerformanceAnalytics package, as illustrated in the next Figure 4.3.

> source("comparison.R") Number of samples= 265 VaR 95 = -0.03420879 , Threshold= 0.9433962 CTE 95 = -0.04646176 ES 95 = -0.04623058 Historical VaR 95 0= -0.03316604 Gaussian VaR 95 = -0.03209374 Historical ES 95 = -0.04552403 Gaussian ES 95 = -0.04043227

Fig. 4.3: Value at Risk and Expected Shortfall.

87 " This version: June 13, 2021 https://personal.ntu.edu.sg/nprivault/indext.html N. Privault

Value at Risk vs Expected Shortfall

1 chart.VaRSensitivity(ts(returns),methods=c("HistoricalVaR","HistoricalES"), colorset=bluefocus, lwd=2)

Risk Confidence Sensitivity of 1800.HK.Adjusted −0.04 −0.06 Value at Risk Value −0.08 −0.10

Historical VaR Historical ES −0.12 0.89 0.9 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99

Confidence Level

Fig. 4.4: Value at Risk vs Expected Shortfall.

4.4 Market Data vs Gaussian Risk Measures

Market returns vs Gaussian and power tails

Consider for example the market returns data obtained from fetching DJI and STI index data using the R package Quantmod and the following scripts.

1 library(quantmod) getSymbols("^STI",from="1990-01-03",to="2015-01-03",src="yahoo");stock=Ad(`STI`); 3 getSymbols("^DJI",from="1990-01-03",to=Sys.Date(),src="yahoo");stock=Ad(`DJI`); stock.rtn=diff(log(stock));returns <- as.vector(stock.rtn) 5 m=mean(returns,na.rm=TRUE);s=sd(returns,na.rm=TRUE);times=index(stock.rtn) n = sum(is.na(returns))+sum(!is.na(returns));x=seq(1,n);y=rnorm(n,mean=m,sd=s) 7 dev.new(width=16,height=8) plot(times,returns,pch=19,xaxs="i",yaxs="i",cex=0.03,col="blue", ylab="", xlab="", main = '', las=1, cex.lab=1.8, cex.axis=1.8, lwd=3) 9 segments(x0 = times, x1 = times, y0 = 0, y1 = returns,col="blue") points(times,y,pch=19,cex=0.3,col="red") 11 abline(h = m+3*s, col="black", lwd =1);abline(h = m, col="black", lwd =1);abline(h = m+-3*s, col="black", lwd =1) length(returns[abs(returns-m)>3*s])/length(stock.rtn) 13 length(y[abs(y-m)>3*s])/length(y);2*(1-pnorm(3*s,0,s))

Figure 4.5 shows the mismatch between the distributional properties of mar- ket log-returns vs standardized Gaussian returns, which tend to underesti- mate the probabilities of extreme events. Note that when X 'N (0, σ2), 88 " This version: June 13, 2021 https://personal.ntu.edu.sg/nprivault/indext.html Notes on Financial Risk and Analytics

99.73% of samples of X are falling within the interval [−3σ, +3σ], i.e. P(|X| 6 3σ) = 0.9973002.

0.05

0.00

−0.05

1995 2000 2005 2010 2015

Fig. 4.5: Market returns vs normalized Gaussian returns.

1 stock.ecdf=ecdf(as.vector(stock.rtn));x <- seq(-0.25, 0.25, length=100);px <- pnorm((x-m)/s) dev.new(width=16,height=8) 3 plot(stock.ecdf, xlab = '', col="blue",ylab = '', ylim=c(-0.002,1.002), main = '', xaxs="i", yaxs="i", las=1, cex.lab=1.8, cex.axis=1.8, lwd=3) lines(x, px, type="l", lty=2, col="red",xlab="",ylab="", main="") 5 legend("topleft", legend=c("Empirical CDF","Gaussian CDF"),col=c("blue","red"), lty=1:2, cex=2);grid(lwd = 2)

1.0 Empirical CDF Gaussian CDF 0.8

0.6

0.4

0.2

0.0 −0.15 −0.10 −0.05 0.00 0.05 0.10

Fig. 4.6: Empirical vs Gaussian CDF.

The following -Quantile plot is plotting the normalized empirical against the standard Gaussian quantiles, and is obtained with the qqnorm(returns) command.

89 " This version: June 13, 2021 https://personal.ntu.edu.sg/nprivault/indext.html N. Privault

1 dev.new(width=16,height=8) qqnorm(returns, col="blue", xaxs="i", yaxs="i", las=1, cex.lab=1.4, cex.axis=1, lwd=3) 3 grid(lwd = 2)

Normal Q−Q Plot

0.10

0.05

0.00

Sample Quantiles −0.05

−0.10

−3 −2 −1 0 1 2 3 Theoretical Quantiles

Fig. 4.7: Quantile-Quantile plot.

1 ks.test(y,"pnorm",mean=m,sd=s) ks.test(returns,"pnorm",mean=m,sd=s)

The Kolmogorov-Smirnov test clearly rejects the null (normality) hypothesis. One-sample Kolmogorov-Smirnov test

data: returns D = 0.075577, p-value < 2.2e-16 alternative hypothesis: two-sided

This mismatch can be further illustrated by the empirical probability density plot in Figure 4.8, which is obtained from the following R code.

1 dev.new(width=16,height=8) 2 x <- seq(-0.25, 0.25, length=100);qx <- dnorm(x,mean=m,sd=s) stock.dens=density(stock.rtn,na.rm=TRUE) 4 plot(stock.dens, xlab = 'x', lwd=4, col="red",ylab = '', main = '', xlim =c(-0.1,0.1), ylim=c(0,65), xaxs="i", yaxs="i", las=1, cex.lab=1.8, cex.axis=1.8) lines(x, qx, type="l", lty=2, lwd=4, col="blue",xlab="x value",ylab="Density", main="") 6 legend("topleft", legend=c("Empirical density","Gaussian density"),col=c("red","blue"), lty=1:2, cex=1.5);grid(lwd = 2)

Clearly, the Gaussian Value at Risk will be strictly lower than the empirical Value at Risk for large return values.

90 " This version: June 13, 2021 https://personal.ntu.edu.sg/nprivault/indext.html Notes on Financial Risk and Analytics

Empirical density 60 Gaussian density

50

40

30

20

10

0 −0.10 −0.05 0.00 0.05 0.10 x

Fig. 4.8: Empirical density vs normalized Gaussian density.

Power tail distributions

We note that the empirical density has significantly higher kurtosis and non zero skewness in comparison with the Gaussian probability density. On the α other hand, power tail probability densities of the form ϕ(x) ' Cα/x , x → ∞, can provide a better fit of empirical probability density functions, as shown in Figure 4.9.

Empirical density 60 Power density

50

40

30

20

10

0 −0.10 −0.05 0.00 0.05 0.10

Fig. 4.9: Empirical density vs power density.

The above fitting of empirical probability density function is using a power probability density function defined by a rational fraction obtained by the following R script.

91 " This version: June 13, 2021 https://personal.ntu.edu.sg/nprivault/indext.html N. Privault

1 install.packages("pracma") 2 library(pracma); x <- seq(-0.25, 0.25, length=1000) stock.dens=density(returns,na.rm=TRUE, from = -0.1, to = 0.1, n = 1000) 4 a<-rationalfit(stock.dens$x, stock.dens$y, d1=2, d2=2) dev.new(width=16,height=8) 6 plot(stock.dens$x,stock.dens$y, lwd=4, type ="l",xlab = '', col="red",ylab = '', main = '', xlim =c(-0.1,0.1), ylim=c(0,65), xaxs="i", yaxs="i", las=1, cex.lab=1.8, cex.axis=1.8) lines(x,(a$p1[3]+a$p1[2]*x+a$p1[1]*x^2)/(a$p2[3]+a$p2[2]*x+a$p2[1]*x^2), type="l",lty=2,col="blue",xlab="x value",lwd=4, ylab="Density",main="") 8 legend("topleft", legend=c("Empirical density","Power density"),col=c("red","blue"), lty=1:2, cex=1.5);grid(lwd = 2)

The output of the rationalfit command is $p1 [1] -0.184717249 -0.001591433 0.001385017

$p2 [1] 1.000000e+00 -6.460948e-04 1.314672e-05 which yields a rational fraction of the form

0.001385017 − 0.001591433 × x − 0.184717249 × x2 x 7−→ 1.314672 10−5 − 6.460948 10−4 × x + x2 0.001591433 0.001385017 ' −0.184717249 − + , x x2 which approximates the empirical probability density function of DJI returns in the least squares sense.

A solution to this tail problem is to use stochastic processes with jumps, that will account for sudden variations of the asset prices. On the other hand, such jump models are generally based on the Poisson distribution which has a slower tail decay than the Gaussian distribution. This allows one to assign higher probabilities to extreme events, resulting in a more realistic modeling of asset prices. Stable distributions with parameter α ∈ (0, 2) provide typical examples of probability laws with power tails, as their probability density 1+α functions behave asymptotically as x 7→ Cα/|x| when x → ±∞.

Edgeworth and Gram-Charlier expansions

Let 1 2 ϕ(x) := √ e−x /2, x ∈ R, 2π denote the standard normal density function, and let x Φ(x) := ϕ(y)dy, x ∈ R, w−∞ denote the standard normal cumulative distribution function. Let also

92 " This version: June 13, 2021 https://personal.ntu.edu.sg/nprivault/indext.html Notes on Financial Risk and Analytics

(−1)n ∂nϕ H (x) := (x), x ∈ R, n ϕ(x) ∂xn denote the Hermite polynomial of degree n, with H0(x) = 1.

X Given X a random variable, the sequence (κn )n>1 of cumulants of X has been introduced in Thiele(1899). In the sequel we will use the Moment Generating Function (MGF) of the random variable X, defined as

n  tX  X t n MX (t) := E e = 1 + E[X ], t ∈ R. (4.7) n! n>1 Definition 4.11. The cumulants of a random variable X are defined to be X the coefficients (κn )n>1 appearing in the series expansion   n n  tX  X t n X X t log E e = log 1 + E[X ] = κ , t ∈ R, (4.8) n! n n! n>1 n>1 of the logarithmic moment generating function (log-MGF) of X. The cumulants of X were originally called “semi-invariants” due to the prop- X+Y X Y erty κn = κn + κn , n > 1, when X and Y are independent random variables. Indeed, in this case we have n X X+Y t  t(X+Y ) κ = log E e n n! n>1  tX   tY  = log E e E e  tX   tY  = log E e + log E e X tn X tn = κX + κY n n! n n! n>1 n>1 n X X Y t = κ + κ , t ∈ R, n n n! n>1

X+Y X Y showing that κn = κn + κn , n > 1. X a) First moment and cumulant. Taking n = 1 and π = {1}, we find κ1 = E[X]. b) Variance and second cumulant. We have

X  2 2  2 κ2 = E X − (E[X]) = E (X − E[X]) , q X and κ2 is the standard deviation of X. c) The third cumulant of X is given as the third central moment

93 " This version: June 13, 2021 https://personal.ntu.edu.sg/nprivault/indext.html N. Privault

X 3 κ3 = E[(X − E[X]) ],

and the coefficient κX E(X − E[X])3 Sk := 3 = X X 3/2 2 3/2 (κ2 ) (E[(X − E[X]) ]) is the skewness of X. d) Similarly, we have

X 4 X 2 κ4 = E[(X − E[X]) ] − 3(κ2 ) 4  22 = E[(X − E[X]) ] − 3 E (X − E[X]) ,

and the excess kurtosis of X is defined as κX E[(X − E[X])4] 4 − EKX := X 2 = 2 2 3. (κ2 ) (E[(X − E[X]) ]) The next proposition summarizes the Gram-Charlier expansion method to obtain series expansion of a probability density function, see Gram(1883), Charlier(1914) and § 17.6 of Cramér(1946). Proposition 4.12. (Proposition 2.1 in Tanaka et al.(2010)) The Gram- Charlier expansion of the continuous probability density function φX (x) of a random variable X is given by       X ∞ X X 1 x − κ1 1 X x − κ1 x − κ1 φX (x) = q ϕ  q  + q cnHn  q  ϕ  q  , X X X X X κ2 κ2 κ2 n=3 κ2 κ2 where c0 = 1, c1 = c2 = 0, and the sequence (cn)n>3 is given from the X cumulants (κn )n>1 of X as

[n/3] κX ··· κX 1 X X l1 lm cn = , n 3. X n/2 > (κ2 ) m!l1! ··· lm! m=1 l1+···+lm=n l1,...,lm>3

X X 3/2 The coefficients c3 and c4 can be expressed from the skweness κ3 /(κ2 ) X X 2 and the excess kurtosis κ4 /(κ2 ) as

X X κ3 κ4 c3 = and c4 = . X 3/2 X 2 3!(κ2 ) 4!(κ2 ) a) The first-order expansion

94 " This version: June 13, 2021 https://personal.ntu.edu.sg/nprivault/indext.html Notes on Financial Risk and Analytics

  X (1) 1 x − κ1 φX (x) = q ϕ  q  X X κ2 κ2

corresponds to normal moment matching approximation. b) The third-order expansion is given by      X X (3) 1 x − κ1 x − κ1 φX (x) = q 1 + c3H3  q  ϕ  q  . X X X κ2 κ2 κ2 c) The fourth-order expansion is given by        X X X (4) 1 x − κ1 x − κ1 x − κ1 φX (x) = q 1 + c3H3  q  + c4H4  q  ϕ  q  . X X X X κ2 κ2 κ2 κ2

1 install.packages("SimMultiCorrData");install.packages("PDQutils") 2 library(quantmod);library(SimMultiCorrData);library(PDQutils) dev.new(width=16,height=8) 4 plot(stock.dens$x,stock.dens$y, xlab = 'x', type = 'l', lwd=4, col="red",ylab = '', main = '', xlim =c(-0.1,0.1), ylim=c(0,65), xaxs="i", yaxs="i", las=1, cex.lab=1.8, cex.axis=1.8) lines(x, qx, type="l", lty=2, lwd=4, col="blue") 6 m<-calc_moments(returns[!is.na(returns)]) cumulants<-c(m[1],m[2]**2);d2 <- dapx_edgeworth(x, cumulants) 8 lines(x, d2, type="l", lty=2, lwd=4, col="blue") cumulants<-c(m[1],m[2]**2,m[3]*m[2]**3);d3 <- dapx_edgeworth(x, cumulants) 10 lines(x, d3, type="l", lty=2, lwd=4, col="green") cumulants<-c(m[1],m[2]**2,0.5*m[3]*m[2]**3,0.2*m[4]*m[2]**4) 12 d4 <- dapx_edgeworth(x, cumulants);lines(x, d4, type="l", lty=2, lwd=4, col="purple") legend("topleft", legend=c("Empirical density","Gaussian density","Third order Gram-Charlier","Fourth order Gram-Charlier"),col=c("red","blue","green", "purple"), lty=1:2,cex=1.5);grid(lwd = 2)

Empirical density 60 Gaussian density Third order Gram−Charlier Fourth order Gram−Charlier 50

40

30

20

10

0 −0.10 −0.05 0.00 0.05 0.10 x Fig. 4.10: Gram-Charlier expansions

95 " This version: June 13, 2021 https://personal.ntu.edu.sg/nprivault/indext.html N. Privault

Historical and Gaussian risk measures

1 dev.new(width=16,height=8) chart.VaRSensitivity(stock.rtn[,1,drop=FALSE],methods=c("HistoricalVaR","GaussianVaR"), colorset=bluefocus, lwd=4)

The next Figure 4.11 uses the above R code to compare the historical and Gaussian values at risk.

Risk Confidence Sensitivity of DJI.Adjusted −0.010 −0.015 −0.020 Value at Risk Value −0.025

Historical VaR

−0.030 Gaussian VaR

0.89 0.9 0.905 0.915 0.925 0.935 0.945 0.955 0.965 0.975 0.985

Confidence Level

Fig. 4.11: Historical vs Gaussian estimates of Value at Risk.

1 dev.new(width=16,height=8) 2 chart.VaRSensitivity(stock.rtn[,1,drop=FALSE],methods=c("HistoricalES","GaussianES"), colorset=bluefocus, lwd=4)

In the next Figure 4.12 we compare the Gaussian and historical estimates of Expected Shortfall.

Risk Confidence Sensitivity of DJI.Adjusted −0.020 −0.025 −0.030 Value at Risk Value −0.035 −0.040

Historical ES

−0.045 Gaussian ES

0.89 0.9 0.905 0.915 0.925 0.935 0.945 0.955 0.965 0.975 0.985

Confidence Level

Fig. 4.12: Quantile function.

96 " This version: June 13, 2021 https://personal.ntu.edu.sg/nprivault/indext.html Notes on Financial Risk and Analytics

In Table 4.1 we summarize some properties of risk measures.

Risk Measure Additivity Homogeneity Subadditivity Coherence

V p   X X X

CTEp   X X X

TVp X X X X X

ESp X X X X X

Table 4.1: Summary of Risk Measures.

p Note that Value at Risk V is coherent on Gaussian random variables ac- X p cording to Remark 3.12. Similarly, the Conditional Tail Expectation CTEX is coherent on random variables having a continuous CDF by Propositions 4.4 and 4.10.

Exercises

Exercise 4.1 Let X denote an exponentially distributed random variable with parameter λ > 0, i.e. the distribution of X has the cumulative distribution function (CDF)

−λx FX (x) = P(X 6 x) = 1 − e , x > 0, and the probability density function (PDF)

0 −λx fX (x) = FX (x) = λe , x > 0.

97 " This version: June 13, 2021 https://personal.ntu.edu.sg/nprivault/indext.html N. Privault

1.0 1 p=0.95

0.9 0.9

0.8 0.8

0.7 0.7

0.6 0.6 0.5 0.5 0.4 0.4 95

0.3 . 0.3 0 0.2 X q 0.2 Probability density 0.1 0.1 0 0.0 0 1 2 4 5 6

95 0 1 2 3 4 5 6 . 0 X q (a) Exponential quantile and PDF. (b) Exponential PDF.

a) Compute the conditional tail expectation

p 1 ∞ E[X | X > VaR ] = p xfX (x)dx. X wVaRp P(X > VaRX ) X b) Compute the tail value at risk

p 1 1 q TV = V dq. X 1 − p wp X

Exercise 4.2 Consider X an (integrable) random variable and z ∈ R such that P(X > z) > 0. a) Show that E[X | X > z] > z. b) Show that E[X | X > z] > E[X]. c) Show that E[X | X > z] > E[X] if P(X z) > 0. p 6 d) Show that CTEX > E[X].

Exercise 4.3 Consider the following data set.

p p Find the Value at Risk VaRX and the Conditional Tail Expectation CTEX =  p  E X | X > VaRX and mark their values on the graph in the following cases. a) p = 0.9. 98 " This version: June 13, 2021 https://personal.ntu.edu.sg/nprivault/indext.html Notes on Financial Risk and Analytics b) p = 0.8.

Exercise 4.4

Let p = 0.9. For the above data set represented by the random variable X, compute the numerical values of the following quantities. a) VaR90,  X  b) E X1 90 , {X>VX } 90 c) P X > VX , 90  90  1  90 d) CTEX = E X | X > VX = E X {X>V 90} /P X > VX ,   X e) E X1 90 , {X>VX } 90 f) P X > VX , 90 1  1  90 90 g) ESX = E X {X V 90} + VX 1 − p − P X > VX , 1 − p > X 1 1 q h) TV90 = V dq, X 1 − p wp X 90% 90% 90% 90% and mark the values of VaRX , CTEX , ESX , TVX on the above graph.

Exercise 4.5 Consider a random variable X ∈ {10, 100, 150} with the distri- bution

P(X = 10) = 96%, P(X = 100) = 3%, P(X = 150) = 1%.

Compute 98% a) the Value at Risk VX , 98% b) the Tail Value at Risk TVX ,  98% c) the Conditional Tail Expectation E X | X > VX , and 98% d) the Expected Shortfall EX .

99 " This version: June 13, 2021 https://personal.ntu.edu.sg/nprivault/indext.html N. Privault

Exercise 4.6 Consider two independent random variables X and Y with same distribution given by

P(X = 0) = P(Y = 0) = 90% and P(X = 100) = P(Y = 100) = 10%. a) Plot the cumulative distribution function of X on the following graph:

FX (x) 1.02 1.00 0.98 0.96 0.94 0.92 0.90 0.88

0 x 20 10 0 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200 210 − −

Fig. 4.14: Cumulative distribution function of X. b) Plot the cumulative distribution function of X + Y on the following graph:

FX+Y (x) 1.00 0.98 0.96 0.94 0.92 0.90 0.88 0.86 0.84 0.82 0.80

0 x 20 10 0 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200 210 − −

Fig. 4.15: Cumulative distribution function of X + Y .

99% 95% 90% c) Give the values at risk VX+Y , VX+Y , VX+Y . d) Compute the Tail Value at Risk

1 1 q TV90% := V dq X 1 − p wp X

at the level p = 90%. e) Compute the Tail Value at Risk

p 1 1 q TV := V dq X+Y 1 − p wp X+Y

at the levels p = 90% and p = 80%.

Exercise 4.7 (Exercise 3.2 continued). a) Compute the Tail Value at Risk

p 1 1 q TV := V dq X 1 − p wp X

100 " This version: June 13, 2021 https://personal.ntu.edu.sg/nprivault/indext.html Notes on Financial Risk and Analytics

99% for all p in the interval [0.99, 1], and give the value of TVX . b) Taking p = 0.98, compute the Conditional Tail Expectation

98%  98% 1 h i CTE = E X | X > V = E X1 p . X X p  {X>VX } P X > VX

101 " This version: June 13, 2021 https://personal.ntu.edu.sg/nprivault/indext.html