Merged master into enterprise.

Fixed conflict in
 - doc/manual/source/running-dynare.rst
time-shift
Stéphane Adjemian (Charybdis) 2020-09-23 15:28:19 +02:00
commit 17e6421ea3
Signed by: stepan
GPG Key ID: 295C1FE89E17EB3C
11 changed files with 239 additions and 147 deletions

View File

@ -290,6 +290,7 @@ by the ``dynare`` command.
computations. computations.
.. option:: nograph .. option:: nograph
:noindex:
Activate the ``nograph`` option (see :opt:`nograph`), so that Activate the ``nograph`` option (see :opt:`nograph`), so that
Dynare will not produce any graph. Dynare will not produce any graph.
@ -503,6 +504,14 @@ by the ``dynare`` command.
equations to exclude then take actions in accord with :ref:`exclude_eqs equations to exclude then take actions in accord with :ref:`exclude_eqs
<exclude_eqs>`. <exclude_eqs>`.
.. option:: use_dll
:noindex:
Instructs the preprocessor to create dynamic loadable libraries (DLL)
containing the model equations and derivatives, instead of writing
those in M-files. This is equivalent to the :opt:`use_dll` option of
the ``model`` block.
These options can be passed to the preprocessor by listing them These options can be passed to the preprocessor by listing them
after the name of the ``.mod`` file. They can alternatively be after the name of the ``.mod`` file. They can alternatively be
defined in the first line of the ``.mod`` file, this avoids typing defined in the first line of the ``.mod`` file, this avoids typing

View File

@ -925,11 +925,11 @@ The model is declared inside a ``model`` block:
libraries (DLL) containing the model equations and libraries (DLL) containing the model equations and
derivatives, instead of writing those in M-files. You need a derivatives, instead of writing those in M-files. You need a
working compilation environment, i.e. a working ``mex`` working compilation environment, i.e. a working ``mex``
command (see :ref:`compil-install` for more details). On command (see :ref:`compil-install` for more details).
MATLAB for Windows, you will need to also pass the compiler Using this option can result in
name at the command line. Using this option can result in
faster simulations or estimations, at the expense of some faster simulations or estimations, at the expense of some
initial compilation time. [#f2]_ initial compilation time. Alternatively, this option can be
given to the ``dynare`` command (see :ref:`dyn-invoc`). [#f2]_
.. option:: block .. option:: block
@ -7569,11 +7569,12 @@ Shock Decomposition
See :opt:`xls_range <xls_range = RANGE>`. See :opt:`xls_range <xls_range = RANGE>`.
.. option:: use_shock_groups [= STRING] .. option:: use_shock_groups [= NAME]
Uses shock grouping defined by the string instead of Uses shock grouping defined by the string instead of
individual shocks in the decomposition. The groups of shocks individual shocks in the decomposition. The groups of shocks
are defined in the :bck:`shock_groups` block. are defined in the :bck:`shock_groups` block. If no group name is
given, ``default`` is assumed.
.. option:: colormap = VARIABLE_NAME .. option:: colormap = VARIABLE_NAME
@ -7642,7 +7643,8 @@ Shock Decomposition
groups. It is possible to use several ``shock_groups`` blocks groups. It is possible to use several ``shock_groups`` blocks
in a model file, each grouping being identified by a different in a model file, each grouping being identified by a different
name. This name must in turn be used in the name. This name must in turn be used in the
``shock_decomposition`` command. ``shock_decomposition`` command. If no name is given, ``default`` is
used.
*Example* *Example*
@ -7721,9 +7723,9 @@ Shock Decomposition
See :opt:`nobs <nobs = INTEGER>`. See :opt:`nobs <nobs = INTEGER>`.
.. option:: use_shock_groups [= STRING] .. option:: use_shock_groups [= NAME]
See :opt:`use_shock_groups <use_shock_groups [= STRING]>`. See :opt:`use_shock_groups <use_shock_groups [= NAME]>`.
.. option:: colormap = VARIABLE_NAME .. option:: colormap = VARIABLE_NAME
@ -7864,9 +7866,9 @@ Shock Decomposition
*Options* *Options*
.. option:: use_shock_groups [= STRING] .. option:: use_shock_groups [= NAME]
See :opt:`use_shock_groups <use_shock_groups [= STRING]>`. See :opt:`use_shock_groups <use_shock_groups [= NAME]>`.
.. option:: colormap = VARIABLE_NAME .. option:: colormap = VARIABLE_NAME

View File

@ -30,29 +30,6 @@ function [endo_histval, exo_histval, exo_det_histval] = histvalf(M, options)
% You should have received a copy of the GNU General Public License % You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>. % along with Dynare. If not, see <http://www.gnu.org/licenses/>.
if ~isfield(options, 'nobs') || isempty(options.nobs)
options.nobs = M.orig_maximum_lag;
end
if ~isfield(options, 'first_obs') || isempty(options.first_obs)
if isfield(options, 'first_simulation_period')
options.first_obs = options.first_simulation_period ...
- options.nobs;
else
options.first_obs = 1;
end
elseif isfield(options, 'first_simulation_period')
nobs = options.first_simulation_period - opions_.first_obs;
if options.nobs ~= nobs
error(sprintf(['HISTVALF: first_obs = %d and', ...
' first_simulation_period = %d', ...
' don''t provide for the number of' ...
' lags in the model.'], ...
options.first_obs, ...
options.first_simulation_period))
end
end
series = histvalf_initvalf('HISTVAL', M, options); series = histvalf_initvalf('HISTVAL', M, options);
% capture the difference between stochastic and % capture the difference between stochastic and
% perfect foresight setup % perfect foresight setup

View File

@ -41,23 +41,19 @@ end
% file % file
datafile = ''; datafile = '';
if isfield(options, 'filename') if isfield(options, 'filename')
warning([caller, '_FILE: option FILENAME is deprecated, please use', ... warning('%s_FILE: option FILENAME is deprecated, please use option DATAFILE', caller)
' option DATAFILE'])
if dseries_ispresent if dseries_ispresent
error([caller, '_FILE: you can''t use option FILENAME and option SERIES', ... error('%s_FILE: you can''t use option FILENAME and option SERIES at the same time', caller)
' at the same time'])
end end
if isfield(options, 'datafile') if isfield(options, 'datafile')
error([caller, '_FILE: you can''t use option DATAFILE and option FILENAME', ... error('%s_FILE: you can''t use option DATAFILE and option FILENAME at the same time', caller)
' at the same time'])
end end
datafile = options.filename; datafile = options.filename;
end end
if isfield(options, 'datafile') if isfield(options, 'datafile')
if dseries_ispresent if dseries_ispresent
error([caller, '_FILE: you can''t use option DATAFILE and option SERIES', ... error('%s_FILE: you can''t use option DATAFILE and option SERIES at the same time', caller)
' at the same time'])
end end
datafile = options.datafile; datafile = options.datafile;
end end
@ -75,10 +71,9 @@ if datafile
elseif exist([basename '.xlsx'],'file') elseif exist([basename '.xlsx'],'file')
extension = '.xlsx'; extension = '.xlsx';
else else
error([caller, '_FILE: Can''t find datafile: ' basename '.{m,mat,xls,xlsx}']); error('%s_FILE: Can''t find datafile: %s.{m,mat,xls,xlsx}', caller, basename);
end end
end end
fullname = [basename extension]; fullname = [basename extension];
series = dseries(fullname); series = dseries(fullname);
end end
@ -87,33 +82,30 @@ end
error_flag = false; error_flag = false;
for i = 1:M.orig_endo_nbr for i = 1:M.orig_endo_nbr
if ~series.exist(M.endo_names{i}) if ~series.exist(M.endo_names{i})
disp(sprintf('%s_FILE: endogenous variable %s is missing', ... dprintf('%s_FILE: endogenous variable %s is missing', caller, M.endo_names{i})
caller, M.endo_names{i}))
error_flag = true; error_flag = true;
end end
end end
for i = 1:M.exo_nbr for i = 1:M.exo_nbr
if ~series.exist(M.exo_names{i}) if ~series.exist(M.exo_names{i})
disp(sprintf('%s_FILE: exogenous variable %s is missing', ... dprintf('%s_FILE: exogenous variable %s is missing', caller, M.exo_names{i})
caller, M.exo_names{i}))
error_flag = true; error_flag = true;
end end
end end
for i = 1:M.exo_det_nbr for i = 1:M.exo_det_nbr
if ~series.exist(M.exo_det_names{i}) if ~series.exist(M.exo_det_names{i})
disp(sprintf('%s_FILE: exo_det variable %s is missing', ... dprintf('%s_FILE: exo_det variable %s is missing', caller, M.exo_det_names{i})
caller, M.exo_det_names{i}))
error_flag = true; error_flag = true;
end end
end end
if error_flag if error_flag
error([caller, '_FILE: some variables are missing']) error('%s_FILE: some variables are missing', caller)
end end
if exist(sprintf('+%s/dynamic_set_auxiliary_series', M.fname), 'file') if exist(sprintf('+%s/dynamic_set_auxiliary_series.m', M.fname), 'file')
series = feval(sprintf('%s.dynamic_set_auxiliary_series', M.fname), series, M.params); series = feval(sprintf('%s.dynamic_set_auxiliary_series', M.fname), series, M.params);
end end
@ -129,95 +121,113 @@ nobs0 = series.nobs;
first_obs_ispresent = false; first_obs_ispresent = false;
last_obs_ispresent = false; last_obs_ispresent = false;
if isfield(options, 'first_obs')
i = options.first_obs; first_obs = periods(1);
if i < 1 if isfield(options, 'first_obs') && ~isempty(options.first_obs)
error([caller, '_FILE: the first requested period is before available', ... if options.first_obs < 1
' data.']) error('%s_FILE: first_obs must be a positive number', caller)
elseif i > nobs0 elseif options.first_obs > nobs0
error([caller, '_FILE: the first requested period is after available', ... error('%s_FILE: first_obs = %d is larger than the number of observations in the data file (%d)', ...
' data.']) caller, options.first_obs, nobs0)
end elseif isfield(options, 'first_simulation_period')
first_obs = periods(i); if options.first_obs == options.first_simulation_period - M.orig_maximum_lag
if nobs > 0 first_obs = periods(options.first_obs);
last_obs = first_obs + nobs - 1; else
last_obs_ispresent = true; error('%s_FILE: first_obs = %d and first_simulation_period = %d have values inconsistent with a maximum lag of %d periods', ...
end caller, options.first_obs, options.first_simulation_period, M.orig_maximum_lag)
first_obs_ispresent = true; end
elseif isfield(options, 'firstobs') elseif isfield(options, 'firstsimulationperiod')
first_obs = options.firstobs; if periods(options.first_obs) == options.firstsimulationperiod - M.orig_maximum_lag
if nobs > 0 first_obs = periods(options.first_obs);
last_obs = first_obs + nobs - 1; else
last_obs_ispresent = true; error('%s_FILE: first_obs = %d and first_simulation_period = %s have values inconsistent with a maximum lag of %d periods', ...
caller, options.first_obs, options.firstsimulationperiod, M.orig_maximum_lag)
end
else
first_obs = periods(options.first_obs);
end end
first_obs_ispresent = true; first_obs_ispresent = true;
end end
if last_obs_ispresent if isfield(options, 'firstobs') && ~isempty(options.firstobs)
if isfield(options, 'last_obs') if isfield(options, 'first_simulation_period')
i = options.last_obs; if options.firstobs == periods(options.first_simulation_period) - M.orig_maximum_lag
if i < 1 first_obs = options.firstobs;
error([caller, '_FILE: the last requested period is before available', ... else
' data.']) error('%s_FILE: first_obs = %s and first_simulation_period = %d have values inconsistent with a maximum lag of %d periods', ...
elseif i > nobs0 caller, options.firstobs, options.first_simulation_period, M.orig_maximum_lag)
error([caller, '_FILE: the last requested period is after available', ...
' data.'])
end end
if last_obs ~= periods(i) elseif isfield(options, 'firstsimulationperiod')
error([caller, '_FILE: FIST_OBS, LAST_OBS and NOBS contain', ... if options.firstobs == options.firstsimulationperiod - M.orig_maximum_lag
' inconsistent information. Use only two of these', ... first_obs = options.firstobs;
' options.']) else
end error('%s_FILE: firstobs = %s and first_simulation_period = %s have values inconsistent with a maximum lag of %d periods', ...
elseif isfield(options, 'lastobs') caller, options.firstobs, options.firstsimulationperiod, M.orig_maximum_lag)
if last_obs ~= options.lastobs end
error([caller, '_FILE: FIST_OBS, LAST_OBS and NOBS contain', ... else
' inconsistent information. Use only two of these', ... first_obs = options.firstobs;
' options.'])
end
end end
elseif isfield(options, 'last_obs') first_obs_ispresent = true;
i = options.last_obs;
if i < 1
error([caller, '_FILE: the last requested period is before available', ...
' data.'])
elseif i > nobs0
error([caller, '_FILE: the last requested period is after available', ...
' data.'])
end
last_obs = periods(i);
if nobs > 0
first_obs = last_obs - nobs + 1;
first_obs_ispresent = true;
end
last_obs_ispresent = true;
elseif isfield(options, 'lastobs')
last_obs = options.lastobs;
if nobs > 0
first_obs = last_obs - nobs + 1;
first_obs_ispresent = true;
end
last_obs_ispresent = true;
end end
if ~first_obs_ispresent if ~first_obs_ispresent
first_obs = periods(1); if isfield(options, 'first_simulation_period')
end if options.first_simulation_period < M.orig_maximum_lag
error('%s_FILE: first_simulation_period = %d must be larger than the maximum lag (%d)', ...
if ~last_obs_ispresent caller, options.first_simulation_period, M.orig_maximum_lag)
if nobs > 0 elseif options.first_simulation_period > nobs0
last_obs = first_obs + nobs - 1; error('%s_FILE: first_simulations_period = %d is larger than the number of observations in the data file (%d)', ...
else caller, options.first_obs, nobs0)
last_obs = periods(end); else
first_obs = periods(options.first_simulation_period) - M.orig_maximum_lag;
end
first_obs_ispresent = true;
elseif isfield(options, 'firstsimulationperiod')
first_obs = options.firstsimulationperiod - M.orig_maximum_lag;
first_obs_ispresent = true;
end end
end end
if first_obs < series.init if isfield(options, 'last_obs')
error([caller, '_FILE: the first requested period is before available', ... if options.last_obs > nobs0
' data.']) error('%s_FILE: last_obs = %d is larger than the number of observations in the dataset (%d)', ...
elseif last_obs > series.last caller, options.last_obs, nobs0)
error([caller, '_FILE: the last requested period is after available', ... elseif first_obs_ispresent
' data.']) if nobs > 0 && (periods(options.last_obs) ~= first_obs + nobs - 1)
error('%s_FILE: FIST_OBS, LAST_OBS and NOBS contain inconsistent information. Use only two of these options.', caller)
else
last_obs = periods(options.last_obs);
end
else
last_obs = periods(options.last_obs);
if nobs > 0
first_obs = last_obs - nobs + 1;
else
first_obs = periods(1);
end
end
elseif isfield(options, 'lastobs')
if options.lastobs > series.last
error('%s_FILE: last_obs = %s is larger than the number of observations in the dataset (%s)', ...
caller, options.lastobs, series.last)
elseif first_obs_ispresent
if nobs > 0 && (options.lastobs ~= first_obs + nobs - 1)
error('%s_FILE: FIST_OBS, LAST_OBS and NOBS contain inconsistent information. Use only two of these options.', caller)
else
last_obs = options.lastobs;
end
else
last_obs = options.last_obs;
if nobs > 0
first_obs = last_obs - nobs + 1;
else
first_obs = periods(1);
end
end
elseif nobs > 0
last_obs = first_obs + nobs - 1;
else else
series = series(first_obs:last_obs); last_obs = series.last;
end end
series = series(first_obs:last_obs);

View File

@ -1513,6 +1513,7 @@ Evaluate::evaluate_over_periods(const bool forward)
it_code = begining; it_code = begining;
compute_block_time(0, false, false); compute_block_time(0, false, false);
} }
it_ = periods+y_kmin-1; // Do not leave it_ in inconsistent state
} }
else else
{ {
@ -1521,6 +1522,7 @@ Evaluate::evaluate_over_periods(const bool forward)
it_code = begining; it_code = begining;
compute_block_time(0, false, false); compute_block_time(0, false, false);
} }
it_ = y_kmin; // Do not leave it_ in inconsistent state (see #1727)
} }
} }
} }
@ -1596,11 +1598,17 @@ Evaluate::solve_simple_over_periods(const bool forward)
else else
{ {
if (forward) if (forward)
for (it_ = y_kmin; it_ < periods+y_kmin; it_++) {
solve_simple_one_periods(); for (it_ = y_kmin; it_ < periods+y_kmin; it_++)
solve_simple_one_periods();
it_= periods+y_kmin-1; // Do not leave it_ in inconsistent state
}
else else
for (it_ = periods+y_kmin-1; it_ >= y_kmin; it_--) {
solve_simple_one_periods(); for (it_ = periods+y_kmin-1; it_ >= y_kmin; it_--)
solve_simple_one_periods();
it_ = y_kmin; // Do not leave it_ in inconsistent state (see #1727)
}
} }
mxFree(g1); mxFree(g1);
mxFree(r); mxFree(r);
@ -1665,6 +1673,7 @@ Evaluate::compute_complete_2b(const bool no_derivatives, double *_res1, double *
else else
return; return;
} }
it_ = periods+y_kmin-1; // Do not leave it_ in inconsistent state
return; return;
} }
@ -1757,6 +1766,7 @@ Evaluate::compute_complete(double lambda, double *crit)
else else
return false; return false;
} }
it_ = periods+y_kmin-1; // Do not leave it_ in inconsistent state
} }
mexPrintf(" lambda=%e, res2=%e\n", lambda, res2_); mexPrintf(" lambda=%e, res2=%e\n", lambda, res2_);
*crit = res2_/2; *crit = res2_/2;

View File

@ -700,8 +700,8 @@ Interpreter::MainLoop(string bin_basename, CodeLoad code, bool evaluate, int blo
else else
{ {
#ifdef DEBUG #ifdef DEBUG
mexPrintf("endo in Block_Count=%d, block=%d, type=%d, steady_state=%d, print_it=%d, Block_Count=%d, fb->get_is_linear()=%d, fb->get_endo_nbr()=%d, fb->get_Max_Lag()=%d, fb->get_Max_Lead()=%d, fb->get_u_count_int()=%d\n", mexPrintf("endo in Block_Count=%d, size=%d, type=%d, steady_state=%d, print_it=%d, fb->get_is_linear()=%d, fb->get_endo_nbr()=%d, fb->get_Max_Lag()=%d, fb->get_Max_Lead()=%d, fb->get_u_count_int()=%d\n",
Block_Count, fb->get_size(), fb->get_type(), steady_state, print_it, Block_Count, fb->get_is_linear(), fb->get_endo_nbr(), fb->get_Max_Lag(), fb->get_Max_Lead(), fb->get_u_count_int()); Block_Count+1, fb->get_size(), fb->get_type(), steady_state, print_it, fb->get_is_linear(), fb->get_endo_nbr(), fb->get_Max_Lag(), fb->get_Max_Lead(), fb->get_u_count_int());
#endif #endif
bool result; bool result;
if (sconstrained_extended_path.size()) if (sconstrained_extended_path.size())

@ -1 +1 @@
Subproject commit 0f268ce70c9c5358447c4d36a0ee50631e852389 Subproject commit 98d01cbbb669b7c5ee37ad6e23b1626ac9cc4dbb

View File

@ -1,5 +1,5 @@
var y y_s R pie dq pie_s de A y_obs pie_obs R_obs vv ww; var y y_s R pie dq pie_s de A y_obs pie_obs R_obs vv ww pure_forward;
varexo e_R e_q e_ys e_pies e_A; varexo e_R e_q e_ys e_pies e_A e_pure_forward;
parameters psi1 psi2 psi3 rho_R tau alpha rr k rho_q rho_A rho_ys rho_pies; parameters psi1 psi2 psi3 rho_R tau alpha rr k rho_q rho_A rho_ys rho_pies;
@ -53,6 +53,10 @@ det = 0.25-0.02 = 0.23
= 1/0.23* = 1/0.23* = = 1/0.23* = 1/0.23* =
[ww] [0.1 0.5] [2] [1.1] [4.7826] [ww] [0.1 0.5] [2] [1.1] [4.7826]
*/ */
/* Test a purely forward variable (thus within a block of type evaluate
backward). See #1727. */
pure_forward = 0.9*pure_forward(+1) + e_pure_forward;
end; end;
shocks; shocks;
@ -76,6 +80,9 @@ shocks;
var e_q; var e_q;
periods 1; periods 1;
values 0.5; values 0.5;
var e_pure_forward;
periods 19;
values 1;
end; end;
simul(periods=20, markowitz=0, stack_solve_algo = @{stack_solve_algo}); simul(periods=20, markowitz=0, stack_solve_algo = @{stack_solve_algo});

View File

@ -1,4 +1,4 @@
function failed_tests = my_assert(failed_tests, success, test_name) function failed_tests = my_assert(failed_tests, success, test_name)
if ~success if ~success
failed_tests = cat(1, test_failed, test_name); failed_tests = cat(1, failed_tests, test_name);
end end

View File

@ -24,6 +24,12 @@ model;
end; end;
initval_file(series = ds); initval_file(series = ds);
if oo_.initval_series.dates(1) ~= dates('1Y');
error("Wrong initial date in oo_.initval_series");
end;
if oo_.initval_series{'x'}.data(6) ~= 0.9;
error("Wrond value for x");
end;
perfect_foresight_setup(periods=200); perfect_foresight_setup(periods=200);
perfect_foresight_solver(maxit=100); perfect_foresight_solver(maxit=100);
@ -42,6 +48,13 @@ data1(8, 6) = 0.9; //shock to x in period 2
ds1 = dseries(data1, '1Y', {'c', 'cmav', 'k', 'z_backward', 'z_forward', 'x'}); ds1 = dseries(data1, '1Y', {'c', 'cmav', 'k', 'z_backward', 'z_forward', 'x'});
initval_file(series = ds1, first_obs = 3, last_obs = 210, nobs = 208); initval_file(series = ds1, first_obs = 3, last_obs = 210, nobs = 208);
if oo_.initval_series.dates(1) ~= dates('3Y');
error("Wrong initial date in oo_.initval_series");
end;
if oo_.initval_series{'x'}.data(6) ~= 0.9;
error("Wrond value for x");
end;
perfect_foresight_setup(periods=200); perfect_foresight_setup(periods=200);
perfect_foresight_solver(maxit=100); perfect_foresight_solver(maxit=100);
@ -54,3 +67,67 @@ base_results=load('sim_exo_lead_lag_results.mat');
if max(max(abs(base_results.oo_.endo_simul(1:5,:) - oo_.endo_simul(1:5,:)))) > 1e-8 if max(max(abs(base_results.oo_.endo_simul(1:5,:) - oo_.endo_simul(1:5,:)))) > 1e-8
error('Simulation with leads and lags doesn''t match the one with auxiliary variables') error('Simulation with leads and lags doesn''t match the one with auxiliary variables')
end end
initval_file(series = ds1, first_obs = 3Y, last_obs = 210Y, nobs = 208);
if oo_.initval_series.dates(1) ~= dates('3Y');
error("Wrong initial date in oo_.initval_series");
end;
if oo_.initval_series{'x'}.data(6) ~= 0.9;
error("Wrond value for x");
end;
perfect_foresight_setup(periods=200);
perfect_foresight_solver(maxit=100);
if ~oo_.deterministic_simulation.status
error('Perfect foresight simulation failed');
end
base_results=load('sim_exo_lead_lag_results.mat');
if max(max(abs(base_results.oo_.endo_simul(1:5,:) - oo_.endo_simul(1:5,:)))) > 1e-8
error('Simulation with leads and lags doesn''t match the one with auxiliary variables')
end
initval_file(series = ds1, first_simulation_period = 7);
if oo_.initval_series.dates(1) ~= dates('3Y');
error("Wrong initial date in oo_.initval_series");
end;
if oo_.initval_series{'x'}.data(6) ~= 0.9;
error("Wrond value for x");
end;
perfect_foresight_setup(periods=200);
perfect_foresight_solver(maxit=100);
if ~oo_.deterministic_simulation.status
error('Perfect foresight simulation failed');
end
base_results=load('sim_exo_lead_lag_results.mat');
if max(max(abs(base_results.oo_.endo_simul(1:5,:) - oo_.endo_simul(1:5,:)))) > 1e-8
error('Simulation with leads and lags doesn''t match the one with auxiliary variables')
end
initval_file(series = ds1, first_simulation_period = 7Y);
if oo_.initval_series.dates(1) ~= dates('3Y');
error("Wrong initial date in oo_.initval_series");
end;
if oo_.initval_series{'x'}.data(6) ~= 0.9;
error("Wrond value for x");
end;
perfect_foresight_setup(periods=200);
perfect_foresight_solver(maxit=100);
if ~oo_.deterministic_simulation.status
error('Perfect foresight simulation failed');
end
base_results=load('sim_exo_lead_lag_results.mat');
if max(max(abs(base_results.oo_.endo_simul(1:5,:) - oo_.endo_simul(1:5,:)))) > 1e-8
error('Simulation with leads and lags doesn''t match the one with auxiliary variables')
end

View File

@ -16,6 +16,7 @@ M.endo_names = {'Variable_1','Variable_2','Variable_3'};
M.exo_nbr = 1; M.exo_nbr = 1;
M.exo_names = {'Variable_4'}; M.exo_names = {'Variable_4'};
M.exo_det_nbr = 0; M.exo_det_nbr = 0;
M.orig_maximum_lag = 2;
caller = 'INITVAL'; caller = 'INITVAL';
@ -88,9 +89,9 @@ try
ds1 = histvalf_initvalf(caller, M, options); ds1 = histvalf_initvalf(caller, M, options);
error('This test didn''t catch the error') error('This test didn''t catch the error')
catch me catch me
if strcmp(me.message, ['INITVAL_FILE: FIST_OBS, LAST_OBS and NOBS contain', ... if ~strcmp(me.message, strcat('INITVAL_FILE: FIST_OBS, LAST_OBS and NOBS contain', ...
' inconsistent information. Use only two of these', ... ' inconsistent information. Use only two of these', ...
' options.']) == false ' options.'))
failed_tests = cat(1, failed_tests, 'Wrong nobs error message' ); failed_tests = cat(1, failed_tests, 'Wrong nobs error message' );
end end
end end
@ -98,14 +99,13 @@ num_tests = num_tests + 1;
options = struct(); options = struct();
options.series = ds; options.series = ds;
options.first_obs = -1; options.first_obs = 0;
try try
ds1 = histvalf_initvalf(caller, M, options); ds1 = histvalf_initvalf(caller, M, options);
error('This test didn''t catch the error') error('This test didn''t catch the error')
catch me catch me
if strcmp(me.message, [caller, '_FILE: the first requested period is', ... if ~strcmp(me.message, strcat(caller, '_FILE: first_obs must be a positive number'))
' before available data.']) == false
failed_tests = cat(1, failed_tests, ... failed_tests = cat(1, failed_tests, ...
'Wrong first period error message'); 'Wrong first period error message');
end end
@ -120,8 +120,8 @@ try
ds1 = histvalf_initvalf(caller, M, options); ds1 = histvalf_initvalf(caller, M, options);
error('This test didn''t catch the error') error('This test didn''t catch the error')
catch me catch me
if strcmp(me.message, [caller, '_FILE: the last requested period is', ... if ~strcmp(me.message, strcat(caller, '_FILE: last_obs = 11 is larger than the number', ...
' after available data.']) == false ' of observations in the dataset (10)'))
failed_tests = cat(1, failed_tests, ... failed_tests = cat(1, failed_tests, ...
'Wrong last period error message'); 'Wrong last period error message');
end end