Commit ebe81eb6 authored by Johannes Pfeifer 's avatar Johannes Pfeifer
Browse files

display_problematic_vars_Jacobian.m: fix display when auxiliary equations...

display_problematic_vars_Jacobian.m: fix display when auxiliary equations outside of Ramsey are present
parent 8052920a
function []=display_problematic_vars_Jacobian(problemrow,problemcol,M_,x,type,caller_string) function []=display_problematic_vars_Jacobian(problemrow,problemcol,M_,x,type,caller_string)
% []=display_problematic_vars_Jacobian(problemrow,problemcol,M_,ys,caller_string) % []=display_problematic_vars_Jacobian(problemrow,problemcol,M_,x,caller_string)
% print the equation numbers and variables associated with problematic entries % print the equation numbers and variables associated with problematic entries
% of the Jacobian % of the Jacobian
% %
...@@ -16,7 +16,7 @@ function []=display_problematic_vars_Jacobian(problemrow,problemcol,M_,x,type,ca ...@@ -16,7 +16,7 @@ function []=display_problematic_vars_Jacobian(problemrow,problemcol,M_,x,type,ca
% none. % none.
% %
% Copyright (C) 2014-2018 Dynare Team % Copyright (C) 2014-2021 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
...@@ -37,7 +37,7 @@ skipline(); ...@@ -37,7 +37,7 @@ skipline();
if nargin<6 if nargin<6
caller_string=''; caller_string='';
end end
aux_eq_nbr=M_.eq_nbr-M_.orig_eq_nbr; initial_aux_eq_nbr=M_.ramsey_eq_nbr;
if strcmp(type,'dynamic') if strcmp(type,'dynamic')
for ii=1:length(problemrow) for ii=1:length(problemrow)
if problemcol(ii)>max(M_.lead_lag_incidence) if problemcol(ii)>max(M_.lead_lag_incidence)
...@@ -54,46 +54,46 @@ if strcmp(type,'dynamic') ...@@ -54,46 +54,46 @@ if strcmp(type,'dynamic')
type_string='lead of'; type_string='lead of';
end end
if problemcol(ii)<=max(max(M_.lead_lag_incidence)) && var_index<=M_.orig_endo_nbr if problemcol(ii)<=max(max(M_.lead_lag_incidence)) && var_index<=M_.orig_endo_nbr
if problemrow(ii)<=aux_eq_nbr if problemrow(ii)<=initial_aux_eq_nbr
eq_nbr = problemrow(ii); eq_nbr = problemrow(ii);
fprintf('Derivative of Auxiliary Equation %d with respect to %s Variable %s (initial value of %s: %g) \n', ... 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)); eq_nbr, type_string, M_.endo_names{var_index}, M_.endo_names{var_index}, x(var_index));
else else
eq_nbr = problemrow(ii)-aux_eq_nbr; eq_nbr = problemrow(ii)-initial_aux_eq_nbr;
fprintf('Derivative of Equation %d with respect to %s Variable %s (initial value of %s: %g) \n', ... 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)); eq_nbr, type_string, M_.endo_names{var_index}, M_.endo_names{var_index}, x(var_index));
end end
elseif problemcol(ii)<=max(max(M_.lead_lag_incidence)) && var_index>M_.orig_endo_nbr % auxiliary vars 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 if M_.aux_vars(1,problemcol(ii)-M_.orig_endo_nbr).type==6 %Ramsey Lagrange Multiplier
if problemrow(ii)<=aux_eq_nbr if problemrow(ii)<=initial_aux_eq_nbr
eq_nbr = problemrow(ii); eq_nbr = problemrow(ii);
fprintf('Derivative of Auxiliary Equation %d with respect to %s of Langrange multiplier of equation %s (initial value: %g) \n', ... 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))); eq_nbr, type_string, M_.aux_vars(1,problemcol(ii)-M_.orig_endo_nbr).eq_nbr, x(problemcol(ii)));
else else
eq_nbr = problemrow(ii)-aux_eq_nbr; eq_nbr = problemrow(ii)-initial_aux_eq_nbr;
fprintf('Derivative of Equation %d with respect to %s of Langrange multiplier of equation %s (initial value: %g) \n', ... 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))); eq_nbr, type_string, M_.aux_vars(1,problemcol(ii)-M_.orig_endo_nbr).eq_nbr, x(problemcol(ii)));
end end
else else
if problemrow(ii)<=aux_eq_nbr if problemrow(ii)<=initial_aux_eq_nbr
eq_nbr = problemrow(ii); eq_nbr = problemrow(ii);
orig_var_index = M_.aux_vars(1,var_index-M_.orig_endo_nbr).orig_index; 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', ... 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)); eq_nbr, type_string, M_.endo_names{orig_var_index}, M_.endo_names{orig_var_index}, x(orig_var_index));
else else
eq_nbr = problemrow(ii)-aux_eq_nbr; eq_nbr = problemrow(ii)-initial_aux_eq_nbr;
orig_var_index = M_.aux_vars(1,var_index-M_.orig_endo_nbr).orig_index; 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', ... 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)); eq_nbr, type_string, M_.endo_names{orig_var_index}, M_.endo_names{orig_var_index}, x(orig_var_index));
end end
end end
elseif problemcol(ii)>max(max(M_.lead_lag_incidence)) && var_index<=M_.exo_nbr elseif problemcol(ii)>max(max(M_.lead_lag_incidence)) && var_index<=M_.exo_nbr
if problemrow(ii)<=aux_eq_nbr if problemrow(ii)<=initial_aux_eq_nbr
eq_nbr = problemrow(ii); eq_nbr = problemrow(ii);
fprintf('Derivative of Auxiliary Equation %d with respect to %s shock %s \n', ... fprintf('Derivative of Auxiliary Equation %d with respect to %s shock %s \n', ...
eq_nbr, type_string, M_.exo_names{var_index}); eq_nbr, type_string, M_.exo_names{var_index});
else else
eq_nbr = problemrow(ii)-aux_eq_nbr; eq_nbr = problemrow(ii)-initial_aux_eq_nbr;
fprintf('Derivative of Equation %d with respect to %s shock %s \n', ... fprintf('Derivative of Equation %d with respect to %s shock %s \n', ...
eq_nbr, type_string, M_.exo_names{var_index}); eq_nbr, type_string, M_.exo_names{var_index});
end end
...@@ -102,40 +102,40 @@ if strcmp(type,'dynamic') ...@@ -102,40 +102,40 @@ if strcmp(type,'dynamic')
end end
end end
fprintf('\n%s The problem most often occurs, because a variable with\n', caller_string) 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 exponent smaller than 0 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 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) fprintf('%s If you are using model-local variables (# operator), check their values as well.\n', caller_string)
elseif strcmp(type, 'static') elseif strcmp(type, 'static')
for ii=1:length(problemrow) for ii=1:length(problemrow)
if problemcol(ii)<=M_.orig_endo_nbr if problemcol(ii)<=M_.orig_endo_nbr
if problemrow(ii)<=aux_eq_nbr if problemrow(ii)<=initial_aux_eq_nbr
eq_nbr = problemrow(ii); eq_nbr = problemrow(ii);
fprintf('Derivative of Auxiliary Equation %d with respect to Variable %s (initial value of %s: %g) \n', ... fprintf('Derivative of Auxiliary Equation %d with respect to Variable %s (initial value of %s: %g) \n', ...
eq_nbr, M_.endo_names{problemcol(ii)}, M_.endo_names{problemcol(ii)}, x(problemcol(ii))); eq_nbr, M_.endo_names{problemcol(ii)}, M_.endo_names{problemcol(ii)}, x(problemcol(ii)));
else else
eq_nbr = problemrow(ii)-aux_eq_nbr; eq_nbr = problemrow(ii)-initial_aux_eq_nbr;
fprintf('Derivative of Equation %d with respect to Variable %s (initial value of %s: %g) \n', ... fprintf('Derivative of Equation %d with respect to Variable %s (initial value of %s: %g) \n', ...
eq_nbr, M_.endo_names{problemcol(ii)}, M_.endo_names{problemcol(ii)}, x(problemcol(ii))); eq_nbr, M_.endo_names{problemcol(ii)}, M_.endo_names{problemcol(ii)}, x(problemcol(ii)));
end end
else %auxiliary vars else %auxiliary vars
if M_.aux_vars(1,problemcol(ii)-M_.orig_endo_nbr).type ==6 %Ramsey Lagrange Multiplier if M_.aux_vars(1,problemcol(ii)-M_.orig_endo_nbr).type ==6 %Ramsey Lagrange Multiplier
if problemrow(ii)<=aux_eq_nbr if problemrow(ii)<=initial_aux_eq_nbr
eq_nbr = problemrow(ii); eq_nbr = problemrow(ii);
fprintf('Derivative of Auxiliary Equation %d with respect to Lagrange multiplier of equation %d (initial value: %g) \n', ... 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))); eq_nbr, M_.aux_vars(1,problemcol(ii)-M_.orig_endo_nbr).eq_nbr, x(problemcol(ii)));
else else
eq_nbr = problemrow(ii)-aux_eq_nbr; eq_nbr = problemrow(ii)-initial_aux_eq_nbr;
fprintf('Derivative of Equation %d with respect to Lagrange multiplier of equation %d (initial value: %g) \n', ... 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))); eq_nbr, M_.aux_vars(1,problemcol(ii)-M_.orig_endo_nbr).eq_nbr, x(problemcol(ii)));
end end
else else
if problemrow(ii)<=aux_eq_nbr if problemrow(ii)<=initial_aux_eq_nbr
eq_nbr = problemrow(ii); eq_nbr = problemrow(ii);
orig_var_index = M_.aux_vars(1,problemcol(ii)-M_.orig_endo_nbr).orig_index; 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', ... 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))); eq_nbr, M_.endo_names{orig_var_index}, M_.endo_names{orig_var_index}, x(problemcol(ii)));
else else
eq_nbr = problemrow(ii)-aux_eq_nbr; eq_nbr = problemrow(ii)-initial_aux_eq_nbr;
orig_var_index = M_.aux_vars(1,problemcol(ii)-M_.orig_endo_nbr).orig_index; 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', ... 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))); eq_nbr, M_.endo_names{orig_var_index}, M_.endo_names{orig_var_index}, x(problemcol(ii)));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment