%RUNMLE     Compute MLE estimates for the benchmark model.  The likelihood 
%           function is in file mleq.m
%
                                                                                
%           Ellen McGrattan, 7-1-15
%           Revised, ERM, 7-1-15

load ../MLEdata/ldhpctot.dat
load ../MLEdata/ldgypc.dat
load ../MLEdata/ldhpc21.dat
load ../MLEparam/fixedpar.dat

global ZVAR
ZVAR  = [ldgypc(149:268,[1:15]),ldhpc21(149:268,[20,17,19])];
iest  = input('Compute new estimates? (1=yes,0=no) ');

x0=[ ...
   0.973987380000000
   0.983936860000000
   0.995000000000000
   0.987364760000000
   0.995000000000000
   0.976335760000000
   0.963338200000000
   0.957058380000000
   0.988589810000000
   0.138223740000000
   0.330325780000000
   0.325550860000000
   0.037926150000000
   0.071745700000000
   0.035687300000000
  -0.027167120000000
   0.026517240000000
   0.054167870000000
   0.038989980000000
   0.021903100000000
  -0.010898110000000
   0.027624960000000
   0.036794750000000
   0.080336570000000
   0.051403580000000
   0.014711900000000
  -0.010023020000000
   0.008438070000000
  -0.006948480000000
  -1.302693830000000
  -1.197412250000000
  -2.873862620000000
   1.427087270000000
   0.941599070000000
   0.712428840000000
   0.761068240000000
   1.167855590000000
   1.547388380000000
   2.201757850000000
   0.702501190000000
   0.191947680000000
   0.542150540000000
   0.611146300000000];

if (iest==1);
  [x1,f,g,code,status]   = uncmin(x0,'mleq',fixedpar);
else 
  x1 = x0;
end;
L  = mleq(x1,fixedpar);

%
% Print results 
%

disp('MLE Estimates')
disp('-------------')
disp(' ')
disp(sprintf(' %10.3e\n', x1'))
disp(' ')
fprintf('  L(Theta) = %g ',L)
disp(' ')



