function [MLE,loglik,exitflag,output,lambda,grad,hessian] = MLGPDEGARCH(par0);
global GARCH_SERIES;
% ML_GPD_EGARCH.M         Constructs the ML estimates for a 
%   GPD-EGARCH(1,1) process:
%       Y[t] = mu + sig[t]*eta[t] where
%       log(sig[t]^2) = alpha0 + alpha1*log(sig[t-1]^2) +
%       alpha2*(Y[t-1]-mu) + alpha3*abs(Y[t-1]-mu)
%   and eta[t] is IID GPD distributed with mean zero, unit variance and pdf as given 
%   in Equation (3) in Komunjer (2006) with alpha = 0.5:
%       p(x,lda) = [gamma(2/lda)/(gamma(1/lda)*gamma(1+1/lda))]*[1/mu]*...
%                   exp(-[gamma(2/lda)/(alpha*gamma(1/lda))]^lda*[abs(x/mu+1-2*alpha)]^lda), if x <= -1*(1-2*alpha)*mu
%                   exp(-[gamma(2/lda)/((1-alpha)*gamma(1/lda))]^lda*[abs(x/mu+1-2*alpha)]^lda), if x > -1*(1-2*alpha)*mu
%       where mu = gamma(2/lda)*[gamma(3/lda)*gamma(1/lda)*(1-3*alpha+3*alpha^2)-gamma(2/lda)^2*(1-2*alpha)^2]^(-0.5).
%
% The objective function is GPDLogLik.m.
%
% Inputs:    
%       GARCH_SERIES = GARCH(1,1) time series studied (GLOBAL variable)
%       par0 = starting values for the optimization
% Outputs:   
%       MLE = estimates
%       fval = optimal value of the vector function 
%       loglik = optimal value of the log-likelihood (max of the vector function)
%
% References:
%   [1] Komunjer, I. (2006): "Asymmetric Power Distribution: Theory and 
%   Applications to Risk Measurement", Journal of Applied Econometrics (forthcoming)
%
% Author: Ivana Komunjer - UCSD (komunjer@ucsd.edu)
% Version: 2.1        Date: 09/11/2006

options = optimset('Display','iter','MaxFunEvals',800,'TolCon',1e-6,'TolFun',1e-6);

% par = [alpha00; alpha10; alpha20; alpha30; mu0; alpha0; lda0];
% Linear inequality constraints A.x <= b on the parameters of the model
delta = 0.0001; % some small number
A = zeros(10,7);
A(1,3) = -1;                % alpha2 > -0.2
A(2,3) = 1;                 % alpha2 < 0.2
A(3,2) = -1;                % alpha1 > -1
A(4,2) = 1;                 % alpha1 < 1
A(5,4) = -1;                % alpha3 > -0.2
A(6,4) = 1;                 % alpha3 < 0.2
A(7,6) = -1;                % alphaGPD >= 0.5
A(8,6) = 1;                 % alphaGPD <= 0.5
A(9,7) = -1;                % ldaAQ > 1
A(10,7) = 1;                % ldaAQ < 5;
b = [0.2-delta;0.2-delta;1-delta;1-delta;0.2-delta;0.2-delta;-0.5;0.5;-1-delta;5-delta];
[MLE,loglik,exitflag,output,lambda,grad,hessian] = ...
    fmincon(@GPDEGARCHLogLik,par0,A,b,[],[],[],[],[],options);

