function [that, fval]=estimate_GMM(yB,yA,y1,y2,y3,y4,xB,xA,x1,x2,x3,x4,thstart,W0,print,should_scale)
   
    x=thstart;

    A = [];
    b = [];
    Aeq = [];
    beq = [];
    lb=0*x-6;
    ub=0*x+6;
    fun=@(th)fct1(yB,yA,y1,y2,y3,y4,xB,xA,x1,x2,x3,x4,th,W0,0,should_scale);
    opti=optimoptions(@fmincon,'MaxFunctionEvaluations',10000,'MaxIterations',10000,'Display','off');
    [x,fval] = fmincon(fun, x,A,b,Aeq,beq,lb,ub,[],opti);
    if print
        fprintf('  Fminunc =%9.4f ',fval)
    end
 
    that=x;
end