Merge branch 'sylvester' into 'master'
Fix for sylvester3a for purely forward looking models See merge request Dynare/dynare!1775time-shift
commit
2c7a1e8aec
|
@ -1,7 +1,7 @@
|
||||||
function [x0, flag]=sylvester3a(x0,a,b,c,dd)
|
function [x0, flag]=sylvester3a(x0,a,b,c,dd)
|
||||||
% solves iteratively ax+bxc=d
|
% solves iteratively ax+bxc=d
|
||||||
|
|
||||||
% Copyright (C) 2005-2017 Dynare Team
|
% Copyright (C) 2005-2017,2020 Dynare Team
|
||||||
%
|
%
|
||||||
% This file is part of Dynare.
|
% This file is part of Dynare.
|
||||||
%
|
%
|
||||||
|
@ -25,7 +25,7 @@ for j=1:size(dd,3)
|
||||||
d = a_1*dd(:,:,j);
|
d = a_1*dd(:,:,j);
|
||||||
e = 1;
|
e = 1;
|
||||||
iter = 1;
|
iter = 1;
|
||||||
while e > 1e-8 && iter < 500
|
while all(e > 1e-8) && iter < 500 %use all() to get a logical in case e is empty
|
||||||
x = d-b*x0(:,:,j)*c;
|
x = d-b*x0(:,:,j)*c;
|
||||||
e = max(max(abs(x-x0(:,:,j))));
|
e = max(max(abs(x-x0(:,:,j))));
|
||||||
x0(:,:,j) = x;
|
x0(:,:,j) = x;
|
||||||
|
|
|
@ -217,6 +217,7 @@ MODFILES = \
|
||||||
identification/rbc_ident/rbc_ident_std_as_structural_par.mod \
|
identification/rbc_ident/rbc_ident_std_as_structural_par.mod \
|
||||||
identification/rbc_ident/rbc_ident_varexo_only.mod \
|
identification/rbc_ident/rbc_ident_varexo_only.mod \
|
||||||
identification/correlated_errors/fs2000_corr.mod \
|
identification/correlated_errors/fs2000_corr.mod \
|
||||||
|
identification/forward_looking/forward_looking.mod \
|
||||||
simul/example1.mod \
|
simul/example1.mod \
|
||||||
simul/Solow_no_varexo.mod \
|
simul/Solow_no_varexo.mod \
|
||||||
simul/simul_ZLB_purely_forward.mod \
|
simul/simul_ZLB_purely_forward.mod \
|
||||||
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
% Forward-looking example model from Koop, Pesaran, Smith (2013, JBES)
|
||||||
|
% created by Willi Mutschler (@wmutschl, willi@mutschler.eu)
|
||||||
|
% =========================================================================
|
||||||
|
% Copyright (C) 2020 Dynare Team
|
||||||
|
%
|
||||||
|
% This file is part of Dynare.
|
||||||
|
%
|
||||||
|
% Dynare is free software: you can redistribute it and/or modify
|
||||||
|
% it under the terms of the GNU General Public License as published by
|
||||||
|
% the Free Software Foundation, either version 3 of the License, or
|
||||||
|
% (at your option) any later version.
|
||||||
|
%
|
||||||
|
% Dynare is distributed in the hope that it will be useful,
|
||||||
|
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
% GNU General Public License for more details.
|
||||||
|
%
|
||||||
|
% You should have received a copy of the GNU General Public License
|
||||||
|
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
% =========================================================================
|
||||||
|
var r x p;
|
||||||
|
varexo e_M e_D e_S;
|
||||||
|
varobs r x p;
|
||||||
|
|
||||||
|
parameters PSI TAU BETA KAPPA;
|
||||||
|
|
||||||
|
PSI=1.1;
|
||||||
|
TAU=2;
|
||||||
|
BETA=0.9;
|
||||||
|
KAPPA=0.6;
|
||||||
|
|
||||||
|
model;
|
||||||
|
r = PSI*p + e_M;
|
||||||
|
x = x(+1) - 1/TAU*(r-p(+1)) + e_D;
|
||||||
|
p = BETA*p(+1) + KAPPA*x + e_S;
|
||||||
|
end;
|
||||||
|
|
||||||
|
shocks;
|
||||||
|
var e_M = 1;
|
||||||
|
var e_D = 1;
|
||||||
|
var e_S = 1;
|
||||||
|
end;
|
||||||
|
|
||||||
|
steady;
|
||||||
|
check;
|
||||||
|
|
||||||
|
estimated_params;
|
||||||
|
PSI, 1.1;
|
||||||
|
TAU, 2;
|
||||||
|
BETA, 0.9;
|
||||||
|
KAPPA, 0.6;
|
||||||
|
end;
|
||||||
|
|
||||||
|
identification; %this triggers sylvester3a with empty ghx
|
||||||
|
|
||||||
|
% as a side note, we have the true solution:
|
||||||
|
% [r;x;p] = TRUE_SOLUTION*[e_M;e_D;e_S] (ghx is empty)
|
||||||
|
A = [1 0 -PSI; 1/TAU 1 0; 0 -KAPPA 1];
|
||||||
|
TRUE_SOLUTION1 = inv(A);
|
||||||
|
TRUE_SOLUTION2 = 1/(KAPPA*PSI/TAU +1)*[1 KAPPA*PSI PSI;
|
||||||
|
-1/TAU 1 -PSI/TAU;
|
||||||
|
-KAPPA/TAU KAPPA 1];
|
||||||
|
% note that BETA drops out from the solution
|
||||||
|
|
||||||
|
if max(max(abs(TRUE_SOLUTION1 - oo_.dr.ghu))) > 1e-15
|
||||||
|
error('Something wrong with perturbation');
|
||||||
|
end
|
||||||
|
if max(max(abs(TRUE_SOLUTION2 - oo_.dr.ghu))) > 1e-15
|
||||||
|
error('Something wrong with perturbation');
|
||||||
|
end
|
Loading…
Reference in New Issue