From 8282e76d6197f324d7051241fdf2766db2ca9017 Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Thu, 31 Oct 2013 08:07:55 +0100 Subject: [PATCH] Add more explicit information in case of singularity problem --- matlab/dynare_estimation_1.m | 2 +- matlab/model_diagnostics.m | 7 +++++++ matlab/print_info.m | 3 ++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/matlab/dynare_estimation_1.m b/matlab/dynare_estimation_1.m index 2c8783bfd..ec907da7b 100644 --- a/matlab/dynare_estimation_1.m +++ b/matlab/dynare_estimation_1.m @@ -646,7 +646,7 @@ if ~options_.mh_posterior_mode_estimation && options_.cova_compute disp('POSTERIOR KERNEL OPTIMIZATION PROBLEM!') disp(' (minus) the hessian matrix at the "mode" is not positive definite!') disp('=> posterior variance of the estimated parameters are not positive.') - disp('You should try to change the initial values of the parameters using') + disp('You should try to change the initial values of the parameters using') disp('the estimated_params_init block, or use another optimization routine.') params_at_bound=find(xparam1==ub | xparam1==lb); if ~isempty(params_at_bound) diff --git a/matlab/model_diagnostics.m b/matlab/model_diagnostics.m index 06eaf2bad..611ae9d38 100644 --- a/matlab/model_diagnostics.m +++ b/matlab/model_diagnostics.m @@ -85,6 +85,7 @@ end % % singular Jacobian of static model % +singularity_problem = 0; if ~isfield(M,'block_structure_stat') nb = 1; else @@ -107,6 +108,7 @@ for b=1:nb end rank_jacob = rank(jacob); if rank_jacob < size(jacob,1) + singularity_problem = 1; disp(['model_diagnostic: the Jacobian of the static model is ' ... 'singular']) disp(['there is ' num2str(endo_nbr-rank_jacob) ... @@ -143,4 +145,9 @@ for b=1:nb end end end +if singularity_problem + fprint('The presence of a singularity problem typically indicates that there is one\n') + fprint('redundant equation entered in the model block, while another non-redundant equation\n') + fprint('is missing. The problem often derives from Walras Law.\n') +end diff --git a/matlab/print_info.m b/matlab/print_info.m index 157275fb4..e4fe151a5 100644 --- a/matlab/print_info.m +++ b/matlab/print_info.m @@ -36,7 +36,8 @@ if ~noprint case 2 error(['The generalized Schur (QZ) decomposition failed. ' ... 'For more information, see the documentation for Lapack function dgges: info=' ... - int2str(info(2)) ', n=' int2str(info(3))]) + int2str(info(2)) ', n=' int2str(info(3)) ... + '. You can also run model_diagnostics to get more information on what may cause this problem.']) case 3 error(['Blanchard Kahn conditions are not satisfied: no stable' ... ' equilibrium'])