From 8f53be2a6fe819175e8d992fb7e8fe24e99f8e68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=28Charybdis=29?= <stephane.adjemian@univ-lemans.fr> Date: Sat, 5 May 2018 16:36:50 +0200 Subject: [PATCH] Impose the consistency of the count of unstable eigenvalues... ... Between stoch_simul and check. Added sdim (the number of stable eigenvalues) and edim (the complementary number of explosive eigenvalues) in dr structure. The test is always done with sdim (or edim) returned by mjdgges. --- doc/dynare.texi | 4 ++++ matlab/check.m | 5 ++--- matlab/dyn_first_order_solver.m | 3 +++ matlab/resol.m | 2 ++ matlab/stochastic_solvers.m | 7 ++++--- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/doc/dynare.texi b/doc/dynare.texi index 6d6a34df3b..9599feaf8e 100644 --- a/doc/dynare.texi +++ b/doc/dynare.texi @@ -3729,6 +3729,9 @@ the square submatrix of the right Schur vectors corresponding to the forward looking variables (jumpers) and to the explosive eigenvalues must have full rank. +Note that the outcome may be different from what would be suggested by +@code{sum(abs(oo_.dr.eigval))} when eigenvalues are very close to @ref{qz_criterium}. + @optionshead @table @code @@ -4348,6 +4351,7 @@ exogenous variables are made available in @code{oo_.exo_simul} (@pxref{oo_.exo_simul}). Default: @code{0}. @item qz_criterium = @var{DOUBLE} +@anchor{qz_criterium} Value used to split stable from unstable eigenvalues in reordering the Generalized Schur decomposition used for solving 1^st order problems. Default: @code{1.000001} (except when estimating with diff --git a/matlab/check.m b/matlab/check.m index f97a758f49..d1755fbb18 100644 --- a/matlab/check.m +++ b/matlab/check.m @@ -78,7 +78,6 @@ end eigenvalues_ = dr.eigval; [m_lambda,i]=sort(abs(eigenvalues_)); -n_explod = nnz(abs(eigenvalues_) > options.qz_criterium); % Count number of forward looking variables if ~options.block @@ -91,7 +90,7 @@ else end result = 0; -if (nyf == n_explod) && (dr.full_rank) +if (nyf == dr.edim) && (dr.full_rank) result = 1; end @@ -101,7 +100,7 @@ if options.noprint == 0 disp(sprintf('%16s %16s %16s\n','Modulus','Real','Imaginary')) z=[m_lambda real(eigenvalues_(i)) imag(eigenvalues_(i))]'; disp(sprintf('%16.4g %16.4g %16.4g\n',z)) - disp(sprintf('\nThere are %d eigenvalue(s) larger than 1 in modulus ', n_explod)); + disp(sprintf('\nThere are %d eigenvalue(s) larger than 1 in modulus ', dr.edim)); disp(sprintf('for %d forward-looking variable(s)',nyf)); skipline() if result diff --git a/matlab/dyn_first_order_solver.m b/matlab/dyn_first_order_solver.m index c74786f82f..f262a61a1b 100644 --- a/matlab/dyn_first_order_solver.m +++ b/matlab/dyn_first_order_solver.m @@ -202,6 +202,9 @@ else return end + dr.sdim = sdim; % Number of stable eigenvalues. + dr.edim = length(dr.eigval)-sdim; % Number of exposive eigenvalues. + nba = nd-sdim; if task==1 diff --git a/matlab/resol.m b/matlab/resol.m index 8cee960d5d..e58eb7e1ba 100644 --- a/matlab/resol.m +++ b/matlab/resol.m @@ -140,6 +140,8 @@ end if options.block [dr,info,M,options,oo] = dr_block(dr,check_flag,M,options,oo); + dr.edim = nnz(abs(dr.eigval) > options.qz_criterium); + dr.sdim = dr.nd-dr.edim; else [dr,info] = stochastic_solvers(dr,check_flag,M,options,oo); end diff --git a/matlab/stochastic_solvers.m b/matlab/stochastic_solvers.m index 9b62f5a466..587641023e 100644 --- a/matlab/stochastic_solvers.m +++ b/matlab/stochastic_solvers.m @@ -232,10 +232,11 @@ if M_.maximum_endo_lead == 0 end dr.eigval = eig(kalman_transition_matrix(dr,nstatic+(1:nspred),1:nspred,M_.exo_nbr)); dr.full_rank = 1; - if any(abs(dr.eigval) > options_.qz_criterium) + dr.edim = nnz(abs(dr.eigval) > options_.qz_criterium); + dr.sdim = nd-dr.edim; + if dr.edim temp = sort(abs(dr.eigval)); - nba = nnz(abs(dr.eigval) > options_.qz_criterium); - temp = temp(nd-nba+1:nd)-1-options_.qz_criterium; + temp = temp(dr.sdim+1:nd)-1-options_.qz_criterium; info(1) = 3; info(2) = temp'*temp; end -- GitLab