diff --git a/matlab/+occbin/mkdatap_anticipated_2constraints_dyn.m b/matlab/+occbin/mkdatap_anticipated_2constraints_dyn.m index 379380cbc..f14344e2f 100644 --- a/matlab/+occbin/mkdatap_anticipated_2constraints_dyn.m +++ b/matlab/+occbin/mkdatap_anticipated_2constraints_dyn.m @@ -98,7 +98,11 @@ if T_max > 0 for i = T_max-1:-1:1 tmp = 0*binding_indicator; tmp(1:end-i+1,:) = binding_indicator(i:end,:); - itmp = find(~any(dictionary.binding_indicator(1:length(tmp)*2,:)-tmp(:))); + if ~isoctave && matlab_ver_less_than('9.1') % Automatic broadcasting was introduced in MATLAB R2016b + itmp = find(~any(bsxfun(@minus, dictionary.binding_indicator(1:length(tmp)*2,:), tmp(:)))); + else + itmp = find(~any(dictionary.binding_indicator(1:length(tmp)*2,:)-tmp(:))); + end if ~isempty(itmp) ireg(i) = itmp; else @@ -166,4 +170,4 @@ for irfpos=2:n_periods+1 end end -zdata = history(:,2:end)'; \ No newline at end of file +zdata = history(:,2:end)'; diff --git a/matlab/+occbin/mkdatap_anticipated_dyn.m b/matlab/+occbin/mkdatap_anticipated_dyn.m index 24740421c..b361c62f4 100644 --- a/matlab/+occbin/mkdatap_anticipated_dyn.m +++ b/matlab/+occbin/mkdatap_anticipated_dyn.m @@ -89,7 +89,11 @@ if T_max > 0 tmp = 0*binding_indicator; tmp(1:end-i+1) = binding_indicator(i:end); - itmp = find(~any(dictionary.binding_indicator-tmp)); + if ~isoctave && matlab_ver_less_than('9.1') % Automatic broadcasting was introduced in MATLAB R2016b + itmp = find(~any(bsxfun(@minus, dictionary.binding_indicator, tmp))); + else + itmp = find(~any(dictionary.binding_indicator-tmp)); + end if ~isempty(itmp) ireg(i) = itmp; else @@ -148,4 +152,4 @@ for irfpos=2:n_periods+1 end end -zdata = history(:,2:end)'; \ No newline at end of file +zdata = history(:,2:end)'; diff --git a/matlab/+occbin/solver.m b/matlab/+occbin/solver.m index 8885b9052..f251432d8 100644 --- a/matlab/+occbin/solver.m +++ b/matlab/+occbin/solver.m @@ -74,9 +74,17 @@ end % add back steady state if ~options_.occbin.simul.piecewise_only - out.linear = out.linear + out.ys'; + if ~isoctave && matlab_ver_less_than('9.1') % Automatic broadcasting was introduced in MATLAB R2016b + out.linear = bsxfun(@plus, out.linear, out.ys'); + else + out.linear = out.linear + out.ys'; + end +end +if ~isoctave && matlab_ver_less_than('9.1') % Automatic broadcasting was introduced in MATLAB R2016b + out.piecewise = bsxfun(@plus, out.piecewise, out.ys'); +else + out.piecewise = out.piecewise + out.ys'; end -out.piecewise = out.piecewise+ out.ys'; out.exo_pos = options_.occbin.simul.exo_pos; oo_.occbin=out; diff --git a/matlab/+occbin/write_regimes_to_xls.m b/matlab/+occbin/write_regimes_to_xls.m index 7029990f6..5c0de9e75 100644 --- a/matlab/+occbin/write_regimes_to_xls.m +++ b/matlab/+occbin/write_regimes_to_xls.m @@ -51,14 +51,18 @@ else xlsmat{tp,5}=int2str(regime_history(tp).regimestart2); end end -filename=[OutputDirectoryName filesep xls_filename '.xls']; -if matlab_ver_less_than('9.3') - if exist(filename,'file') - delete(filename) - end +if ~ispc && ~isoctave && matlab_ver_less_than('9.0') + % On GNU/Linux and macOS, with MATLAB < R2016a, “writeable” can’t write Excel files + warning('This version of MATLAB is too old and cannot create Excel files. The Occbin regimes will rather be written to a CSV file') + filename=[OutputDirectoryName filesep xls_filename '.csv']; else - if isfile(filename) - delete(filename) - end + filename=[OutputDirectoryName filesep xls_filename '.xls']; +end +if isfile(filename) + delete(filename) +end +if ~ispc && ~isoctave && matlab_ver_less_than('9.0') % See above + writetable(array2table(xlsmat,'VariableNames',Header), filename); +else + writetable(array2table(xlsmat,'VariableNames',Header), filename, 'Sheet', 'Regimes'); end -writetable(array2table(xlsmat,'VariableNames',Header), filename, 'Sheet', 'Regimes'); diff --git a/tests/ecb/SUR/sur_params_noniterative.mod b/tests/ecb/SUR/sur_params_noniterative.mod index 268ae3d30..e74a29302 100644 --- a/tests/ecb/SUR/sur_params_noniterative.mod +++ b/tests/ecb/SUR/sur_params_noniterative.mod @@ -206,8 +206,8 @@ else 0.480506381923643 -0.111002148299648 1.000000000000000]; - if max(abs(BETA' - good)) > 1e-14 - error(['sum of BETA'' - good was: ' num2str(sum(abs(BETA - good)))]); + if max(abs(BETA' - good)) > 2e-14 + error(['sum of BETA'' - good was: ' num2str(sum(abs(BETA' - good)))]); end return end diff --git a/tests/histval_initval_file_unit_tests.m b/tests/histval_initval_file_unit_tests.m index 07b171e50..183ce1208 100644 --- a/tests/histval_initval_file_unit_tests.m +++ b/tests/histval_initval_file_unit_tests.m @@ -21,14 +21,14 @@ M.orig_maximum_lag = 2; caller = 'INITVAL'; options = struct(); -options.series = "ds"; +options.series = 'ds'; ds1 = histvalf_initvalf(caller, M, options); failed_tests = my_assert(failed_tests, all(all(ds1 == ds)), 'basic test'); num_tests = num_tests + 1; options = struct(); -options.series = "ds1"; +options.series = 'ds1'; options.first_obs = 2; ds1 = histvalf_initvalf(caller, M, options); failed_tests = my_assert(failed_tests, ds1.init == dates('2Y'), ... @@ -36,7 +36,7 @@ failed_tests = my_assert(failed_tests, ds1.init == dates('2Y'), ... num_tests = num_tests + 1; options = struct(); -options.series = "ds"; +options.series = 'ds'; options.first_obs = 2; options.last_obs = 9; ds1 = histvalf_initvalf(caller, M, options); @@ -47,7 +47,7 @@ failed_tests = my_assert(failed_tests, ds1.last == dates('9Y'), ... num_tests = num_tests + 2; options = struct(); -options.series = "ds"; +options.series = 'ds'; options.last_obs = 9; ds1 = histvalf_initvalf(caller, M, options); failed_tests = my_assert(failed_tests, ds1.init == dates('1Y'), ... @@ -57,7 +57,7 @@ failed_tests = my_assert(failed_tests, ds1.last == dates('9Y'), ... num_tests = num_tests + 2; options = struct(); -options.series = "ds"; +options.series = 'ds'; options.first_obs = 2; options.last_obs = 9; options.nobs = 8; @@ -69,7 +69,7 @@ failed_tests = my_assert(failed_tests, ds1.last == dates('9Y'), ... num_tests = num_tests + 2; options = struct(); -options.series = "ds"; +options.series = 'ds'; options.last_obs = 9; options.nobs = 8; ds1 = histvalf_initvalf(caller, M, options); @@ -80,7 +80,7 @@ failed_tests = my_assert(failed_tests, ds1.last == dates('9Y'), ... num_tests = num_tests + 2; options = struct(); -options.series = "ds"; +options.series = 'ds'; options.first_obs = 2; options.last_obs = 9; options.nobs = 7; @@ -98,7 +98,7 @@ end num_tests = num_tests + 1; options = struct(); -options.series = "ds"; +options.series = 'ds'; options.first_obs = 0; try @@ -113,7 +113,7 @@ end num_tests = num_tests + 1; options = struct(); -options.series = "ds"; +options.series = 'ds'; options.last_obs = 11; try diff --git a/tests/occbin/model_borrcon/borrcon_common.inc b/tests/occbin/model_borrcon/borrcon_common.inc index b4d12a463..845c5d919 100644 --- a/tests/occbin/model_borrcon/borrcon_common.inc +++ b/tests/occbin/model_borrcon/borrcon_common.inc @@ -17,7 +17,11 @@ ylabels = char(percent,percent,percent,level); figtitle = 'Simulated variables'; legendlist = cellstr(char('Piecewise Linear','Linear')); -options_.TeX=1; +if isoctave || ~matlab_ver_less_than('8.4') + % For some unknown reason, MATLAB R2014a crashes with TeX labels + % when -nodisplay is passed (as in the testsuite) + options_.TeX=1; +end occbin_graph; occbin_graph c_hat b_hat y_hat;