Commit 510a9342 authored by MichelJuillard's avatar MichelJuillard

backward models: adding explicit solution guess

parent 7614186f
function simulation = simul_backward_model(initialconditions, samplesize, innovations) function simulation = simul_backward_model(initialconditions, samplesize, ...
innovations, guess)
% Simulates a stochastic backward looking model (with arbitrary precision). % Simulates a stochastic backward looking model (with arbitrary precision).
% %
...@@ -85,5 +86,6 @@ end ...@@ -85,5 +86,6 @@ end
if options_.linear if options_.linear
simulation = simul_backward_linear_model(initialconditions, samplesize, options_, M_, oo_, Innovations); simulation = simul_backward_linear_model(initialconditions, samplesize, options_, M_, oo_, Innovations);
else else
simulation = simul_backward_nonlinear_model(initialconditions, samplesize, options_, M_, oo_, Innovations); simulation = simul_backward_nonlinear_model(initialconditions, samplesize, ...
options_, M_, oo_, Innovations, guess);
end end
\ No newline at end of file
...@@ -24,6 +24,7 @@ samplesize = varargin{2}; ...@@ -24,6 +24,7 @@ samplesize = varargin{2};
DynareOptions = varargin{3}; DynareOptions = varargin{3};
DynareModel = varargin{4}; DynareModel = varargin{4};
DynareOutput = varargin{5}; DynareOutput = varargin{5};
guess = vararing{6};
% Test if the model is backward. % Test if the model is backward.
if DynareModel.maximum_lead if DynareModel.maximum_lead
...@@ -179,7 +180,12 @@ else ...@@ -179,7 +180,12 @@ else
end end
% Initialization of the returned simulations. % Initialization of the returned simulations.
DynareOutput.endo_simul = NaN(DynareModel.endo_nbr, samplesize+initialconditions.nobs); if isempty(guess)
DynareOutput.endo_simul = NaN(DynareModel.endo_nbr, samplesize+ ...
initialconditions.nobs);
else
DynareOutput.endo_simul = guess;
end
for i=1:length(endonames) for i=1:length(endonames)
if ismember(endonames{i}, initialconditions.name) if ismember(endonames{i}, initialconditions.name)
DynareOutput.endo_simul(i,1:initialconditions.nobs) = transpose(initialconditions{endonames{i}}.data); DynareOutput.endo_simul(i,1:initialconditions.nobs) = transpose(initialconditions{endonames{i}}.data);
......
...@@ -47,7 +47,11 @@ end ...@@ -47,7 +47,11 @@ end
% Simulations (call a Newton-like algorithm for each period). % Simulations (call a Newton-like algorithm for each period).
for it = initialconditions.nobs+(1:samplesize) for it = initialconditions.nobs+(1:samplesize)
ylag = DynareOutput.endo_simul(iy1,it-1); % Set lagged variables. ylag = DynareOutput.endo_simul(iy1,it-1); % Set lagged variables.
y = DynareOutput.endo_simul(:,it-1); % A good guess for the initial conditions is the previous values for the endogenous variables. if DynareOptions.use_current_guess
DynareOutput.endo_simul(:,it);
else
y = DynareOutput.endo_simul(:,it-1); % A good guess for the initial conditions is the previous values for the endogenous variables.
end
[DynareOutput.endo_simul(:,it), info, fvec] = dynare_solve(model_dynamic_s, ... [DynareOutput.endo_simul(:,it), info, fvec] = dynare_solve(model_dynamic_s, ...
y, DynareOptions, model_dynamic, ylag, DynareOutput.exo_simul, DynareModel.params, DynareOutput.steady_state, it); y, DynareOptions, model_dynamic, ylag, DynareOutput.exo_simul, DynareModel.params, DynareOutput.steady_state, it);
if info if info
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment