diff --git a/doc/manual/source/running-dynare.rst b/doc/manual/source/running-dynare.rst index 48ffbbb37..6005b0b88 100644 --- a/doc/manual/source/running-dynare.rst +++ b/doc/manual/source/running-dynare.rst @@ -290,6 +290,7 @@ by the ``dynare`` command. computations. .. option:: nograph + :noindex: Activate the ``nograph`` option (see :opt:`nograph`), so that 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 `. + .. 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 after the name of the ``.mod`` file. They can alternatively be defined in the first line of the ``.mod`` file, this avoids typing diff --git a/doc/manual/source/the-model-file.rst b/doc/manual/source/the-model-file.rst index 8cfc1a148..1c48d82c0 100644 --- a/doc/manual/source/the-model-file.rst +++ b/doc/manual/source/the-model-file.rst @@ -925,11 +925,11 @@ The model is declared inside a ``model`` block: libraries (DLL) containing the model equations and derivatives, instead of writing those in M-files. You need a working compilation environment, i.e. a working ``mex`` - command (see :ref:`compil-install` for more details). On - MATLAB for Windows, you will need to also pass the compiler - name at the command line. Using this option can result in + command (see :ref:`compil-install` for more details). + Using this option can result in 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 @@ -7569,11 +7569,12 @@ Shock Decomposition See :opt:`xls_range `. - .. option:: use_shock_groups [= STRING] + .. option:: use_shock_groups [= NAME] Uses shock grouping defined by the string instead of 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 @@ -7642,7 +7643,8 @@ Shock Decomposition groups. It is possible to use several ``shock_groups`` blocks in a model file, each grouping being identified by a different 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* @@ -7721,9 +7723,9 @@ Shock Decomposition See :opt:`nobs `. - .. option:: use_shock_groups [= STRING] + .. option:: use_shock_groups [= NAME] - See :opt:`use_shock_groups `. + See :opt:`use_shock_groups `. .. option:: colormap = VARIABLE_NAME @@ -7864,9 +7866,9 @@ Shock Decomposition *Options* - .. option:: use_shock_groups [= STRING] + .. option:: use_shock_groups [= NAME] - See :opt:`use_shock_groups `. + See :opt:`use_shock_groups `. .. option:: colormap = VARIABLE_NAME diff --git a/matlab/histvalf.m b/matlab/histvalf.m index f15e72511..07a6a25a7 100644 --- a/matlab/histvalf.m +++ b/matlab/histvalf.m @@ -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 % along with Dynare. If not, see . -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); % capture the difference between stochastic and % perfect foresight setup diff --git a/matlab/histvalf_initvalf.m b/matlab/histvalf_initvalf.m index e65779c49..2ed72aee7 100644 --- a/matlab/histvalf_initvalf.m +++ b/matlab/histvalf_initvalf.m @@ -41,23 +41,19 @@ end % file datafile = ''; if isfield(options, 'filename') - warning([caller, '_FILE: option FILENAME is deprecated, please use', ... - ' option DATAFILE']) + warning('%s_FILE: option FILENAME is deprecated, please use option DATAFILE', caller) if dseries_ispresent - error([caller, '_FILE: you can''t use option FILENAME and option SERIES', ... - ' at the same time']) + error('%s_FILE: you can''t use option FILENAME and option SERIES at the same time', caller) end if isfield(options, 'datafile') - error([caller, '_FILE: you can''t use option DATAFILE and option FILENAME', ... - ' at the same time']) + error('%s_FILE: you can''t use option DATAFILE and option FILENAME at the same time', caller) end datafile = options.filename; end if isfield(options, 'datafile') if dseries_ispresent - error([caller, '_FILE: you can''t use option DATAFILE and option SERIES', ... - ' at the same time']) + error('%s_FILE: you can''t use option DATAFILE and option SERIES at the same time', caller) end datafile = options.datafile; end @@ -75,10 +71,9 @@ if datafile elseif exist([basename '.xlsx'],'file') extension = '.xlsx'; 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 - fullname = [basename extension]; series = dseries(fullname); end @@ -87,33 +82,30 @@ end error_flag = false; for i = 1:M.orig_endo_nbr if ~series.exist(M.endo_names{i}) - disp(sprintf('%s_FILE: endogenous variable %s is missing', ... - caller, M.endo_names{i})) + dprintf('%s_FILE: endogenous variable %s is missing', caller, M.endo_names{i}) error_flag = true; end end for i = 1:M.exo_nbr if ~series.exist(M.exo_names{i}) - disp(sprintf('%s_FILE: exogenous variable %s is missing', ... - caller, M.exo_names{i})) + dprintf('%s_FILE: exogenous variable %s is missing', caller, M.exo_names{i}) error_flag = true; end end for i = 1:M.exo_det_nbr if ~series.exist(M.exo_det_names{i}) - disp(sprintf('%s_FILE: exo_det variable %s is missing', ... - caller, M.exo_det_names{i})) + dprintf('%s_FILE: exo_det variable %s is missing', caller, M.exo_det_names{i}) error_flag = true; end end if error_flag - error([caller, '_FILE: some variables are missing']) + error('%s_FILE: some variables are missing', caller) 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); end @@ -129,95 +121,113 @@ nobs0 = series.nobs; first_obs_ispresent = false; last_obs_ispresent = false; -if isfield(options, 'first_obs') - i = options.first_obs; - if i < 1 - error([caller, '_FILE: the first requested period is before available', ... - ' data.']) - elseif i > nobs0 - error([caller, '_FILE: the first requested period is after available', ... - ' data.']) - end - first_obs = periods(i); - if nobs > 0 - last_obs = first_obs + nobs - 1; - last_obs_ispresent = true; - end - first_obs_ispresent = true; -elseif isfield(options, 'firstobs') - first_obs = options.firstobs; - if nobs > 0 - last_obs = first_obs + nobs - 1; - last_obs_ispresent = true; + +first_obs = periods(1); +if isfield(options, 'first_obs') && ~isempty(options.first_obs) + if options.first_obs < 1 + error('%s_FILE: first_obs must be a positive number', caller) + elseif options.first_obs > nobs0 + error('%s_FILE: first_obs = %d is larger than the number of observations in the data file (%d)', ... + caller, options.first_obs, nobs0) + elseif isfield(options, 'first_simulation_period') + if options.first_obs == options.first_simulation_period - M.orig_maximum_lag + first_obs = periods(options.first_obs); + else + error('%s_FILE: first_obs = %d and first_simulation_period = %d have values inconsistent with a maximum lag of %d periods', ... + caller, options.first_obs, options.first_simulation_period, M.orig_maximum_lag) + end + elseif isfield(options, 'firstsimulationperiod') + if periods(options.first_obs) == options.firstsimulationperiod - M.orig_maximum_lag + first_obs = periods(options.first_obs); + else + 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 first_obs_ispresent = true; end -if last_obs_ispresent - if isfield(options, 'last_obs') - 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.']) +if isfield(options, 'firstobs') && ~isempty(options.firstobs) + if isfield(options, 'first_simulation_period') + if options.firstobs == periods(options.first_simulation_period) - M.orig_maximum_lag + first_obs = options.firstobs; + else + error('%s_FILE: first_obs = %s and first_simulation_period = %d have values inconsistent with a maximum lag of %d periods', ... + caller, options.firstobs, options.first_simulation_period, M.orig_maximum_lag) end - if last_obs ~= periods(i) - error([caller, '_FILE: FIST_OBS, LAST_OBS and NOBS contain', ... - ' inconsistent information. Use only two of these', ... - ' options.']) - end - elseif isfield(options, 'lastobs') - if last_obs ~= options.lastobs - error([caller, '_FILE: FIST_OBS, LAST_OBS and NOBS contain', ... - ' inconsistent information. Use only two of these', ... - ' options.']) - end + elseif isfield(options, 'firstsimulationperiod') + if options.firstobs == options.firstsimulationperiod - M.orig_maximum_lag + first_obs = options.firstobs; + else + error('%s_FILE: firstobs = %s and first_simulation_period = %s have values inconsistent with a maximum lag of %d periods', ... + caller, options.firstobs, options.firstsimulationperiod, M.orig_maximum_lag) + end + else + first_obs = options.firstobs; end -elseif isfield(options, 'last_obs') - 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; + first_obs_ispresent = true; end if ~first_obs_ispresent - first_obs = periods(1); -end - -if ~last_obs_ispresent - if nobs > 0 - last_obs = first_obs + nobs - 1; - else - last_obs = periods(end); + if isfield(options, 'first_simulation_period') + if options.first_simulation_period < M.orig_maximum_lag + error('%s_FILE: first_simulation_period = %d must be larger than the maximum lag (%d)', ... + caller, options.first_simulation_period, M.orig_maximum_lag) + elseif options.first_simulation_period > nobs0 + error('%s_FILE: first_simulations_period = %d is larger than the number of observations in the data file (%d)', ... + caller, options.first_obs, nobs0) + 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 -if first_obs < series.init - error([caller, '_FILE: the first requested period is before available', ... - ' data.']) -elseif last_obs > series.last - error([caller, '_FILE: the last requested period is after available', ... - ' data.']) +if isfield(options, 'last_obs') + if options.last_obs > nobs0 + error('%s_FILE: last_obs = %d is larger than the number of observations in the dataset (%d)', ... + caller, options.last_obs, nobs0) + elseif first_obs_ispresent + 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 - series = series(first_obs:last_obs); + last_obs = series.last; end +series = series(first_obs:last_obs); \ No newline at end of file diff --git a/mex/sources/bytecode/Evaluate.cc b/mex/sources/bytecode/Evaluate.cc index 576edff9e..841d9365b 100644 --- a/mex/sources/bytecode/Evaluate.cc +++ b/mex/sources/bytecode/Evaluate.cc @@ -1513,6 +1513,7 @@ Evaluate::evaluate_over_periods(const bool forward) it_code = begining; compute_block_time(0, false, false); } + it_ = periods+y_kmin-1; // Do not leave it_ in inconsistent state } else { @@ -1521,6 +1522,7 @@ Evaluate::evaluate_over_periods(const bool forward) it_code = begining; 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 { 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 - 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(r); @@ -1665,6 +1673,7 @@ Evaluate::compute_complete_2b(const bool no_derivatives, double *_res1, double * else return; } + it_ = periods+y_kmin-1; // Do not leave it_ in inconsistent state return; } @@ -1757,6 +1766,7 @@ Evaluate::compute_complete(double lambda, double *crit) else return false; } + it_ = periods+y_kmin-1; // Do not leave it_ in inconsistent state } mexPrintf(" lambda=%e, res2=%e\n", lambda, res2_); *crit = res2_/2; diff --git a/mex/sources/bytecode/Interpreter.cc b/mex/sources/bytecode/Interpreter.cc index a3aa0bbe3..65d275d68 100644 --- a/mex/sources/bytecode/Interpreter.cc +++ b/mex/sources/bytecode/Interpreter.cc @@ -700,8 +700,8 @@ Interpreter::MainLoop(string bin_basename, CodeLoad code, bool evaluate, int blo else { #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", - 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()); + 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+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 bool result; if (sconstrained_extended_path.size()) diff --git a/preprocessor b/preprocessor index 0f268ce70..98d01cbbb 160000 --- a/preprocessor +++ b/preprocessor @@ -1 +1 @@ -Subproject commit 0f268ce70c9c5358447c4d36a0ee50631e852389 +Subproject commit 98d01cbbb669b7c5ee37ad6e23b1626ac9cc4dbb diff --git a/tests/block_bytecode/ls2003.mod b/tests/block_bytecode/ls2003.mod index 87fca4a9f..62ffb6bb6 100644 --- a/tests/block_bytecode/ls2003.mod +++ b/tests/block_bytecode/ls2003.mod @@ -1,5 +1,5 @@ -var y y_s R pie dq pie_s de A y_obs pie_obs R_obs vv ww; -varexo e_R e_q e_ys e_pies e_A; +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 e_pure_forward; 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* = [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; shocks; @@ -76,6 +80,9 @@ shocks; var e_q; periods 1; values 0.5; +var e_pure_forward; +periods 19; +values 1; end; simul(periods=20, markowitz=0, stack_solve_algo = @{stack_solve_algo}); diff --git a/tests/histval_initval_file/my_assert.m b/tests/histval_initval_file/my_assert.m index 2ac132e12..6f30d2dbe 100644 --- a/tests/histval_initval_file/my_assert.m +++ b/tests/histval_initval_file/my_assert.m @@ -1,4 +1,4 @@ function failed_tests = my_assert(failed_tests, success, test_name) if ~success - failed_tests = cat(1, test_failed, test_name); + failed_tests = cat(1, failed_tests, test_name); end \ No newline at end of file diff --git a/tests/histval_initval_file/sim_exo_lead_lag_initvalf.mod b/tests/histval_initval_file/sim_exo_lead_lag_initvalf.mod index e74b6c9b2..044a1ee26 100644 --- a/tests/histval_initval_file/sim_exo_lead_lag_initvalf.mod +++ b/tests/histval_initval_file/sim_exo_lead_lag_initvalf.mod @@ -24,6 +24,12 @@ model; end; 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_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'}); 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_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 error('Simulation with leads and lags doesn''t match the one with auxiliary variables') 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 + diff --git a/tests/histval_initval_file_unit_tests.m b/tests/histval_initval_file_unit_tests.m index 4b81f71de..925ce1a57 100644 --- a/tests/histval_initval_file_unit_tests.m +++ b/tests/histval_initval_file_unit_tests.m @@ -16,6 +16,7 @@ M.endo_names = {'Variable_1','Variable_2','Variable_3'}; M.exo_nbr = 1; M.exo_names = {'Variable_4'}; M.exo_det_nbr = 0; +M.orig_maximum_lag = 2; caller = 'INITVAL'; @@ -88,9 +89,9 @@ try ds1 = histvalf_initvalf(caller, M, options); error('This test didn''t catch the error') catch me - if strcmp(me.message, ['INITVAL_FILE: FIST_OBS, LAST_OBS and NOBS contain', ... - ' inconsistent information. Use only two of these', ... - ' options.']) == false + if ~strcmp(me.message, strcat('INITVAL_FILE: FIST_OBS, LAST_OBS and NOBS contain', ... + ' inconsistent information. Use only two of these', ... + ' options.')) failed_tests = cat(1, failed_tests, 'Wrong nobs error message' ); end end @@ -98,14 +99,13 @@ num_tests = num_tests + 1; options = struct(); options.series = ds; -options.first_obs = -1; +options.first_obs = 0; try ds1 = histvalf_initvalf(caller, M, options); error('This test didn''t catch the error') catch me - if strcmp(me.message, [caller, '_FILE: the first requested period is', ... - ' before available data.']) == false + if ~strcmp(me.message, strcat(caller, '_FILE: first_obs must be a positive number')) failed_tests = cat(1, failed_tests, ... 'Wrong first period error message'); end @@ -120,8 +120,8 @@ try ds1 = histvalf_initvalf(caller, M, options); error('This test didn''t catch the error') catch me - if strcmp(me.message, [caller, '_FILE: the last requested period is', ... - ' after available data.']) == false + if ~strcmp(me.message, strcat(caller, '_FILE: last_obs = 11 is larger than the number', ... + ' of observations in the dataset (10)')) failed_tests = cat(1, failed_tests, ... 'Wrong last period error message'); end