function  f = SkewTES(alpha_bar,xi,nu);
global GARCH_SERIES;
% SKEW_T_ES.M       Constructs the alpha_bar ES of a SKEW-T distribution 
%   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
% 
% 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

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;
% computes the alpha_bar quantile 
lda = (xi^2-1)/(xi^2+1);
q_bar = skewtdis_inv(alpha_bar, nu, lda);

f = q_bar + ((alpha_bar*(1+xi^2)/2)^(-1))*((xi^(-1))*c*(nu-2)/(nu-1)*(1+((xi*(s*q_bar+m))^2)/(nu-2))^(-1*(nu-1)/2) ... 
    + m*skewtdis_cdf(xi*(s*q_bar+m),nu,0));

