From 07937f5b9fdecf79d2dbcfcb744110aaebff10bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Thu, 26 Sep 2019 15:36:49 +0200 Subject: [PATCH 01/10] Updated dseries submodule (is{row,column,matrix} are builtin functions, not M-files). [skip-ci] --- matlab/modules/dseries | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/matlab/modules/dseries b/matlab/modules/dseries index 7f27abcad..f4bad5a62 160000 --- a/matlab/modules/dseries +++ b/matlab/modules/dseries @@ -1 +1 @@ -Subproject commit 7f27abcadfec19ebf5dac00417b752388c4c73f6 +Subproject commit f4bad5a6279adfb052bc088153b17ec391ed64f1 From 715ae0ce39469a8f6865c166f3a5b6abea5d54b4 Mon Sep 17 00:00:00 2001 From: Houtan Bastani Date: Mon, 30 Sep 2019 11:09:43 +0200 Subject: [PATCH 02/10] preprocessor: submodule update --- doc/manual/source/the-model-file.rst | 16 ++++++++-------- preprocessor | 2 +- .../ls2003_endog_prior_restrict_estimation.mod | 6 +++--- tests/gsa/ls2003a.mod | 10 +++++----- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/doc/manual/source/the-model-file.rst b/doc/manual/source/the-model-file.rst index 4ab96bce4..7b19c8f92 100644 --- a/doc/manual/source/the-model-file.rst +++ b/doc/manual/source/the-model-file.rst @@ -8744,8 +8744,8 @@ IRF and moment calibration can be defined in ``irf_calibration`` and To set IRF restrictions with specific intervals, the following syntax is used:: - VARIABLE_NAME(INTEGER),EXOGENOUS_NAME, [DOUBLE DOUBLE]; - VARIABLE_NAME(INTEGER:INTEGER),EXOGENOUS_NAME, [DOUBLE DOUBLE]; + VARIABLE_NAME(INTEGER),EXOGENOUS_NAME, [EXPRESSION, EXPRESSION]; + VARIABLE_NAME(INTEGER:INTEGER),EXOGENOUS_NAME, [EXPRESSION, EXPRESSION]; When ``(INTEGER:INTEGER)`` is used, the restriction is considered to be fulfilled by a logical OR. A list of restrictions must @@ -8762,9 +8762,9 @@ IRF and moment calibration can be defined in ``irf_calibration`` and :: irf_calibration; - y(1:4), e_ys, [ -50 50]; //[first year response with logical OR] + y(1:4), e_ys, [-50, 50]; //[first year response with logical OR] @#for ilag in 21:40 - R_obs(@{ilag}), e_ys, [0 6]; //[response from 5th to 10th years with logical AND] + R_obs(@{ilag}), e_ys, [0, 6]; //[response from 5th to 10th years with logical AND] @#endfor end; @@ -8775,10 +8775,10 @@ IRF and moment calibration can be defined in ``irf_calibration`` and |br| This block allows defining moment calibration criteria. This block is terminated by ``end;``, and contains lines of the form:: - VARIABLE_NAME1,VARIABLE_NAME2(+/-INTEGER), [DOUBLE DOUBLE]; + VARIABLE_NAME1,VARIABLE_NAME2(+/-INTEGER), [EXPRESSION, EXPRESSION]; VARIABLE_NAME1,VARIABLE_NAME2(+/-INTEGER), +/-; - VARIABLE_NAME1,VARIABLE_NAME2(+/-(INTEGER:INTEGER)), [DOUBLE DOUBLE]; - VARIABLE_NAME1,VARIABLE_NAME2((-INTEGER:+INTEGER)), [DOUBLE DOUBLE]; + VARIABLE_NAME1,VARIABLE_NAME2(+/-(INTEGER:INTEGER)), [EXPRESSION, EXPRESSION]; + VARIABLE_NAME1,VARIABLE_NAME2((-INTEGER:+INTEGER)), [EXPRESSION, EXPRESSION]; When ``(INTEGER:INTEGER)`` is used, the restriction is considered to be fulfilled by a logical OR. A list of restrictions must @@ -8789,7 +8789,7 @@ IRF and moment calibration can be defined in ``irf_calibration`` and :: moment_calibration; - y_obs,y_obs, [0.5 1.5]; //[unconditional variance] + y_obs,y_obs, [0.5, 1.5]; //[unconditional variance] y_obs,y_obs(-(1:4)), +; //[sign restriction for first year acf with logical OR] @#for ilag in -2:2 y_obs,R_obs(@{ilag}), -; //[-2:2 ccf with logical AND] diff --git a/preprocessor b/preprocessor index 92ad5aad2..1fcd30501 160000 --- a/preprocessor +++ b/preprocessor @@ -1 +1 @@ -Subproject commit 92ad5aad2c5dd0ba4e917ede11baddb674db82c0 +Subproject commit 1fcd305015c77b93ca2110efc749dbfd72dfe3ba diff --git a/tests/estimation/ls2003_endog_prior_restrict_estimation.mod b/tests/estimation/ls2003_endog_prior_restrict_estimation.mod index 093cec088..901ac60d4 100644 --- a/tests/estimation/ls2003_endog_prior_restrict_estimation.mod +++ b/tests/estimation/ls2003_endog_prior_restrict_estimation.mod @@ -65,9 +65,9 @@ end; // endogenous prior restrictions irf_calibration(relative_irf); -y(1:4), e_ys, [ -50 50]; //[first year response] +y(1:4), e_ys, [ -50, 50]; //[first year response] @#for ilag in 21:40 -R_obs(@{ilag}), e_ys, [0 6]; //[response after 4th year to 10th year] +R_obs(@{ilag}), e_ys, [0, 6]; //[response after 4th year to 10th year] @#endfor end; @@ -82,4 +82,4 @@ y_obs,pie_obs(@{ilag}), -; //[ccf] end; estimation(datafile='../gsa/data_ca1.m',mode_check,first_obs=8,nobs=79,mh_nblocks=1, - prefilter=1,mh_jscale=0.0005,mh_replic=5000, mode_compute=4, mh_drop=0.6, bayesian_irf,mcmc_jumping_covariance='identity_matrix') R_obs y; \ No newline at end of file + prefilter=1,mh_jscale=0.0005,mh_replic=5000, mode_compute=4, mh_drop=0.6, bayesian_irf,mcmc_jumping_covariance='identity_matrix') R_obs y; diff --git a/tests/gsa/ls2003a.mod b/tests/gsa/ls2003a.mod index c5083ab19..2f0dc73f2 100644 --- a/tests/gsa/ls2003a.mod +++ b/tests/gsa/ls2003a.mod @@ -70,24 +70,24 @@ end; // endogenous prior restrictions irf_calibration(relative_irf); -y(1:4), e_ys, [ -50 50]; //[first year response] +y(1:4), e_ys, [ -50, 50]; //[first year response] //y(1:4), e_ys, [-inf -50]; //[first year response] @#for ilag in 21:40 -R_obs(@{ilag}), e_ys, [0 6]; //[response after 4th year to 10th year] +R_obs(@{ilag}), e_ys, [0, 6]; //[response after 4th year to 10th year] @#endfor end; /* irf_calibration; -y(1:4), e_ys, [-inf -0.4]; //[first year response] +y(1:4), e_ys, [-inf, -0.4]; //[first year response] @#for ilag in 21:40 -R_obs(@{ilag}), e_ys, [0 0.25]; //[response after 4th year to 10th year] +R_obs(@{ilag}), e_ys, [0, 0.25]; //[response after 4th year to 10th year] @#endfor end; */ moment_calibration; -//y_obs,y_obs, [0.8 1.1]; //[unconditional variance] +//y_obs,y_obs, [0.8, 1.1]; //[unconditional variance] y_obs,y_obs(1:4), +; //[first year acf] //y_obs,pie_obs(-4:4), -; //[ccf] @#for ilag in -2:2 From 6bc0672ddf3552ae19f401ff30c4310eb0e38be5 Mon Sep 17 00:00:00 2001 From: Houtan Bastani Date: Mon, 30 Sep 2019 12:31:45 +0200 Subject: [PATCH 03/10] doc: aesthetic fix --- doc/manual/source/the-model-file.rst | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/manual/source/the-model-file.rst b/doc/manual/source/the-model-file.rst index 7b19c8f92..2334e5921 100644 --- a/doc/manual/source/the-model-file.rst +++ b/doc/manual/source/the-model-file.rst @@ -8738,14 +8738,14 @@ IRF and moment calibration can be defined in ``irf_calibration`` and terminated by ``end;``. To set IRF sign restrictions, the following syntax is used:: - VARIABLE_NAME(INTEGER),EXOGENOUS_NAME, -; - VARIABLE_NAME(INTEGER:INTEGER),EXOGENOUS_NAME, +; + VARIABLE_NAME(INTEGER), EXOGENOUS_NAME, -; + VARIABLE_NAME(INTEGER:INTEGER), EXOGENOUS_NAME, +; To set IRF restrictions with specific intervals, the following syntax is used:: - VARIABLE_NAME(INTEGER),EXOGENOUS_NAME, [EXPRESSION, EXPRESSION]; - VARIABLE_NAME(INTEGER:INTEGER),EXOGENOUS_NAME, [EXPRESSION, EXPRESSION]; + VARIABLE_NAME(INTEGER), EXOGENOUS_NAME, [EXPRESSION, EXPRESSION]; + VARIABLE_NAME(INTEGER:INTEGER), EXOGENOUS_NAME, [EXPRESSION, EXPRESSION]; When ``(INTEGER:INTEGER)`` is used, the restriction is considered to be fulfilled by a logical OR. A list of restrictions must @@ -8775,10 +8775,10 @@ IRF and moment calibration can be defined in ``irf_calibration`` and |br| This block allows defining moment calibration criteria. This block is terminated by ``end;``, and contains lines of the form:: - VARIABLE_NAME1,VARIABLE_NAME2(+/-INTEGER), [EXPRESSION, EXPRESSION]; - VARIABLE_NAME1,VARIABLE_NAME2(+/-INTEGER), +/-; - VARIABLE_NAME1,VARIABLE_NAME2(+/-(INTEGER:INTEGER)), [EXPRESSION, EXPRESSION]; - VARIABLE_NAME1,VARIABLE_NAME2((-INTEGER:+INTEGER)), [EXPRESSION, EXPRESSION]; + VARIABLE_NAME1, VARIABLE_NAME2(+/-INTEGER), [EXPRESSION, EXPRESSION]; + VARIABLE_NAME1, VARIABLE_NAME2(+/-INTEGER), +/-; + VARIABLE_NAME1, VARIABLE_NAME2(+/-(INTEGER:INTEGER)), [EXPRESSION, EXPRESSION]; + VARIABLE_NAME1, VARIABLE_NAME2((-INTEGER:+INTEGER)), [EXPRESSION, EXPRESSION]; When ``(INTEGER:INTEGER)`` is used, the restriction is considered to be fulfilled by a logical OR. A list of restrictions must From 6ece46ce659f1ee5a2541f93e6b545a168141a74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=B3ra=20Linda=20Kocsis?= Date: Tue, 1 Oct 2019 12:13:49 +0200 Subject: [PATCH 04/10] doc: grammar fix --- doc/manual/source/the-model-file.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/manual/source/the-model-file.rst b/doc/manual/source/the-model-file.rst index 2334e5921..7ec175ac2 100644 --- a/doc/manual/source/the-model-file.rst +++ b/doc/manual/source/the-model-file.rst @@ -2391,7 +2391,7 @@ parameters with new values as it will lead to wrong results. *Steady state file for deterministic models* - The ``steady_state_model`` block works also with deterministic + The ``steady_state_model`` block also works with deterministic models. An ``initval`` block and, when necessary, an ``endval`` block, is used to set the value of the exogenous variables. Each ``initval`` or ``endval`` block must be followed by ``steady`` to From 357f0e423ce4d44e49b42749c611e03fe688006b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Tue, 1 Oct 2019 13:40:31 +0200 Subject: [PATCH 05/10] Under Debian, latexmk is needed to compile the manual [skip ci] --- README.md | 3 ++- windows/install-packages.sh | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0e934f11f..be34df871 100644 --- a/README.md +++ b/README.md @@ -237,12 +237,13 @@ All the prerequisites are packaged: - `texlive-generic-extra` (for Sphinx) - `lmodern` (for macroprocessor PDF) - `python3-sphinx` +- `latexmk` - `libjs-mathjax` - `doxygen` You can install them all at once with: ``` -apt install build-essential gfortran liboctave-dev libboost-graph-dev libgsl-dev libmatio-dev libslicot-dev libslicot-pic libsuitesparse-dev flex bison autoconf automake texlive texlive-publishers texlive-latex-extra texlive-fonts-extra texlive-latex-recommended texlive-science texlive-generic-extra lmodern python3-sphinx libjs-mathjax doxygen +apt install build-essential gfortran liboctave-dev libboost-graph-dev libgsl-dev libmatio-dev libslicot-dev libslicot-pic libsuitesparse-dev flex bison autoconf automake texlive texlive-publishers texlive-latex-extra texlive-fonts-extra texlive-latex-recommended texlive-science texlive-generic-extra lmodern python3-sphinx latexmk libjs-mathjax doxygen ``` ## Windows diff --git a/windows/install-packages.sh b/windows/install-packages.sh index 2fbd2f788..4ea28b0d0 100755 --- a/windows/install-packages.sh +++ b/windows/install-packages.sh @@ -25,7 +25,7 @@ PACKAGES=(make xz-utils p7zip bzip2 zip patch wget autoconf automake libtool mingw-w64 gfortran-mingw-w64 parallel flex bison texlive texlive-publishers texlive-latex-extra texlive-math-extra - texlive-fonts-extra lmodern python3-sphinx nsis) + texlive-fonts-extra lmodern python3-sphinx latexmk nsis) apt install "${PACKAGES[@]}" From f3600b0de99a51ab206db8b14dfeb837bf545362 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Scylla=29?= Date: Fri, 29 Sep 2017 10:19:13 +0200 Subject: [PATCH 06/10] Added trap for complex residuals and jacobian in nonlinear solver. --- matlab/dynare_solve.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/matlab/dynare_solve.m b/matlab/dynare_solve.m index 76b654b7b..9ba3ea3f1 100644 --- a/matlab/dynare_solve.m +++ b/matlab/dynare_solve.m @@ -76,7 +76,9 @@ end if jacobian_flag [fvec, fjac] = feval(func, x, varargin{:}); wrong_initial_guess_flag = false; - if ~all(isfinite(fvec)) || any(isinf(fjac(:))) || any(isnan((fjac(:)))) + if ~all(isfinite(fvec)) || any(isinf(fjac(:))) || any(isnan((fjac(:)))) ... + || any(~isreal(fvec)) || any(~isreal(fjac(:))) + disp('Randomize initial guess...') % Let's try random numbers for the variables initialized with the default value. wrong_initial_guess_flag = true; % First try with positive numbers. From ab911e98c4f0fec796516c1220b075e5196ed499 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemia=20=28Scylla=29?= Date: Wed, 13 Feb 2019 15:18:40 +0100 Subject: [PATCH 07/10] Cosmetic changes. --- matlab/backward/backward_model_irf.m | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/matlab/backward/backward_model_irf.m b/matlab/backward/backward_model_irf.m index b57042d90..130079003 100644 --- a/matlab/backward/backward_model_irf.m +++ b/matlab/backward/backward_model_irf.m @@ -137,8 +137,11 @@ end % Get the covariance matrix of the shocks. if ~deterministicshockflag if nnz(M_.Sigma_e) + % Add ϵ>0 on the diagonal, so that the Cholesky won't fail + % if a shock has zero variance Sigma = M_.Sigma_e + 1e-14*eye(M_.exo_nbr); - sigma = transpose(chol(Sigma)); + % Factorize Sigma (C is such that C*C' == Sigma) + C = chol(Sigma, 'lower'); else error('You did not specify the size of the shocks!') end @@ -166,6 +169,7 @@ end % Compute the IRFs (loop over innovations). for i=1:length(listofshocks) + % Reset innovations to the default value (typically zero). innovations = Innovations; % Add the shock. if deterministicshockflag @@ -182,7 +186,8 @@ for i=1:length(listofshocks) if isempty(j) error('backward_model_irf: Exogenous variable %s is unknown!', listofshocks{i}) end - innovations(1,:) = innovations(1,:) + transpose(sigma(:,j)); + % Put the column associated to the j-th structural shock in the first row. + innovations(1,:) = innovations(1,:) + transpose(C(:,j)); end if options_.linear ysim__1 = simul_backward_linear_model_(initialcondition, periods, DynareOptions, DynareModel, DynareOutput, innovations, nx, ny1, iy1, jdx, model_dynamic); From 634b11de70cd473ad256bc8be3a5ed097c6f318c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=28Charybdis=29?= Date: Sun, 4 Mar 2018 19:15:27 +0100 Subject: [PATCH 08/10] Cosmetic change. --- matlab/model_inversion.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/matlab/model_inversion.m b/matlab/model_inversion.m index f9a96ca83..f67288cc1 100644 --- a/matlab/model_inversion.m +++ b/matlab/model_inversion.m @@ -59,7 +59,7 @@ crange = constraints.dates; instruments = exogenousvariables(crange); freeinnovations = instruments.name(find(all(isnan(instruments)))); if ~isequal(length(freeinnovations), constraints.vobs) - error('model_inversion: The number of instruments must be equal to the number of constrained variables!') + error('The number of instruments must be equal to the number of constrained variables!') end % Check if some of the exogenous variables are given. From 8eb3023069849617320bce881d4f9e03b3cbd31d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Mon, 12 Dec 2016 14:06:27 +0100 Subject: [PATCH 09/10] Changed isint function. To make it consistent with the routine available in the dates toolbox. --- matlab/utilities/general/isint.m | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/matlab/utilities/general/isint.m b/matlab/utilities/general/isint.m index f6ed5a64e..01f403d5d 100644 --- a/matlab/utilities/general/isint.m +++ b/matlab/utilities/general/isint.m @@ -1,4 +1,4 @@ -function [b,c,d] = isint(a) +function [l,c,d] = isint(a) % This function tests if the input argument is an integer. % % INPUT @@ -33,7 +33,7 @@ function [b,c,d] = isint(a) % along with Dynare. If not, see . if ~isnumeric(a) - b = false; + l = false; if nargout>1 c = []; d = []; @@ -41,11 +41,9 @@ if ~isnumeric(a) return end -[m,n] = size(a); - -b = abs(fix(a)-a)<1e-15; +l = abs(fix(a)-a)<1e-15; if nargout>1 - c = find(b==1); - d = find(b==0); + c = find(l==true); + d = find(l==false); end \ No newline at end of file From 6a87779d9e91c0970e79443c6b6c020f96d39a26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Thu, 4 Oct 2018 23:17:49 +0200 Subject: [PATCH 10/10] Cosmetic change. --- matlab/utilities/general/isquare.m | 36 +++++++++--------------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/matlab/utilities/general/isquare.m b/matlab/utilities/general/isquare.m index 693417c35..edd2ad1ab 100644 --- a/matlab/utilities/general/isquare.m +++ b/matlab/utilities/general/isquare.m @@ -1,28 +1,14 @@ function info = isquare(A) -%@info: -%! @deftypefn {Function File} {@var{info} =} isquare (@var{A}) -%! @anchor{isquare} -%! @sp 1 -%! Tests if @var{A} is square matrix. -%! @sp 2 -%! @strong{Inputs} -%! @sp 1 -%! @table @ @var -%! @item A -%! Matlab's array. -%! @end table -%! @sp 2 -%! @strong{Outputs} -%! @sp 1 -%! @table @ @var -%! @item info -%! Integer scalar equal to 1 if @var{A} is a square matrix, 0 otherwise. -%! @end table -%! @end deftypefn -%@eod: +% Returns true iff A is a square matrix. +% +% INPUTS +% - A [double] matrix. +% +% OUTPUTS +% - info [logical] -% Copyright (C) 2013-2014 Dynare Team +% Copyright (C) 2013-2018 Dynare Team % % This file is part of Dynare. % @@ -39,7 +25,7 @@ function info = isquare(A) % You should have received a copy of the GNU General Public License % along with Dynare. If not, see . -info = 0; -if isequal(ndims(A),2) && isequal(size(A,1),size(A,2)) - info = 1; +info = false; +if ismatrix(A) && isequal(size(A, 1), size(A, 2)) + info = true; end \ No newline at end of file