function out=sgmmj(THETA,par,ficm,NSTR)

global nobs init slong nsim nsec poids trunc nvar NTM
global eu ew;
global mom_h Omega
global r s kom phi0 nss beta wb Sel;

eval(['MOM=',ficm,'(THETA,NSTR);'])

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                           %
%                    Construction de la fonction objectif                   %
%                                                                           %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

diff_mom=MOM(:)-mom_h(:);
if par==1;
   out=nsim/(nsim+1)*diff_mom'*Omega*diff_mom;
   THETA(:)'
	[MOM(:) mom_h(:)]'
   disp(sprintf('J-Stat : %12.6f U : %6.2f',out,100-100*mean(NTM)))
elseif par==2;
   THETA(:)';
   [MOM(:) mom_h(:)];
	out=MOM(:);
else
   disp('Ne correspond à aucun cas envisagé dans la procédure d''estimation')
end