diff --git a/matlab/dynare_identification.m b/matlab/dynare_identification.m index a640da990..9586dea3c 100644 --- a/matlab/dynare_identification.m +++ b/matlab/dynare_identification.m @@ -461,7 +461,7 @@ if iload <=0 identification_analysis(params, indpmodel, indpstderr, indpcorr, options_ident, dataset_info, prior_exist, 1); %the 1 at the end implies initialization of persistent variables if info(1)~=0 % there are errors in the solution algorithm - message = get_error_message(info,0,options_); + message = get_error_message(info,options_); fprintf('-----------\n'); fprintf('The model does not solve for %s (info = %d: %s)\n', parameters, info(1), message); fprintf('-----------\n'); diff --git a/matlab/fjaco.m b/matlab/fjaco.m index 74398be57..566d2b729 100644 --- a/matlab/fjaco.m +++ b/matlab/fjaco.m @@ -59,7 +59,7 @@ function disp_info_error_identification_perturbation(info,j) % there are errors in the solution algorithm probl_par = get_the_name(j,varargin{5}.TeX,varargin{3},varargin{2},varargin{5}); skipline() - message = get_error_message(info,0,varargin{5}); + message = get_error_message(info,varargin{5}); fprintf('Parameter error in numerical two-sided difference method:\n') fprintf('Cannot solve the model for %s (info = %d, %s)\n', probl_par, info(1), message); fprintf('Possible solutions:\n') diff --git a/matlab/get_error_message.m b/matlab/get_error_message.m index 4380f3a90..c4ed1148a 100644 --- a/matlab/get_error_message.m +++ b/matlab/get_error_message.m @@ -1,9 +1,8 @@ -function message = get_error_message(info, noprint, DynareOptions) +function message = get_error_message(info, DynareOptions) % Returns error messages % % INPUTS % info [double] vector returned by resol.m -% noprint [integer] equal to 0 if the error message has to be printed. % DynareOptions [structure] --> options_ % OUTPUTS % message [string] corresponding error message @@ -11,7 +10,7 @@ function message = get_error_message(info, noprint, DynareOptions) % SPECIAL REQUIREMENTS % none -% Copyright (C) 2005-2019 Dynare Team +% Copyright (C) 2005-2020 Dynare Team % % This file is part of Dynare. % @@ -28,147 +27,145 @@ function message = get_error_message(info, noprint, DynareOptions) % You should have received a copy of the GNU General Public License % along with Dynare. If not, see . -if ~noprint - switch info(1) - case 0 - message = ''; - case 1 - message = 'The model doesn''t determine the current variable uniquely.'; - case 2 - message = sprintf('The generalized Schur (QZ) decomposition failed. For more information, see the documentation for Lapack function dgges: info=%d, n=%d. You can also run model_diagnostics to get more information on what may cause this problem.', info(2), info(3)); - case 3 - message = 'Blanchard & Kahn conditions are not satisfied: no stable equilibrium.'; - case 4 - message = 'Blanchard & Kahn conditions are not satisfied: indeterminacy.'; - case 5 - message = 'Blanchard & Kahn conditions are not satisfied: indeterminacy due to rank failure.'; - case 6 - message = 'The Jacobian matrix evaluated at the steady state contains elements that are not real or are infinite.'; - case 7 - message = sprintf('One of the eigenvalues is close to 0/0 (the absolute value of numerator and denominator is smaller than %5.4f!\n If you believe that the model has a unique solution you can try to reduce the value of qz_zero_threshold.',DynareOptions.qz_zero_threshold); - case 8 - if size(info,2)>=2 - global M_; - disp_string = M_.param_names{info(2)}; - for ii=1:length(info)-2 - disp_string = [disp_string, ', ', M_.param_names{info(2+ii)}]; - end - message = ['The Jacobian contains NaNs because the following parameters are NaN: ' disp_string]; - else - message = 'The Jacobian contains NaNs. For more information, use options_.debug.'; +switch info(1) + case 0 + message = ''; + case 1 + message = 'The model doesn''t determine the current variable uniquely.'; + case 2 + message = sprintf('The generalized Schur (QZ) decomposition failed. For more information, see the documentation for Lapack function dgges: info=%d, n=%d. You can also run model_diagnostics to get more information on what may cause this problem.', info(2), info(3)); + case 3 + message = 'Blanchard & Kahn conditions are not satisfied: no stable equilibrium.'; + case 4 + message = 'Blanchard & Kahn conditions are not satisfied: indeterminacy.'; + case 5 + message = 'Blanchard & Kahn conditions are not satisfied: indeterminacy due to rank failure.'; + case 6 + message = 'The Jacobian matrix evaluated at the steady state contains elements that are not real or are infinite.'; + case 7 + message = sprintf('One of the eigenvalues is close to 0/0 (the absolute value of numerator and denominator is smaller than %5.4f!\n If you believe that the model has a unique solution you can try to reduce the value of qz_zero_threshold.',DynareOptions.qz_zero_threshold); + case 8 + if size(info,2)>=2 + global M_; + disp_string = M_.param_names{info(2)}; + for ii=1:length(info)-2 + disp_string = [disp_string, ', ', M_.param_names{info(2+ii)}]; end - case 9 - message = 'k_order_pert was unable to compute the solution'; - case 10 - message = 'The Jacobian of the dynamic model contains Inf. For more information, use options_.debug.'; - case 11 - message = 'The Hessian of the dynamic model used for second order solutions must not contain Inf'; - case 12 - message = 'The Hessian of the dynamic model used for second order solutions must not contain NaN'; - case 19 - message = 'The steadystate file did not compute the steady state'; - case 20 - if DynareOptions.linear - message = sprintf('Impossible to find the steady state (the sum of square residuals of the static equations is %5.4f). Either the model doesn''t have a steady state or there are an infinity of steady states Check whether your model is truly linear or whether there is a mistake in linearization.', info(2)); - else - message = sprintf('Impossible to find the steady state (the sum of square residuals of the static equations is %5.4f). Either the model doesn''t have a steady state, there are an infinity of steady states, or the guess values are too far from the solution', info(2)); - end - case 21 - message = sprintf('The steady state is complex (the sum of square residuals of imaginary parts of the steady state is %5.4f)', info(2)); - case 22 - message = 'The steady state has NaNs or Inf.'; - case 23 - message = 'Parameters have been updated in the steadystate routine and some have complex values.'; - case 24 - message = 'Parameters have been updated in the steadystate routine and some are NaNs or Inf.'; - case 25 - message = 'The solution to the static equations is not a steady state of the dynamic model: verify that the equations tagged by [static] and [dynamic] are consistent'; - case 26 - message = 'The loglinearization of the model cannot be performed, because the steady state is not strictly positive.'; - case 30 - message = 'Ergodic variance can''t be computed.'; - case 41 - message = 'one (many) parameter(s) do(es) not satisfy the lower bound'; - case 42 - message = 'one (many) parameter(s) do(es) not satisfy the upper bound'; - case 43 - message = 'Covariance matrix of structural shocks is not positive definite'; - case 44 %DsgeLikelihood_hh / dsge_likelihood - message = 'The covariance matrix of the measurement errors is not positive definite.'; - case 45 %DsgeLikelihood_hh / dsge_likelihood - message = 'Likelihood is not a number (NaN) or a complex number'; - case 46 %DsgeLikelihood_hh / dsge_likelihood - message = 'Likelihood is a complex number'; - case 47 %DsgeLikelihood_hh / dsge_likelihood - message = 'Prior density is not a number (NaN)'; - case 48 %DsgeLikelihood_hh / dsge_likelihood - message = 'Prior density is a complex number'; - case 49 - message = 'The model violates one (many) endogenous prior restriction(s)'; - case 50 - message = 'Likelihood is Inf'; - case 51 - message = sprintf('\n The dsge_prior_weight is dsge_var=%5.4f, but must be at least %5.4f for the prior to be proper.\n You are estimating a DSGE-VAR model, but the value of the dsge prior weight is too low!', info(2), info(3)); - case 52 %dsge_var_likelihood - message = 'You are estimating a DSGE-VAR model, but the implied covariance matrix of the VAR''s innovations, based on artificial and actual sample is not positive definite!'; - case 53 %dsge_var_likelihood - message = 'You are estimating a DSGE-VAR model, but the implied covariance matrix of the VAR''s innovations, based on the artificial sample, is not positive definite!'; - case 55 - message = 'Fast Kalman filter only works with stationary models [lik_init=1] or stationary observables for non-stationary models [lik_init=3]'; - case 61 %Discretionary policy - message = 'Discretionary policy: maximum number of iterations has been reached. Procedure failed.'; - case 62 - message = 'Discretionary policy: some eigenvalues greater than options_.qz_criterium. Model potentially unstable.'; - case 63 - message = 'Discretionary policy: NaN elements are present in the solution. Procedure failed.'; - case 64 - message = 'discretionary_policy: the derivatives of the objective function contain NaN.'; - case 65 - message = 'discretionary_policy: the model must be written in deviation form and not have constant terms.'; - case 66 - message = 'discretionary_policy: the objective function must have zero first order derivatives.'; - case 71 - message = 'Calibrated covariance of the structural errors implies correlation larger than +-1.'; - case 72 - message = 'Calibrated covariance of the measurement errors implies correlation larger than +-1.'; - % Aim Code Conversions by convertAimCodeToInfo.m - case 81 - message = ['Ramsey: The solution to the static first order conditions for optimal policy could not be found. Either the model' ... - ' doesn''t have a steady state, there are an infinity of steady states, ' ... - ' or the guess values are too far from the solution']; - case 82 - message = 'Ramsey: The steady state computation resulted in NaN in the static first order conditions for optimal policy'; - case 83 - message = 'Ramsey: The steady state computation resulted in NaN in the auxiliary equations for optimal policy'; - case 84 - message = 'Ramsey: The steady state file computation for the Ramsey problem resulted in NaNs at the initial values of the instruments'; - case 85 - message = 'Ramsey: The steady state file does not solve the static first order conditions conditional on the instruments.'; - case 86 - message = 'Ramsey: The steady state file provides complex numbers conditional on the instruments.'; - case 87 - message = 'Ramsey: The maximum number of iterations has been reached. Try increasing maxit.'; - case 102 - message = 'Aim: roots not correctly computed by real_schur'; - case 103 - message = 'Aim: too many explosive roots: no stable equilibrium'; - case 135 - message = 'Aim: too many explosive roots, and q(:,right) is singular'; - case 104 - message = 'Aim: too few explosive roots: indeterminacy'; - case 145 - message = 'Aim: too few explosive roots, and q(:,right) is singular'; - case 105 - message = 'Aim: q(:,right) is singular'; - case 161 - message = 'Aim: too many exact shiftrights'; - case 162 - message = 'Aim: too many numeric shiftrights'; - case 163 - message = 'Aim: A is NAN or INF.'; - case 164 - message = 'Aim: Problem in SPEIG.'; - otherwise - message = 'This case shouldn''t happen. Contact the authors of Dynare'; - end + message = ['The Jacobian contains NaNs because the following parameters are NaN: ' disp_string]; + else + message = 'The Jacobian contains NaNs. For more information, use options_.debug.'; + end + case 9 + message = 'k_order_pert was unable to compute the solution'; + case 10 + message = 'The Jacobian of the dynamic model contains Inf. For more information, use options_.debug.'; + case 11 + message = 'The Hessian of the dynamic model used for second order solutions must not contain Inf'; + case 12 + message = 'The Hessian of the dynamic model used for second order solutions must not contain NaN'; + case 19 + message = 'The steadystate file did not compute the steady state'; + case 20 + if DynareOptions.linear + message = sprintf('Impossible to find the steady state (the sum of square residuals of the static equations is %5.4f). Either the model doesn''t have a steady state or there are an infinity of steady states Check whether your model is truly linear or whether there is a mistake in linearization.', info(2)); + else + message = sprintf('Impossible to find the steady state (the sum of square residuals of the static equations is %5.4f). Either the model doesn''t have a steady state, there are an infinity of steady states, or the guess values are too far from the solution', info(2)); + end + case 21 + message = sprintf('The steady state is complex (the sum of square residuals of imaginary parts of the steady state is %5.4f)', info(2)); + case 22 + message = 'The steady state has NaNs or Inf.'; + case 23 + message = 'Parameters have been updated in the steadystate routine and some have complex values.'; + case 24 + message = 'Parameters have been updated in the steadystate routine and some are NaNs or Inf.'; + case 25 + message = 'The solution to the static equations is not a steady state of the dynamic model: verify that the equations tagged by [static] and [dynamic] are consistent'; + case 26 + message = 'The loglinearization of the model cannot be performed, because the steady state is not strictly positive.'; + case 30 + message = 'Ergodic variance can''t be computed.'; + case 41 + message = 'one (many) parameter(s) do(es) not satisfy the lower bound'; + case 42 + message = 'one (many) parameter(s) do(es) not satisfy the upper bound'; + case 43 + message = 'Covariance matrix of structural shocks is not positive definite'; + case 44 %DsgeLikelihood_hh / dsge_likelihood + message = 'The covariance matrix of the measurement errors is not positive definite.'; + case 45 %DsgeLikelihood_hh / dsge_likelihood + message = 'Likelihood is not a number (NaN) or a complex number'; + case 46 %DsgeLikelihood_hh / dsge_likelihood + message = 'Likelihood is a complex number'; + case 47 %DsgeLikelihood_hh / dsge_likelihood + message = 'Prior density is not a number (NaN)'; + case 48 %DsgeLikelihood_hh / dsge_likelihood + message = 'Prior density is a complex number'; + case 49 + message = 'The model violates one (many) endogenous prior restriction(s)'; + case 50 + message = 'Likelihood is Inf'; + case 51 + message = sprintf('\n The dsge_prior_weight is dsge_var=%5.4f, but must be at least %5.4f for the prior to be proper.\n You are estimating a DSGE-VAR model, but the value of the dsge prior weight is too low!', info(2), info(3)); + case 52 %dsge_var_likelihood + message = 'You are estimating a DSGE-VAR model, but the implied covariance matrix of the VAR''s innovations, based on artificial and actual sample is not positive definite!'; + case 53 %dsge_var_likelihood + message = 'You are estimating a DSGE-VAR model, but the implied covariance matrix of the VAR''s innovations, based on the artificial sample, is not positive definite!'; + case 55 + message = 'Fast Kalman filter only works with stationary models [lik_init=1] or stationary observables for non-stationary models [lik_init=3]'; + case 61 %Discretionary policy + message = 'Discretionary policy: maximum number of iterations has been reached. Procedure failed.'; + case 62 + message = 'Discretionary policy: some eigenvalues greater than options_.qz_criterium. Model potentially unstable.'; + case 63 + message = 'Discretionary policy: NaN elements are present in the solution. Procedure failed.'; + case 64 + message = 'discretionary_policy: the derivatives of the objective function contain NaN.'; + case 65 + message = 'discretionary_policy: the model must be written in deviation form and not have constant terms.'; + case 66 + message = 'discretionary_policy: the objective function must have zero first order derivatives.'; + case 71 + message = 'Calibrated covariance of the structural errors implies correlation larger than +-1.'; + case 72 + message = 'Calibrated covariance of the measurement errors implies correlation larger than +-1.'; + % Aim Code Conversions by convertAimCodeToInfo.m + case 81 + message = ['Ramsey: The solution to the static first order conditions for optimal policy could not be found. Either the model' ... + ' doesn''t have a steady state, there are an infinity of steady states, ' ... + ' or the guess values are too far from the solution']; + case 82 + message = 'Ramsey: The steady state computation resulted in NaN in the static first order conditions for optimal policy'; + case 83 + message = 'Ramsey: The steady state computation resulted in NaN in the auxiliary equations for optimal policy'; + case 84 + message = 'Ramsey: The steady state file computation for the Ramsey problem resulted in NaNs at the initial values of the instruments'; + case 85 + message = 'Ramsey: The steady state file does not solve the static first order conditions conditional on the instruments.'; + case 86 + message = 'Ramsey: The steady state file provides complex numbers conditional on the instruments.'; + case 87 + message = 'Ramsey: The maximum number of iterations has been reached. Try increasing maxit.'; + case 102 + message = 'Aim: roots not correctly computed by real_schur'; + case 103 + message = 'Aim: too many explosive roots: no stable equilibrium'; + case 135 + message = 'Aim: too many explosive roots, and q(:,right) is singular'; + case 104 + message = 'Aim: too few explosive roots: indeterminacy'; + case 145 + message = 'Aim: too few explosive roots, and q(:,right) is singular'; + case 105 + message = 'Aim: q(:,right) is singular'; + case 161 + message = 'Aim: too many exact shiftrights'; + case 162 + message = 'Aim: too many numeric shiftrights'; + case 163 + message = 'Aim: A is NAN or INF.'; + case 164 + message = 'Aim: Problem in SPEIG.'; + otherwise + message = 'This case shouldn''t happen. Contact the authors of Dynare'; end \ No newline at end of file diff --git a/matlab/print_info.m b/matlab/print_info.m index 08902a181..7fa109391 100644 --- a/matlab/print_info.m +++ b/matlab/print_info.m @@ -11,7 +11,7 @@ function print_info(info, noprint, DynareOptions) % SPECIAL REQUIREMENTS % none -% Copyright (C) 2005-2019 Dynare Team +% Copyright (C) 2005-2020 Dynare Team % % This file is part of Dynare. % @@ -27,6 +27,7 @@ function print_info(info, noprint, DynareOptions) % % You should have received a copy of the GNU General Public License % along with Dynare. If not, see . - -message = get_error_message(info, noprint, DynareOptions); -error(message); +if ~noprint + message = get_error_message(info, DynareOptions); + error(message); +end \ No newline at end of file