From 6d7218f9dc48aa5d16fd50e14b44bf1fb47895b0 Mon Sep 17 00:00:00 2001
From: ferhat <ferhat.mihoubi@univ-evry.fr>
Date: Wed, 11 Nov 2015 18:35:41 +0100
Subject: [PATCH] Fix bugs in det_cond_forecast.m

---
 .../perfect-foresight-models/det_cond_forecast.m   | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/matlab/perfect-foresight-models/det_cond_forecast.m b/matlab/perfect-foresight-models/det_cond_forecast.m
index 0c1070dc1a..bc43149047 100644
--- a/matlab/perfect-foresight-models/det_cond_forecast.m
+++ b/matlab/perfect-foresight-models/det_cond_forecast.m
@@ -34,7 +34,9 @@ pp = 2;
 initial_conditions = oo_.steady_state;
 verbosity = options_.verbosity;
 options_.verbosity = 0;
-
+if options_.periods == 0
+	options_.periods = 25;
+end;
 %We have to get an initial guess for the conditional forecast 
 % and terminal conditions for the non-stationary variables, we
 % use the first order approximation of the rational expectation solution.
@@ -134,11 +136,19 @@ else
                     oo_.endo_simul(M_.aux_vars(i).endo_index, 1:sym_dset.nobs) = repmat(oo_.steady_state(M_.aux_vars(i).endo_index), 1, range.ndat + 1);
                 end
             end
-            %Compute the initial path using the first order solution around the
+            %Compute the initial path using the the steady-state
             % steady-state
             for jj = 2 : (options_.periods + 2)
               oo_.endo_simul(:, jj) = oo_.steady_state;  
             end
+            missings = isnan(oo_.endo_simul(:,1));
+            if any(missings)
+                for jj = 1:M_.endo_nbr
+                    if missings(jj)
+                        oo_.endo_simul(jj,1) = oo_.steady_state(jj,1);
+                    end
+                end
+            end
 
             if options_.bytecode
                 save_options_dynatol_f = options_.dynatol.f;
-- 
GitLab