diff --git a/matlab/perfect-foresight-models/perfect_foresight_with_expectation_errors_setup.m b/matlab/perfect-foresight-models/perfect_foresight_with_expectation_errors_setup.m index 2e7ad0b59..3b57d4559 100644 --- a/matlab/perfect-foresight-models/perfect_foresight_with_expectation_errors_setup.m +++ b/matlab/perfect-foresight-models/perfect_foresight_with_expectation_errors_setup.m @@ -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; diff --git a/matlab/perfect-foresight-models/perfect_foresight_with_expectation_errors_solver.m b/matlab/perfect-foresight-models/perfect_foresight_with_expectation_errors_solver.m index fdbdda3ce..0e9cd3f26 100644 --- a/matlab/perfect-foresight-models/perfect_foresight_with_expectation_errors_solver.m +++ b/matlab/perfect-foresight-models/perfect_foresight_with_expectation_errors_solver.m @@ -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; diff --git a/tests/Makefile.am b/tests/Makefile.am index b6ed5b9ae..ba975f066 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 \ diff --git a/tests/deterministic_simulations/pfwee_multiple_shocks.mod b/tests/deterministic_simulations/pfwee_multiple_shocks.mod new file mode 100644 index 000000000..8e5454d79 --- /dev/null +++ b/tests/deterministic_simulations/pfwee_multiple_shocks.mod @@ -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;