perfect_foresight_with_expectation_errors_{setup,solver}: fix bugs with several exogenous

Closes: #1883
silicon
Sébastien Villemot 2023-01-24 14:58:30 +01:00
parent 35b32ded34
commit 5aca770931
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
4 changed files with 43 additions and 4 deletions

View File

@ -1,6 +1,6 @@
function perfect_foresight_with_expectation_errors_setup
% Copyright © 2021-2022 Dynare Team
% Copyright © 2021-2023 Dynare Team
%
% This file is part of Dynare.
%
@ -69,7 +69,7 @@ else
%% Initialize information set at period 1 using “bare” shocks and endval blocks (or initval if there is no endval)
oo_.pfwee.terminal_info(:, 1) = oo_.exo_steady_state;
oo_.pfwee.shocks_info(:, :, 1) = oo_.exo_steady_state;
oo_.pfwee.shocks_info(:, :, 1) = repmat(oo_.exo_steady_state, 1, periods);
for i = 1:length(M_.det_shocks)
prds = M_.det_shocks(i).periods;
exo_id = M_.det_shocks(i).exo_id;

View File

@ -1,6 +1,6 @@
function perfect_foresight_with_expectation_errors_solver
% Copyright © 2021-2022 Dynare Team
% Copyright © 2021-2023 Dynare Team
%
% This file is part of Dynare.
%
@ -68,7 +68,7 @@ while info_period <= periods
oo_.endo_simul(:, end-M_.maximum_lead+1:end) = repmat(oo_.steady_state, 1, M_.maximum_lead);
oo_.exo_simul = exo_simul(info_period:end, :);
oo_.exo_simul(M_.maximum_lag+(1:periods-info_period+1), :) = oo_.pfwee.shocks_info(:, info_period:end, info_period)';
oo_.exo_simul(M_.maximum_lag+periods-info_period+2:end) = repmat(oo_.exo_steady_state, sim_length+M_.maximum_lead-(periods-info_period+1), 1);
oo_.exo_simul(M_.maximum_lag+periods-info_period+2:end, :) = repmat(oo_.exo_steady_state', sim_length+M_.maximum_lead-(periods-info_period+1), 1);
options_.periods = sim_length;

View File

@ -398,6 +398,7 @@ MODFILES = \
deterministic_simulations/pfwee.mod \
deterministic_simulations/pfwee_constant_sim_length.mod \
deterministic_simulations/pfwee_learnt_in.mod \
deterministic_simulations/pfwee_multiple_shocks.mod \
lmmcp/rbc.mod \
lmmcp/sw_lmmcp.mod \
lmmcp/sw_newton.mod \

View File

@ -0,0 +1,38 @@
// Test case with several exogenous variables (regression test for #1883)
var c k;
varexo x y;
parameters alph gam delt bet aa;
alph=0.5;
gam=0.5;
delt=0.02;
bet=0.05;
aa=0.5;
model;
c + k - aa*x*k(-1)^alph - (1-delt)*k(-1) +y;
c^(-gam) - (1+bet)^(-1)*(aa*alph*x(+1)*k^(alph-1) + 1 - delt)*c(+1)^(-gam);
end;
initval;
y=0;
x = 1;
k = ((delt+bet)/(1.0*aa*alph))^(1/(alph-1));
c = aa*k^alph-delt*k;
end;
steady;
check;
shocks(learnt_in=2);
var x;
periods 2:3;
values 1.2;
end;
perfect_foresight_with_expectation_errors_setup(periods = 7);
perfect_foresight_with_expectation_errors_solver;
rplot c;