Remove calls to dbstack in dynare_solve.

Adding three input parameters for maxit, tolf and tolx.

Closes #1841.
fix-nonlinear-solvers
Stéphane Adjemian (Charybdis) 2022-04-10 15:51:55 +02:00 committed by Stéphane Adjemian (Ryûk)
parent 01203f7e39
commit f1aff2b370
Signed by: stepan
GPG Key ID: 295C1FE89E17EB3C
20 changed files with 96 additions and 112 deletions

View File

@ -1,13 +1,13 @@
function [filtered_errs, resids, Emat, stateval, error_code] = IVF_core(M_,oo_,options_,err_index,filtered_errs_init,my_obs_list,obs,init_val)
% function [filtered_errs, resids, Emat, stateval] = IVF_core(M_,oo_,options_,err_index,filtered_errs_init,my_obs_list,obs,init_val)
% Computes thre
% Computes thre
%
% Outputs:
% - filtered_errs [T by N_obs] filtered shocks
% - resids [T by N_obs] residuals
% - Emat [N by N_obs by T] response matrix of endogenous variables to shocks at each point in time
% - stateval [T by N] vector of endogenous variables
% - error_code [4 by 1] error code
% - error_code [4 by 1] error code
%
% Inputs
% - M_ [structure] Matlab's structure describing the model (M_).
@ -16,7 +16,7 @@ function [filtered_errs, resids, Emat, stateval, error_code] = IVF_core(M_,oo_,o
% - err_index [double] index of shocks with strictly positive variance in M_.exo_names
% - filtered_errs_init [T by N_obs] initial values for the shocks
% - my_obs_list [cell] names of observables
% - obs [T by N_obs] observed data
% - obs [T by N_obs] observed data
% - init_val [N by 1] initial value of endogenous variables
% Original authors: Pablo Cuba-Borda, Luca Guerrieri, Matteo Iacoviello, and Molin Zhong
@ -28,7 +28,7 @@ function [filtered_errs, resids, Emat, stateval, error_code] = IVF_core(M_,oo_,o
% However the authors would appreciate acknowledgement of the source by
% citation of any of the following papers:
%
% Pablo Cuba-Borda, Luca Guerrieri, Matteo Iacoviello, and Molin Zhong (2019): "Likelihood evaluation of models
% Pablo Cuba-Borda, Luca Guerrieri, Matteo Iacoviello, and Molin Zhong (2019): "Likelihood evaluation of models
% with occasionally binding constraints", Journal of Applied Econometrics,
% 34(7), 1073-1085
@ -70,14 +70,14 @@ if options_.occbin.likelihood.waitbar
hh = dyn_waitbar(0,'IVF_core: Filtering the shocks');
set(hh,'Name','IVF_core: Filtering the shocks.');
end
for this_period=1:sample_length
if options_.occbin.likelihood.waitbar
dyn_waitbar(this_period/sample_length, hh, sprintf('Period %u of %u', this_period,sample_length));
end
current_obs = obs(this_period,:);
init_val_old = init_val;
inan = ~isnan(current_obs);
current_obs = current_obs(inan);
obs_list = my_obs_list(inan);
@ -85,23 +85,20 @@ for this_period=1:sample_length
opts_simul.exo_pos=err_index(inan); %err_index is predefined mapping from observables to shocks
opts_simul.endo_init = init_val_old;
opts_simul.SHOCKS = filtered_errs_init(this_period,inan);
% [ err_vals_out, exitflag ] = csolve(@(err_vals) occbin.match_function(...
% err_vals, obs_list,current_obs, opts_simul, M_,oo_,options_),...
% err0',@(err_vals) occbin.match_function(...
% err_vals, obs_list,current_obs, opts_simul, M_,oo_,options_),options_.solve_tolf,options_.occbin.solver.maxit);
[err_vals_out, exitflag] = dynare_solve(@occbin.match_function, filtered_errs_init(this_period,inan)', options_, obs_list,current_obs, opts_simul, M_,oo_,options_);
% TODO We should probably have a specific field for maxit (new option?)
[err_vals_out, exitflag] = dynare_solve(@occbin.match_function, filtered_errs_init(this_period,inan)', options_.steady.maxit, options_.solve_tolf, options_.solve_tolx, options_, obs_list, current_obs, opts_simul, M_, oo_, options_);
if exitflag
filtered_errs=NaN;
error_code(1) = 304;
error_code(4) = 1000;
if options_.occbin.likelihood.waitbar; dyn_waitbar_close(hh); end
return
return
end
filtered_errs(this_period,inan)=err_vals_out';
opts_simul.SHOCKS = err_vals_out;
[ resids(this_period,inan), ~, stateval(this_period,:), Emat(:,inan,this_period), M_] = occbin.match_function(...
err_vals_out,obs_list,current_obs,opts_simul, M_,oo_,options_);
init_val = stateval(this_period,:); %update
@ -123,7 +120,7 @@ for this_period=1:sample_length
end
end
if options_.occbin.likelihood.waitbar
dyn_waitbar_close(hh);
dyn_waitbar_close(hh);
end
end

View File

@ -108,7 +108,9 @@ for t = 1:nobs(constraints)
% values) and the free exogenous variables (initialized with 0).
z = [Y(freeendogenousvariables_id,ity-1); zeros(nxfree, 1)];
% Solves for z.
[z, failed, ~, ~, errorcode] = dynare_solve(model_dtransf, z, DynareOptions, model_dynamic, ylag, ycur, X, DynareModel.params, DynareOutput.steady_state, itx, ModelInversion);
[z, failed, ~, ~, errorcode] = dynare_solve(model_dtransf, z, ...
DynareOptions.simul.maxit, DynareOptions.dynatol.f, DynareOptions.dynatol.x, ...
DynareOptions, model_dynamic, ylag, ycur, X, DynareModel.params, DynareOutput.steady_state, itx, ModelInversion);
if failed
error('Nonlinear solver failed with errorcode=%i', errorcode)
end

View File

@ -56,13 +56,16 @@ for it = initialconditions.nobs+(1:samplesize)
y = y_; % A good guess for the initial conditions is the previous values for the endogenous variables.
try
if ismember(DynareOptions.solve_algo, [12,14])
[DynareOutput.endo_simul(:,it), errorflag, ~, ~, errorcode] = ...
dynare_solve(model_dynamic_s, y, DynareOptions, ...
DynareModel.isloggedlhs, DynareModel.isauxdiffloggedrhs, DynareModel.endo_names, DynareModel.lhs, ...
model_dynamic, ylag, DynareOutput.exo_simul, DynareModel.params, DynareOutput.steady_state, it);
[DynareOutput.endo_simul(:,it), errorflag, ~, ~, errorcode] = dynare_solve(model_dynamic_s, y, ...
DynareOptions.simul.maxit, DynareOptions.dynatol.f, DynareOptions.dynatol.x, ...
DynareOptions, ...
DynareModel.isloggedlhs, DynareModel.isauxdiffloggedrhs, DynareModel.endo_names, DynareModel.lhs, ...
model_dynamic, ylag, DynareOutput.exo_simul, DynareModel.params, DynareOutput.steady_state, it);
else
[DynareOutput.endo_simul(:,it), errorflag, ~, ~, errorcode] = ...
dynare_solve(model_dynamic_s, y, DynareOptions, ...
dynare_solve(model_dynamic_s, y, ...
DynareOptions.simul.maxit, DynareOptions.dynatol.f, DynareOptions.dynatol.x, ...
DynareOptions, ...
model_dynamic, ylag, DynareOutput.exo_simul, DynareModel.params, DynareOutput.steady_state, it);
end
if errorflag

View File

@ -1,6 +1,5 @@
function [steady_state,params,check] = dyn_ramsey_static(ys_init,M,options_,oo)
function [steady_state, params, check] = dyn_ramsey_static(ys_init, M, options_, oo)
% function [steady_state,params,check] = dyn_ramsey_static_(ys_init,M,options_,oo)
% Computes the steady state for optimal policy
%
% INPUTS
@ -18,7 +17,7 @@ function [steady_state,params,check] = dyn_ramsey_static(ys_init,M,options_,oo)
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2003-2020 Dynare Team
% Copyright © 2003-2022 Dynare Team
%
% This file is part of Dynare.
%
@ -66,9 +65,8 @@ elseif options_.steadystate_flag
%initial value for instrument
opt = options_;
opt.jacobian_flag = false;
[inst_val,info1] = dynare_solve(nl_func,ys_init(k_inst), ...
opt);
if info1~=0
[inst_val, errorflag] = dynare_solve(nl_func, ys_init(k_inst), options_.ramsey.maxit, options_.solve_tolf, options_.solve_tolx, opt);
if errorflag
check=81;
end
end
@ -81,8 +79,8 @@ else
xx = oo.steady_state(1:n_var);
opt = options_;
opt.jacobian_flag = false;
[xx,info1] = dynare_solve(nl_func,xx,opt);
if info1~=0
[xx, errorflag] = dynare_solve(nl_func, xx, options_.ramsey.maxit, options_.solve_tolf, options_.solve_tolx, opt);
if errorflag
check=81;
end
[~,~,steady_state] = nl_func(xx);

View File

@ -1,4 +1,4 @@
function [x, errorflag, fvec, fjac, errorcode] = dynare_solve(f, x, options, varargin)
function [x, errorflag, fvec, fjac, errorcode] = dynare_solve(f, x, maxit, tolf, tolx, options, varargin)
% Solves a nonlinear system of equations, f(x) = 0 with n unknowns
% and n equations.
@ -41,32 +41,6 @@ function [x, errorflag, fvec, fjac, errorcode] = dynare_solve(f, x, options, var
jacobian_flag = options.jacobian_flag; % true iff Jacobian is returned by f routine (as a second output argument).
% Set tolerance parameter depending the the caller function.
stack = dbstack;
if isoctave
[~, name, ext]=fileparts(stack(2).file);
caller_file_name=[name,ext];
else
if size(stack,1)>1
caller_file_name=stack(2).file;
else
caller_file_name=stack(1).file;
end
end
if strcmp(caller_file_name, 'solve_stacked_problem.m') || strcmp(caller_file_name, 'sim1_purely_backward.m')
tolf = options.dynatol.f;
tolx = options.dynatol.x;
else
tolf = options.solve_tolf;
tolx = options.solve_tolx;
end
if strcmp(caller_file_name,'dyn_ramsey_static.m')
maxit = options.ramsey.maxit;
else
maxit = options.steady.maxit;
end
errorflag = false; % Let's be optimistic!
nn = size(x,1);
@ -96,6 +70,7 @@ else
end
% checking initial values
% TODO We should have an option to deactivate the randomization.
if jacobian_flag
[fvec, fjac] = feval(f, x, arguments{:});
wrong_initial_guess_flag = false;

View File

@ -1,5 +1,6 @@
function [x,info] = dynare_solve_block_or_bytecode(y, exo, params, options, M)
% Copyright (C) 2010-2022 Dynare Team
% Copyright © 2010-2022 Dynare Team
%
% This file is part of Dynare.
%
@ -25,12 +26,11 @@ if options.block && ~options.bytecode
if M.block_structure_stat.block(b).Simulation_Type ~= 1 && ...
M.block_structure_stat.block(b).Simulation_Type ~= 2
if options.solve_algo <= 4 || options.solve_algo >= 9
[y, check] = dynare_solve('block_mfs_steadystate', ...
ss(M.block_structure_stat.block(b).variable), ...
options, b, ss, exo, params, T, M);
if check ~= 0
% error(['STEADY: convergence
% problems in block ' int2str(b)])
[y, errorflag] = dynare_solve('block_mfs_steadystate', ...
ss(M.block_structure_stat.block(b).variable), ...
options.simul.maxit, options.solve_tolf, options.solve_tolx, ...
options, b, ss, exo, params, T, M);
if errorflag
info = 1;
return
end
@ -65,13 +65,11 @@ elseif options.bytecode
for b = 1:length(M.block_structure_stat.block)
if M.block_structure_stat.block(b).Simulation_Type ~= 1 && ...
M.block_structure_stat.block(b).Simulation_Type ~= 2
[y, check] = dynare_solve('block_bytecode_mfs_steadystate', ...
x(M.block_structure_stat ...
.block(b).variable), ...
options, b, x, exo, params, T, M);
if check
% error(['STEADY: convergence problems in block '
% int2str(b)])
[y, errorflag] = dynare_solve('block_bytecode_mfs_steadystate', ...
x(M.block_structure_stat.block(b).variable), ...
options.simul.maxit, options.solve_tolf, options.solve_tolx, ...
options, b, x, exo, params, T, M);
if errorflag
info = 1;
return
end
@ -89,10 +87,10 @@ elseif options.bytecode
end
end
else
[x, check] = dynare_solve('bytecode_steadystate', y, ...
options, exo, params);
if check
% error('STEADY: convergence problems')
[x, errorflag] = dynare_solve('bytecode_steadystate', y, ...
options.simul.maxit, options.solve_tolf, options.solve_tolx, ...
options, exo, params);
if errorflag
info = 1;
return
end

View File

@ -143,9 +143,5 @@ Options.steady.maxit = 100;
y = repmat(steady_state,block_nbr,1);
Options.solve_algo = Options.ep.solve_algo;
Options.steady.maxit = Options.ep.maxit;
[y, errorflag, ~, ~, errorcode] = dynare_solve(@ep_problem_2,y,Options,exo_simul,pfm);
if info
flag = 1;
err = info;
end
[y, errorflag, ~, ~, errorcode] = dynare_solve(@ep_problem_2, y, Options.simul.maxit, Options.dynatol.f, Options.dynatol.x, Options, exo_simul, pfm);
endo_simul(:,2) = y(1:ny);

View File

@ -261,18 +261,14 @@ elseif steadystate_flag
elseif ~options.bytecode && ~options.block
if ~options.linear
% non linear model
static_model = str2func([M.fname '.static']);
[ys, check] = dynare_solve(@static_problem, ...
ys_init, ...
options, exo_ss, params, ...
M.endo_nbr, ...
static_model);
static_model = str2func(sprintf('%s.static', M.fname));
[ys, check] = dynare_solve(@static_problem, ys_init, ...
options.steady.maxit, options.solve_tolf, options.solve_tolx, ...
options, exo_ss, params, M.endo_nbr, static_model);
if check && options.debug
[ys, check, fvec, fjac, errorcode] = dynare_solve(@static_problem, ...
ys_init, ...
options, exo_ss, params, ...
M.endo_nbr, ...
static_model);
[ys, check, fvec, fjac, errorcode] = dynare_solve(@static_problem, ys_init, ...
options.steady.maxit, options.solve_tolf, options.solve_tolx, ...
options, exo_ss, params, M.endo_nbr, static_model);
dprintf('Nonlinear solver routine returned errorcode=%i.', errorcode)
skipline()
[infrow,infcol]=find(isinf(fjac) | isnan(fjac));

View File

@ -127,5 +127,5 @@ elseif ~isempty(options.steadystate_partial)
for i = 1:nov
indv(i) = strmatch(ssvar(i), M.endo_names, 'exact');
end
ys = dynare_solve('restricted_steadystate', ys(indv), options, exo_ss,indv);
ys = dynare_solve('restricted_steadystate', ys(indv), options.steady.maxit, options.dynatol.f, options.dynatol.x, options, exo_ss, indv);
end

View File

@ -91,9 +91,8 @@ else
oo_.exo_det_steady_state], M_.params))) > options_.solve_tolf
opt = options_;
opt.jacobian_flag = false;
[dr.ys,check1] = dynare_solve(fh,dr.ys,opt,...
[oo_.exo_steady_state; ...
oo_.exo_det_steady_state], M_.params);
[dr.ys, check1] = dynare_solve(fh,dr.ys, options.steady_.maxit, options_.solve_tolf, options_.solve_tolx, ...
opt, [oo_.exo_steady_state; oo_.exo_det_steady_state], M_.params);
end
else
% linear models

View File

@ -89,7 +89,9 @@ if options_.ramsey_policy && ~options_.ACES_solver
% options_.solve_algo = 1;
opt = options_;
opt.jacobian_flag = false;
oo_.steady_state = dynare_solve('ramsey_static',oo_.steady_state,opt,M_,options_,oo_,it_);
oo_.steady_state = dynare_solve('ramsey_static', oo_.steady_state, ...
options_.ramsey.maxit, options_.solve_tolf, options_.solve_tolx, ...
opt, M_, options_, oo_, it_);
options_.solve_algo = old_solve_algo;
[~,~,multbar] = ramsey_static(oo_.steady_state,M_,options_,oo_,it_);
[jacobia_,M_] = ramsey_dynamic(oo_.steady_state,multbar,M_,options_,oo_,it_);

View File

@ -39,11 +39,14 @@ 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 ismember(options.solve_algo, [12,14])
[tmp, check, ~, ~, errorcode] = dynare_solve(dynamicmodel_s, y, options, M.isloggedlhs, M.isauxdiffloggedrhs, M.endo_names, M.lhs, ...
[tmp, check, ~, ~, errorcode] = dynare_solve(dynamicmodel_s, y, ...
options.simul.maxit, options.dynatol.f, options.dynatol.x, ...
options, M.isloggedlhs, M.isauxdiffloggedrhs, M.endo_names, M.lhs, ...
dynamicmodel, ylag, exogenousvariables, M.params, steadystate, it);
else
[tmp, check, ~, ~, errorcode] = dynare_solve(dynamicmodel_s, y, options, ...
dynamicmodel, ylag, exogenousvariables, M.params, steadystate, it);
[tmp, check, ~, ~, errorcode] = dynare_solve(dynamicmodel_s, y, ...
options.simul.maxit, options.dynatol.f, options.dynatol.x, ...
options, dynamicmodel, ylag, exogenousvariables, M.params, steadystate, it);
end
if check
info.status = false;

View File

@ -33,10 +33,14 @@ info.status = true;
for it = options.periods:-1:1
yf = endogenousvariables(:,it+1); % Values at next period, also used as guess value for current period
if ismember(options.solve_algo, [12,14])
[tmp, check, ~, ~, errorcode] = dynare_solve(dynamicmodel_s, yf, options, M.isloggedlhs, M.isauxdiffloggedrhs, M.endo_names, M.lhs, ...
[tmp, check, ~, ~, errorcode] = dynare_solve(dynamicmodel_s, yf, ...
options.simul.maxit, options.dynatol.f, options.dynatol.x, ...
options, M.isloggedlhs, M.isauxdiffloggedrhs, M.endo_names, M.lhs, ...
dynamicmodel, yf(iyf), exogenousvariables, M.params, steadystate, it);
else
[tmp, check, ~, ~, errorcode] = dynare_solve(dynamicmodel_s, yf, options, ...
[tmp, check, ~, ~, errorcode] = dynare_solve(dynamicmodel_s, yf, ...
options.simul.maxit, options.dynatol.f, options.dynatol.x, ...
options, ...
dynamicmodel, yf(iyf), exogenousvariables, M.params, steadystate, it);
end
if check

View File

@ -36,11 +36,14 @@ y = endogenousvariables(:,1);
for it = 1:options.periods
if ismember(options.solve_algo, [12,14])
[tmp, check, ~, ~, errorcode] = dynare_solve(dynamicmodel_s, y, options, M.isloggedlhs, M.isauxdiffloggedrhs, M.endo_names, M.lhs, ...
[tmp, check, ~, ~, errorcode] = dynare_solve(dynamicmodel_s, y, ...
options.simul.maxit, options.dynatol.f, options.dynatol.x, ...
options, M.isloggedlhs, M.isauxdiffloggedrhs, M.endo_names, M.lhs, ...
dynamicmodel, exogenousvariables, M.params, steadystate, it);
else
[tmp, check, ~, ~, errorcode] = dynare_solve(dynamicmodel_s, y, options, ...
dynamicmodel, exogenousvariables, M.params, steadystate, it);
[tmp, check, ~, ~, errorcode] = dynare_solve(dynamicmodel_s, y, ...
options.simul.maxit, options.dynatol.f, options.dynatol.x, ...
options, dynamicmodel, exogenousvariables, M.params, steadystate, it);
end
if check
info.status = false;

View File

@ -41,7 +41,9 @@ jendo = transpose(1:nd);
z = bsxfun(@minus, z, steadystate_y);
x = bsxfun(@minus, exogenousvariables, steadystate_x');
[y, check, ~, ~, errorcode] = dynare_solve(@linear_perfect_foresight_problem,z(:), options, ...
[y, check, ~, ~, errorcode] = dynare_solve(@linear_perfect_foresight_problem, z(:), ...
options.simul.maxit, options.dynatol.f, options.dynatol.x, ...
options, ...
jacobian, y0-steadystate_y, yT-steadystate_y, ...
x, M.params, steadystate_y, ...
M.maximum_lag, options.periods, M.endo_nbr, i_cols, ...

View File

@ -46,14 +46,18 @@ if (options.solve_algo == 10 || options.solve_algo == 11)% mixed complementarity
options.mcppath.lb = repmat(lb,options.periods,1);
options.mcppath.ub = repmat(ub,options.periods,1);
end
[y, check, ~, ~, errorcode] = dynare_solve(@perfect_foresight_mcp_problem,z(:),options, ...
[y, check, ~, ~, errorcode] = dynare_solve(@perfect_foresight_mcp_problem, z(:), ...
options.simul.maxit, options.dynatol.f, options.dynatol.x, ...
options, ...
dynamicmodel, y0, yT, ...
exogenousvariables, M.params, steadystate, ...
M.maximum_lag, options.periods, M.endo_nbr, i_cols, ...
i_cols_J1, i_cols_1, i_cols_T, i_cols_j, i_cols_0, i_cols_J0, ...
eq_index);
else
[y, check, ~, ~, errorcode] = dynare_solve(@perfect_foresight_problem,z(:), options, y0, yT, exogenousvariables, M.params, steadystate, options.periods, M, options);
[y, check, ~, ~, errorcode] = dynare_solve(@perfect_foresight_problem, z(:), ...
options.simul.maxit, options.dynatol.f, options.dynatol.x, ...
options, y0, yT, exogenousvariables, M.params, steadystate, options.periods, M, options);
end
if all(imag(y)<.1*options.dynatol.x)

View File

@ -88,7 +88,7 @@ staticmodel = str2fun(sprintf('%s.static', M_.fname));
% Simulations (call a Newton-like algorithm for each period).
for t=1:samplesize
y = zeros(M_.endo_nbr, 1);
[oo_.endo_simul(:,t), info, ~, ~, errorcode] = dynare_solve(staticmodel, y, options_, oo_.exo_simul(t,:), M_.params);
[oo_.endo_simul(:,t), info, ~, ~, errorcode] = dynare_solve(staticmodel, y, options_.simul.maxit, options_.dynatol.f, options_.dynatol.x, options_, oo_.exo_simul(t,:), M_.params);
if info
error('Newton failed (with error code %i).', errorcode)
end

View File

@ -103,7 +103,8 @@ for t = 1:nobs(constraints)
% values) and the free exogenous variables (initialized with 0).
z = [Y(freeendogenousvariables_id,ity); zeros(nxfree, 1)];
% Solves for z.
[z, errorflag, ~, ~, errorcode] = dynare_solve(model_stransf, z, DynareOptions, model_dynamic, ycur, X(itx, :), DynareModel.params, ModelInversion);
[z, errorflag, ~, ~, errorcode] = dynare_solve(model_stransf, z, DynareOptions.simul.maxit, DynareOptions.dynatol.f, DynareOptions.dynatol.x, ...
DynareOptions, model_dynamic, ycur, X(itx, :), DynareModel.params, ModelInversion);
if errorflag
error('Enable to solve the system of equations (with error code %i).', errorcode)
end

View File

@ -48,7 +48,7 @@ c_z_2 = -.1;
c_z_dx2 = .3;
c_z_u = .3;
c_z_dv = .4;
c_z_s = -.2;
c_z_s = -.2;
cx = 1.0;
cy = 1.0;
@ -122,6 +122,7 @@ init = rand(10, M_.endo_nbr+M_.exo_nbr);
initialconditions = dseries(init, 2000Q1, vertcat(M_.endo_names,M_.exo_names));
// Simulate the model for 500 periods
options_.dynatol.f = 1e-9;
TrueData = simul_backward_model(initialconditions, 500);
TrueData_ = copy(TrueData);
@ -144,4 +145,4 @@ fprintf('Max. abs. error is %s.\n', num2str(max(abs(TrueData.x3.data(12:end)-Tru
if max(abs(TrueData.x3.data(12:end)-TrueData_.x3.data(12:end)))>1e-5
error('equation.evaluate() returned wrong values.')
end
end

View File

@ -119,7 +119,7 @@ init = ones(10, M_.endo_nbr+M_.exo_nbr);
initialconditions = dseries(init, 2000Q1, vertcat(M_.endo_names,M_.exo_names));
// Simulate the model for 500 periods
options_.solve_tolf = 1e-9;
options_.dynatol.f = 1e-9;
TrueData = simul_backward_model(initialconditions, 5000);
TrueData_ = copy(TrueData);