2014-03-28 14:52:06 +01:00
|
|
|
function []=display_problematic_vars_Jacobian(problemrow,problemcol,M_,x,type,caller_string)
|
2021-10-11 17:45:03 +02:00
|
|
|
% []=display_problematic_vars_Jacobian(problemrow,problemcol,M_,x,caller_string)
|
2017-05-16 15:10:20 +02:00
|
|
|
% print the equation numbers and variables associated with problematic entries
|
|
|
|
% of the Jacobian
|
2014-03-28 14:52:06 +01:00
|
|
|
%
|
|
|
|
% INPUTS
|
|
|
|
% problemrow [vector] rows associated with problematic entries
|
|
|
|
% problemcol [vector] columns associated with problematic entries
|
2017-05-16 15:10:20 +02:00
|
|
|
% M_ [matlab structure] Definition of the model.
|
2014-03-28 14:52:06 +01:00
|
|
|
% x [vector] point at which the Jacobian was evaluated
|
|
|
|
% type [string] 'static' or 'dynamic' depending on the type of
|
|
|
|
% Jacobian
|
2017-05-16 15:10:20 +02:00
|
|
|
% caller_string [string] contains name of calling function for printing
|
|
|
|
%
|
2014-03-28 14:52:06 +01:00
|
|
|
% OUTPUTS
|
|
|
|
% none.
|
2017-05-16 15:10:20 +02:00
|
|
|
%
|
2014-03-28 14:52:06 +01:00
|
|
|
|
2022-04-13 13:15:19 +02:00
|
|
|
% Copyright © 2014-2021 Dynare Team
|
2014-03-28 14:52:06 +01:00
|
|
|
%
|
|
|
|
% This file is part of Dynare.
|
|
|
|
%
|
|
|
|
% Dynare is free software: you can redistribute it and/or modify
|
|
|
|
% it under the terms of the GNU General Public License as published by
|
|
|
|
% the Free Software Foundation, either version 3 of the License, or
|
|
|
|
% (at your option) any later version.
|
|
|
|
%
|
|
|
|
% Dynare is distributed in the hope that it will be useful,
|
|
|
|
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
% GNU General Public License for more details.
|
|
|
|
%
|
|
|
|
% You should have received a copy of the GNU General Public License
|
2021-06-09 17:33:48 +02:00
|
|
|
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
2014-03-28 14:52:06 +01:00
|
|
|
|
2016-08-19 11:17:43 +02:00
|
|
|
skipline();
|
2014-03-28 14:52:06 +01:00
|
|
|
if nargin<6
|
|
|
|
caller_string='';
|
|
|
|
end
|
2021-10-11 17:45:03 +02:00
|
|
|
initial_aux_eq_nbr=M_.ramsey_eq_nbr;
|
2014-03-28 14:52:06 +01:00
|
|
|
if strcmp(type,'dynamic')
|
|
|
|
for ii=1:length(problemrow)
|
2016-06-14 18:32:47 +02:00
|
|
|
if problemcol(ii)>max(M_.lead_lag_incidence)
|
|
|
|
var_row=2;
|
|
|
|
var_index=problemcol(ii)-max(max(M_.lead_lag_incidence));
|
|
|
|
else
|
|
|
|
[var_row,var_index]=find(M_.lead_lag_incidence==problemcol(ii));
|
|
|
|
end
|
2014-03-28 14:52:06 +01:00
|
|
|
if var_row==2
|
|
|
|
type_string='';
|
|
|
|
elseif var_row==1
|
|
|
|
type_string='lag of';
|
2017-05-16 12:42:01 +02:00
|
|
|
elseif var_row==3
|
2014-03-28 14:52:06 +01:00
|
|
|
type_string='lead of';
|
|
|
|
end
|
2016-06-14 18:32:47 +02:00
|
|
|
if problemcol(ii)<=max(max(M_.lead_lag_incidence)) && var_index<=M_.orig_endo_nbr
|
2021-10-11 17:45:03 +02:00
|
|
|
if problemrow(ii)<=initial_aux_eq_nbr
|
2017-10-10 10:05:59 +02:00
|
|
|
eq_nbr = problemrow(ii);
|
|
|
|
fprintf('Derivative of Auxiliary Equation %d with respect to %s Variable %s (initial value of %s: %g) \n', ...
|
|
|
|
eq_nbr, type_string, M_.endo_names{var_index}, M_.endo_names{var_index}, x(var_index));
|
2014-07-18 14:05:12 +02:00
|
|
|
else
|
2021-10-11 17:45:03 +02:00
|
|
|
eq_nbr = problemrow(ii)-initial_aux_eq_nbr;
|
2017-10-10 10:05:59 +02:00
|
|
|
fprintf('Derivative of Equation %d with respect to %s Variable %s (initial value of %s: %g) \n', ...
|
|
|
|
eq_nbr, type_string, M_.endo_names{var_index}, M_.endo_names{var_index}, x(var_index));
|
2014-07-18 14:05:12 +02:00
|
|
|
end
|
2017-10-10 10:05:59 +02:00
|
|
|
elseif problemcol(ii)<=max(max(M_.lead_lag_incidence)) && var_index>M_.orig_endo_nbr % auxiliary vars
|
|
|
|
if M_.aux_vars(1,problemcol(ii)-M_.orig_endo_nbr).type==6 %Ramsey Lagrange Multiplier
|
2021-10-11 17:45:03 +02:00
|
|
|
if problemrow(ii)<=initial_aux_eq_nbr
|
2017-10-10 10:05:59 +02:00
|
|
|
eq_nbr = problemrow(ii);
|
|
|
|
fprintf('Derivative of Auxiliary Equation %d with respect to %s of Langrange multiplier of equation %s (initial value: %g) \n', ...
|
|
|
|
eq_nbr, type_string, M_.aux_vars(1,problemcol(ii)-M_.orig_endo_nbr).eq_nbr, x(problemcol(ii)));
|
|
|
|
else
|
2021-10-11 17:45:03 +02:00
|
|
|
eq_nbr = problemrow(ii)-initial_aux_eq_nbr;
|
2017-10-10 10:05:59 +02:00
|
|
|
fprintf('Derivative of Equation %d with respect to %s of Langrange multiplier of equation %s (initial value: %g) \n', ...
|
|
|
|
eq_nbr, type_string, M_.aux_vars(1,problemcol(ii)-M_.orig_endo_nbr).eq_nbr, x(problemcol(ii)));
|
|
|
|
end
|
2017-05-16 15:10:20 +02:00
|
|
|
else
|
2021-10-11 17:45:03 +02:00
|
|
|
if problemrow(ii)<=initial_aux_eq_nbr
|
2017-10-10 10:05:59 +02:00
|
|
|
eq_nbr = problemrow(ii);
|
|
|
|
orig_var_index = M_.aux_vars(1,var_index-M_.orig_endo_nbr).orig_index;
|
|
|
|
fprintf('Derivative of Auxiliary Equation %d with respect to %s Variable %s (initial value of %s: %g) \n', ...
|
|
|
|
eq_nbr, type_string, M_.endo_names{orig_var_index}, M_.endo_names{orig_var_index}, x(orig_var_index));
|
|
|
|
else
|
2021-10-11 17:45:03 +02:00
|
|
|
eq_nbr = problemrow(ii)-initial_aux_eq_nbr;
|
2017-10-10 10:05:59 +02:00
|
|
|
orig_var_index = M_.aux_vars(1,var_index-M_.orig_endo_nbr).orig_index;
|
|
|
|
fprintf('Derivative of Equation %d with respect to %s Variable %s (initial value of %s: %g) \n', ...
|
|
|
|
eq_nbr, type_string, M_.endo_names{orig_var_index}, M_.endo_names{orig_var_index}, x(orig_var_index));
|
|
|
|
end
|
2017-05-16 15:10:20 +02:00
|
|
|
end
|
2016-06-14 18:32:47 +02:00
|
|
|
elseif problemcol(ii)>max(max(M_.lead_lag_incidence)) && var_index<=M_.exo_nbr
|
2021-10-11 17:45:03 +02:00
|
|
|
if problemrow(ii)<=initial_aux_eq_nbr
|
2017-10-10 10:05:59 +02:00
|
|
|
eq_nbr = problemrow(ii);
|
|
|
|
fprintf('Derivative of Auxiliary Equation %d with respect to %s shock %s \n', ...
|
|
|
|
eq_nbr, type_string, M_.exo_names{var_index});
|
2016-06-14 18:32:47 +02:00
|
|
|
else
|
2021-10-11 17:45:03 +02:00
|
|
|
eq_nbr = problemrow(ii)-initial_aux_eq_nbr;
|
2019-12-20 16:28:06 +01:00
|
|
|
fprintf('Derivative of Equation %d with respect to %s shock %s \n', ...
|
2017-10-10 10:05:59 +02:00
|
|
|
eq_nbr, type_string, M_.exo_names{var_index});
|
2017-05-16 15:10:20 +02:00
|
|
|
end
|
2016-06-14 18:32:47 +02:00
|
|
|
else
|
|
|
|
error('display_problematic_vars_Jacobian:: The error should not happen. Please contact the developers')
|
|
|
|
end
|
2014-03-28 14:52:06 +01:00
|
|
|
end
|
2017-10-10 10:05:59 +02:00
|
|
|
fprintf('\n%s The problem most often occurs, because a variable with\n', caller_string)
|
2021-10-11 17:45:03 +02:00
|
|
|
fprintf('%s exponent smaller than 0 has been initialized to 0. Taking the derivative\n', caller_string)
|
2017-10-10 10:05:59 +02:00
|
|
|
fprintf('%s and evaluating it at the steady state then results in a division by 0.\n', caller_string)
|
|
|
|
fprintf('%s If you are using model-local variables (# operator), check their values as well.\n', caller_string)
|
|
|
|
elseif strcmp(type, 'static')
|
2014-03-28 14:52:06 +01:00
|
|
|
for ii=1:length(problemrow)
|
|
|
|
if problemcol(ii)<=M_.orig_endo_nbr
|
2021-10-11 17:45:03 +02:00
|
|
|
if problemrow(ii)<=initial_aux_eq_nbr
|
2017-10-10 10:05:59 +02:00
|
|
|
eq_nbr = problemrow(ii);
|
|
|
|
fprintf('Derivative of Auxiliary Equation %d with respect to Variable %s (initial value of %s: %g) \n', ...
|
2019-12-20 16:28:06 +01:00
|
|
|
eq_nbr, M_.endo_names{problemcol(ii)}, M_.endo_names{problemcol(ii)}, x(problemcol(ii)));
|
2014-07-18 14:05:12 +02:00
|
|
|
else
|
2021-10-11 17:45:03 +02:00
|
|
|
eq_nbr = problemrow(ii)-initial_aux_eq_nbr;
|
2019-12-20 16:28:06 +01:00
|
|
|
fprintf('Derivative of Equation %d with respect to Variable %s (initial value of %s: %g) \n', ...
|
2017-10-10 10:05:59 +02:00
|
|
|
eq_nbr, M_.endo_names{problemcol(ii)}, M_.endo_names{problemcol(ii)}, x(problemcol(ii)));
|
2014-07-18 14:05:12 +02:00
|
|
|
end
|
2014-03-28 14:52:06 +01:00
|
|
|
else %auxiliary vars
|
2017-05-16 15:10:20 +02:00
|
|
|
if M_.aux_vars(1,problemcol(ii)-M_.orig_endo_nbr).type ==6 %Ramsey Lagrange Multiplier
|
2021-10-11 17:45:03 +02:00
|
|
|
if problemrow(ii)<=initial_aux_eq_nbr
|
2017-10-10 10:05:59 +02:00
|
|
|
eq_nbr = problemrow(ii);
|
|
|
|
fprintf('Derivative of Auxiliary Equation %d with respect to Lagrange multiplier of equation %d (initial value: %g) \n', ...
|
|
|
|
eq_nbr, M_.aux_vars(1,problemcol(ii)-M_.orig_endo_nbr).eq_nbr, x(problemcol(ii)));
|
2014-07-18 14:05:12 +02:00
|
|
|
else
|
2021-10-11 17:45:03 +02:00
|
|
|
eq_nbr = problemrow(ii)-initial_aux_eq_nbr;
|
2017-10-10 10:05:59 +02:00
|
|
|
fprintf('Derivative of Equation %d with respect to Lagrange multiplier of equation %d (initial value: %g) \n', ...
|
|
|
|
eq_nbr, M_.aux_vars(1,problemcol(ii)-M_.orig_endo_nbr).eq_nbr, x(problemcol(ii)));
|
2014-07-18 14:05:12 +02:00
|
|
|
end
|
|
|
|
else
|
2021-10-11 17:45:03 +02:00
|
|
|
if problemrow(ii)<=initial_aux_eq_nbr
|
2017-10-10 10:05:59 +02:00
|
|
|
eq_nbr = problemrow(ii);
|
|
|
|
orig_var_index = M_.aux_vars(1,problemcol(ii)-M_.orig_endo_nbr).orig_index;
|
|
|
|
fprintf('Derivative of Auxiliary Equation %d with respect to Variable %s (initial value of %s: %g) \n', ...
|
|
|
|
eq_nbr, M_.endo_names{orig_var_index}, M_.endo_names{orig_var_index}, x(problemcol(ii)));
|
2017-05-16 15:10:20 +02:00
|
|
|
else
|
2021-10-11 17:45:03 +02:00
|
|
|
eq_nbr = problemrow(ii)-initial_aux_eq_nbr;
|
2017-10-10 10:05:59 +02:00
|
|
|
orig_var_index = M_.aux_vars(1,problemcol(ii)-M_.orig_endo_nbr).orig_index;
|
|
|
|
fprintf('Derivative of Equation %d with respect to Variable %s (initial value of %s: %g) \n', ...
|
|
|
|
eq_nbr, M_.endo_names{orig_var_index}, M_.endo_names{orig_var_index}, x(problemcol(ii)));
|
2017-05-16 15:10:20 +02:00
|
|
|
end
|
2014-07-18 14:05:12 +02:00
|
|
|
end
|
2014-03-28 14:52:06 +01:00
|
|
|
end
|
|
|
|
end
|
2017-10-10 10:05:59 +02:00
|
|
|
fprintf('\n%s The problem most often occurs, because a variable with\n', caller_string)
|
|
|
|
fprintf('%s exponent smaller than 1 has been initialized to 0. Taking the derivative\n', caller_string)
|
|
|
|
fprintf('%s and evaluating it at the steady state then results in a division by 0.\n', caller_string)
|
|
|
|
fprintf('%s If you are using model-local variables (# operator), check their values as well.\n', caller_string)
|
2014-03-28 14:52:06 +01:00
|
|
|
else
|
2017-05-16 15:10:20 +02:00
|
|
|
error('Unknown Type')
|
2014-03-28 14:52:06 +01:00
|
|
|
end
|