% After the first round of GMM is done, this code finds the minimum of fval.

clear;
load 'C:\Users\LoweryR\Documents\My Dropbox\UND_research_Banking\Final_files\output_files\GMM1st_KLW.mat'

% Note that this is different from afterGMM1st_v28_KLW.m as we don't do optimization with tighter criteria (e.g.10^-24). It is already done in GMM1st_KLW.m
% x and x_initial are almost the same.

x_1stGMM = x_opt;
fval_1stGMM = fval_opt;
exitflag_1stGMM = exitflag_opt;
[x1_new,f1_old,f1_new,minf,x_minf] = fn_obj_KLW(x_1stGMM);
[fval_1stGMM;f1_new;minf] % check if objectives values are close enough.
[x_1stGMM;x1_new] % check if argmin values are close enough.

save('C:\Users\LoweryR\Documents\My Dropbox\UND_research_Banking\Final_files\output_files\theta_GMM1st_KLW.mat','x_1stGMM','fval_1stGMM','exitflag_1stGMM');