
clc

% CALIBRATION

par.bet  = .99;
par.the  = -1;
par.mu   = .4;
par.phi  = 0;
par.psi  = 1;
par.del  = .025;
par.sig  = .73;
par.alf  = .9;
par.gam  = 1/3;
par.Q    = 0.06;
par.H    = .96;

% INITIAL VALUES (c n i s xi)

if flag==1;
  val = res; 
else
  val = [0.331 .324 0.069 0.060 0.373]';
end

% FIND SS

%ststclosed(val,par);
stst(val,par);
%resclosed = fsolve(@(x) ststclosed(x,par), val);
[res,xxx,flag] = fsolve(@(x) stst(x,par), val);

[xxx,out] = stst(res,par);

disp(out) % check xi>=0!!!
