Estimate the parameters of the Generalized Pareto Distribution with the Maximum Likelihood method
[xoptim,v,inf]=evt(x0,x,u)
For data (x) higher than a threshold "u", the Generalized Pareto Distribution have 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).
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
-->[xoptim,v,inf]=evt([0.2 0.0002],x,0.0001)
inf = 1.
v = 1.0D-12 *
- 1.8189894 - 0.0017764
xoptim = 0.5020924 0.0001470
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