Commit 80479f2d authored by Marco Ratto's avatar Marco Ratto
Browse files

add gabaix_check_long_run option for debug purposes

parent 3e5ec0ac
......@@ -341,6 +341,7 @@ options_.partial_information = false;
options_.ACES_solver = false;
options_.conditional_variance_decomposition = [];
options_.gabaix = false;
options_.gabaix_check_long_run = true;
% Ramsey policy
options_.ramsey_policy = false;
......
......@@ -21,44 +21,41 @@ if nargin<=4
Bbarmat = h_;
Abarmat = hl1_; % lead
% check BK of behavioral model, to make sure it solves in forward looking mode
klen = M_.maximum_lag + M_.maximum_lead + 1;
exo_simul = [repmat(oo_.exo_steady_state',klen,1) repmat(oo_.exo_det_steady_state',klen,1)];
iyv = M_.lead_lag_incidence';
iyv = iyv(:);
iyr0 = find(iyv) ;
it_ = M_.maximum_lag + 1;
z = repmat(oo_.dr.ys,1,klen);
task=1; % only check eigvals
[~,jacobia_] = feval([M_.fname '.dynamic'],z(iyr0),exo_simul, ...
Mbase_.params, oo_.dr.ys, it_);
[dr,info] = dyn_first_order_solver(jacobia_,Mbase_,oo_.dr,DynareOptions,task);
% if info(1)
% A=[];
% B=[];
% return
% end
% invmat = inv(Bbarmat+Abarmat*A);
% A = -invmat*Cbarmat;
A = -(Bbarmat+Abarmat*A)\Cbarmat;
% max_eig = max(abs(eig(A)));
% if isempty(DynareOptions.qz_criterium)
% DynareOptions.qz_criterium = 1+1e-6;
% end
% if max_eig>DynareOptions.qz_criterium
% info(1)=3;
% info(2)=(max_eig-DynareOptions.qz_criterium)^2;
% A=[];
% B=[];
% return
% end
% E = [zeros(length(A)) -Cbarmat; eye(length(A)) zeros(length(A))];
% D = [Abarmat Bbarmat; zeros(length(A)) eye(length(A))];
% [ss, tt, w, sdim, dr.eigval, info1] = mjdgges(E, D, DynareOptions.qz_criterium, DynareOptions.qz_zero_threshold);
if options_.gabaix_check_long_run
% check BK of behavioral model, to make sure it solves in forward looking mode
klen = M_.maximum_lag + M_.maximum_lead + 1;
exo_simul = [repmat(oo_.exo_steady_state',klen,1) repmat(oo_.exo_det_steady_state',klen,1)];
iyv = M_.lead_lag_incidence';
iyv = iyv(:);
iyr0 = find(iyv) ;
it_ = M_.maximum_lag + 1;
z = repmat(oo_.dr.ys,1,klen);
task=1; % only check eigvals
[~,jacobia_] = feval([M_.fname '.dynamic'],z(iyr0),exo_simul, ...
Mbase_.params, oo_.dr.ys, it_);
[dr,info] = dyn_first_order_solver(jacobia_,Mbase_,oo_.dr,DynareOptions,task);
if info(1)
A=[];
B=[];
return
else
A = -(Bbarmat+Abarmat*A)\Cbarmat;
end
% B = -invmat*Jbarmat_;
else
A = -(Bbarmat+Abarmat*A)\Cbarmat;
max_eig = max(abs(eig(A)));
if isempty(DynareOptions.qz_criterium)
DynareOptions.qz_criterium = 1+1e-6;
end
if max_eig>DynareOptions.qz_criterium
info(1)=3;
info(2)=(max_eig-DynareOptions.qz_criterium)^2;
A=[];
B=[];
return
end
end
B = -(Bbarmat+Abarmat*A)\Jbarmat_;
endo_nbr = Model.endo_nbr;
nstatic = Model.nstatic;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment