function [MLE,loglik,exitflag,output,lambda,grad,hessian] = MLSkewTGARCH(par0);
global GARCH_SERIES;
% ML_SKEW_T_GARCH.M     Constructs the ML estimates for a Skew-t GARCH(1,1) 
%   process:
%       Y[t] = mu + sig[t]*eta[t] where
%       sig[t]^2 = alpha0 + alpha1*sig[t-1]^2 + alpha2*(Y[t-1]-mu)^2 and
%       eta[t] is Skew-t distributed with pdf (Giot and Laurent 2004):
%           p(x,xi,nu) =
%               (2/(xi+1/xi))*s*c*[1+((xi*(s*x+m))^2)/(nu-2)]^(-1*(nu+1)/2), if x<=-m/s
%           p(x,xi,nu) = 
%               (2/(xi+1/xi))*s*c*[1+(((s*x+m)/xi)^2)/(nu-2)]^(-1*(nu+1)/2), if x>=-m/s
%           with    c = (gamma((nu+1)/2))/(((pi*(nu-2))^0.5)*gamma(nu/2));
%                   m = gamma((nu-1)/2)*((nu-2)^0.5)*(xi-1/xi)/((pi^0.5)*gamma(nu/2));
%                   s = (xi^2+xi^(-2)-1-m^2)^0.5
%
% The objective function is SkewTLogLik.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; mu0; lda0; eta0];
% Linear inequality constraints A.x <= b on the parameters of the model
delta = 0.0001; % some small number
A = zeros(10,6);
A(1,2) = -1;                % alpha1 > 0
A(2,2) = 1;                 % alpha1 < 1
A(3,3) = -1;                % alpha2 > 0
A(4,3) = 1;                 % alpha2 < 1
A(5,2) = 1; A(5,3) = 1;     % alpha1 + alpha2 < 1
A(6,1) = -1;                % alpha0 > 0
A(7,5) = -1;                % xi > -1
A(8,5) = 1;                 % xi < 1
A(9,6) = -1;                % nu > 2
A(10,6) = 1;                % nu < 10;
b = [-delta;1-delta;-delta;1-delta;1-delta;-1e-6;1-delta;1-delta;-2-delta;10-delta];
[MLE,loglik,exitflag,output,lambda,grad,hessian] = ...
    fmincon(@SkewTGARCHLogLik,par0,A,b,[],[],[],[],[],options);

