From 87955c61d0513c64d1a0a746fe51eb698996be79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Hermes=29?= Date: Fri, 26 Feb 2016 21:31:50 +0100 Subject: [PATCH] Fixed bug in the routine simulating backward looking non linear stochastic models. --- matlab/simul_backward_nonlinear_model.m | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/matlab/simul_backward_nonlinear_model.m b/matlab/simul_backward_nonlinear_model.m index dd15d7e8f..9833faaa5 100644 --- a/matlab/simul_backward_nonlinear_model.m +++ b/matlab/simul_backward_nonlinear_model.m @@ -101,14 +101,18 @@ y = NaN(length(idx)+ny1,1); DynareOutput.endo_simul = NaN(DynareModel.endo_nbr,sample_size+1); DynareOutput.endo_simul(:,1) = DynareOutput.steady_state; +Y = DynareOutput.endo_simul; + % Simulations (call a Newton-like algorithm for each period). for it = 2:sample_size+1 - y(jdx) = DynareOutput.endo_simul(:,it-1); % A good guess for the initial conditions is the previous values for the endogenous variables. + y(jdx) = Y(:,it-1); % A good guess for the initial conditions is the previous values for the endogenous variables. y(hdx) = y(jdx(iy1)); % Set lagged variables. - y(jdx) = solve1(model_dynamic, y, idx, jdx, 1, DynareOptions.gstep, ... + z = solve1(model_dynamic, y, idx, jdx, 1, DynareOptions.gstep, ... DynareOptions.solve_tolf,DynareOptions.solve_tolx, ... DynareOptions.simul.maxit,DynareOptions.debug, ... DynareOutput.exo_simul, DynareModel.params, ... DynareOutput.steady_state, it); - DynareOutput.endo_simul(:,it) = y(jdx); -end \ No newline at end of file + Y(:,it) = z(jdx); +end + +DynareOuput.endo_simul = Y; \ No newline at end of file