Compute both Expected Shortfall and Value at Risk by using the Extreme Value Theory. Furthermore, also the parameter of the Generalized Pareto Distribution are estimated with the Maximum Likelihood method
[es,var,xoptim,v,inf]=esvarevt(x0,data,u,alpha);
The Extreme Value Theory assumes that a phenomenon has a uniform distribution before a given threshold "u", while after this threshold it follows a Generalized Pareto Distribution having the form
f(x) = (1+xi*(x-u)/beta)^(-1/xi-1)/beta
This function estimates both "xi" and "beta" on the data (by Maximum Likelihood) and computes both the Expected Shortfall and the Value at Risk by using this density function.
First we generate 1000 random numbers taken from a Generalized Pareto Distribution. First step is the creation of a vector of 1000 uniformly distributed random variables:
-->U=grand(1000,1,'def');
then we create the random variables from the GPD with parameters u=0.0001; xi=0.5; beta=0.00015:
-->x=0.0001-0.00015/0.5+0.00015/0.5*(1-U)^(-0.5);
These data could be daily return on an asset. Now we can use the function on vector x for computing ES and VaR at, for instance, 0.01 confidence level
-->[es,var,xoptim,v,inf]=esvarevt([0.2 0.0002],x,0.0001,0.01)
inf = 1.
v = 1.0D-12 *
- 1.8189894 - 0.0017764
xoptim = 0.5020924 0.0001470
var = 0.0027625
es = 0.0057426
We can see that the convergence is good (please note that the algorithm is very sensitive to the initial condition x0). The estimated values of "xi" and "beta" are close to the true ones.
Francesco Menoncin - Brescia University - 2010