From c1999443ceda62cd32b0ddc786ea42ddf1e4f43e Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Wed, 29 Oct 2014 19:33:33 +0100 Subject: [PATCH 1/2] Condition singularity warning on unit root check When singularity is detected, try to compute eigenvalues to see if unit root is present and issue warning according to this check --- matlab/model_diagnostics.m | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/matlab/model_diagnostics.m b/matlab/model_diagnostics.m index 29b56b318..d43618d20 100644 --- a/matlab/model_diagnostics.m +++ b/matlab/model_diagnostics.m @@ -169,6 +169,18 @@ for b=1:nb end if singularity_problem + try + options_check=options; + options_check.noprint=1; + [eigenvalues_] = check(M, options_check, oo); + if any((abs(eigenvalues_)-1)<1e-6) + fprintf('MODEL_DIAGNOSTICS: The singularity seems to be (partly) caused by the presence of a unit root\n') + fprintf('MODEL_DIAGNOSTICS: as the absolute value of one eigenvalue is in the range of +-1e-6 to 1.\n') + fprintf('MODEL_DIAGNOSTICS: If the model is actually supposed to feature unit root behavior, such a warning is expected,\n') + fprintf('MODEL_DIAGNOSTICS: but you should nevertheless check whether there is an additional singularity problem.\n') + end + catch + end fprintf('MODEL_DIAGNOSTICS: The presence of a singularity problem typically indicates that there is one\n') fprintf('MODEL_DIAGNOSTICS: redundant equation entered in the model block, while another non-redundant equation\n') fprintf('MODEL_DIAGNOSTICS: is missing. The problem often derives from Walras Law.\n') From 3a9c2735357212d93682cf715a8120091dd67d02 Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Wed, 29 Oct 2014 19:37:03 +0100 Subject: [PATCH 2/2] Allow for check of Hessian at order>2 in model_diagnostics.m --- matlab/model_diagnostics.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/matlab/model_diagnostics.m b/matlab/model_diagnostics.m index d43618d20..62ec92054 100644 --- a/matlab/model_diagnostics.m +++ b/matlab/model_diagnostics.m @@ -204,7 +204,7 @@ if options.order == 1 [junk,jacobia_] = feval([M.fname '_dynamic'],z(iyr0),exo_simul, ... M.params, dr.ys, it_); end; -elseif options.order == 2 +elseif options.order >= 2 if (options.bytecode) [chck, junk, loc_dr] = bytecode('dynamic','evaluate', z,exo_simul, ... M.params, dr.ys, 1);