From f97c1386857969791bebf27193537f738d947aa3 Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Thu, 27 May 2021 22:35:33 +0200 Subject: [PATCH] sim1_purely_backward.m: for purely static model, do not use past value for first iteration Index 0 does not exist. --- matlab/perfect-foresight-models/sim1_purely_backward.m | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/matlab/perfect-foresight-models/sim1_purely_backward.m b/matlab/perfect-foresight-models/sim1_purely_backward.m index daee720ce..3f155325f 100644 --- a/matlab/perfect-foresight-models/sim1_purely_backward.m +++ b/matlab/perfect-foresight-models/sim1_purely_backward.m @@ -43,8 +43,13 @@ dynamicmodel_s = str2func('dynamic_backward_model_for_simulation'); info.status = true; for it = M.maximum_lag + (1:options.periods) - y = endogenousvariables(:,it-1); % Values at previous period, also used as guess value for current period - ylag = y(iyb); + if M.maximum_lag==0 && it==1 + y = endogenousvariables(:,it); % Values at previous period, also used as guess value for current period + ylag = []; + else + y = endogenousvariables(:,it-1); % Values at previous period, also used as guess value for current period + ylag = y(iyb); + end if ismember(options.solve_algo, [12,14]) [tmp, check] = dynare_solve(dynamicmodel_s, y, options, M.isloggedlhs, M.isauxdiffloggedrhs, M.endo_names, M.lhs, ... dynamicmodel, ylag, exogenousvariables, M.params, steadystate, it);