From c6c906a1cdfdfae8242aacd141044fe403bbf81e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Thu, 29 Feb 2024 18:52:45 +0100
Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20marginal=20linearization?=
 =?UTF-8?q?=20in=20the=20context=20of=20perfect=5Fforesight=5Fwith=5Fexpec?=
 =?UTF-8?q?tation=5Ferrors=5Fsolver=20with=20homotopy?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The formula used to create the scenario in subsequent informational periods was
wrong.

See also message of commit c3d91d5ce8e93cfc02731669407776ba39c1c16d.
---
 matlab/perfect-foresight-models/perfect_foresight_solver.m | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/matlab/perfect-foresight-models/perfect_foresight_solver.m b/matlab/perfect-foresight-models/perfect_foresight_solver.m
index 1e6b517751..c7a4f12127 100644
--- a/matlab/perfect-foresight-models/perfect_foresight_solver.m
+++ b/matlab/perfect-foresight-models/perfect_foresight_solver.m
@@ -460,12 +460,12 @@ function [steady_success, endo_simul, exo_simul, steady_state, exo_steady_state]
 %   exo_steady_state [vector]    steady state of exogenous corresponding to the scenario (equal to the input if terminal steady state not recomputed)
 
 % Compute convex combination for the path of exogenous
-exo_simul = exoorig*share/shareorig + exobase*(1-share);
+exo_simul = exoorig*share/shareorig + exobase*(1-share/shareorig);
 
 % Compute convex combination for the initial condition
 % In most cases, the initial condition is a steady state and this does nothing
 % This is for cases when the initial condition is out of equilibrium
-endo_simul(:, initperiods) = share/shareorig*endoorig(:, initperiods)+(1-share)*endobase(:, initperiods);
+endo_simul(:, initperiods) = share/shareorig*endoorig(:, initperiods)+(1-share/shareorig)*endobase(:, initperiods);
 
 % If there is a permanent shock, ensure that the rescaled terminal condition is
 % a steady state (if the user asked for this recomputation, or if the original
@@ -518,7 +518,7 @@ if recompute_final_steady_state
     options_.markowitz = saved_steady_markowitz;
 else
     % The terminal condition is not a steady state, compute a convex combination
-    endo_simul(:, lastperiods) = share/shareorig*endoorig(:, lastperiods)+(1-share)*endobase(:, lastperiods);
+    endo_simul(:, lastperiods) = share/shareorig*endoorig(:, lastperiods)+(1-share/shareorig)*endobase(:, lastperiods);
 end
 
 
-- 
GitLab