From 1c01bacf36e80d9ffc285ca2fc9a022a28d5aaf6 Mon Sep 17 00:00:00 2001
From: Johannes Pfeifer <jpfeifer@gmx,de>
Date: Mon, 8 Dec 2014 08:45:32 +0100
Subject: [PATCH] Fix bug in dyn_forecast.m where forecasts after an initval
 block where computed at the initial values and not at the steady state

This contradicted the manual (histval must be used to do this). Also clarifies the manual on this.
---
 doc/dynare.texi       | 31 +++++++++++++++++++++++--------
 matlab/dyn_forecast.m |  2 +-
 2 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/doc/dynare.texi b/doc/dynare.texi
index 2b558d3f93..670eef8145 100644
--- a/doc/dynare.texi
+++ b/doc/dynare.texi
@@ -2160,20 +2160,24 @@ commands (@code{stoch_simul}, @code{estimation}@dots{}).
 It is not necessary to declare @code{0} as initial value for exogenous
 stochastic variables, since it is the only possible value.
 
-This steady state will be used as the initial condition at all the
-periods preceeding the first simulation period for the two possible
+The subsequently computed steady state (not the initial values, use @xref{histval} or this) will be used as the initial condition at all the 
+periods preceeding the first simulation period for the three possible
 types of simulations in stochastic mode:
 
 @itemize
 
 @item
-in @code{stoch_simul}, if the @code{periods} options is specified
+in @xref{stoch_simul}, if the @code{periods} options is specified
 
 @item
-in @code{forecast} (in this case, note that it is still possible to
-modify some of these initial values with @code{histval})
+in @xref{forecast} as the initial point at which the forecasts are computed
+
+@item
+in @xref{conditional_forecast} as the initial point at which the conditional forecasts are computed
 @end itemize
 
+To start simulations at a particular set of starting values that are not a computed steady state, use @xref{histval}.
+
 @optionshead
 
 @table @code
@@ -2386,11 +2390,22 @@ before (except when a @code{steady} command doesn't follow an
 @customhead{In a stochastic simulation context}
 
 In the context of stochastic simulations, @code{histval} allows setting
-the starting point of those simulations in the state space (it does not
-affect the starting point for impulse response functions). As for the case of
+the starting point of those simulations in the state space. As for the case of
 perfect foresight simulations, all not explicitly specified variables are set to 0.
 Moreover, as only states enter the recursive policy functions, all values specified for control variables will be ignored.
 
+@itemize
+
+@item
+in @xref{stoch_simul}, if the @code{periods} options is specified. Note that this only affects the starting point for the simulation, but not for the impulse response functions.
+
+@item
+in @xref{forecast} as the initial point at which the forecasts are computed
+
+@item
+in @xref{conditional_forecast} as the initial point at which the conditional forecasts are computed
+@end itemize
+
 For @ref{Ramsey} policy, it also specifies the values of the endogenous states at 
 which the objective function of the planner is computed. Note that the initial values 
 of the Lagrange multipliers associated with the planner's problem cannot be set
@@ -6247,7 +6262,7 @@ Fields are of the form:
 
 
 @deffn Command conditional_forecast (@var{OPTIONS}@dots{}) [@var{VARIABLE_NAME}@dots{}];
-
+@anchor{conditional_forecast}
 @descriptionhead
 
 This command computes forecasts on an estimated or calibrated model for a
diff --git a/matlab/dyn_forecast.m b/matlab/dyn_forecast.m
index b6ad8c9601..30b8674763 100644
--- a/matlab/dyn_forecast.m
+++ b/matlab/dyn_forecast.m
@@ -64,7 +64,7 @@ switch task
         horizon = 5;
     end
     if isempty(M_.endo_histval)
-        y0 = repmat(oo_.steady_state,1,maximum_lag);
+        y0 = repmat(oo_.dr.ys,1,maximum_lag);
     else
         y0 = M_.endo_histval;
     end
-- 
GitLab