model_diagnostics.m: allow setting tolerance for singularity checks starting with Matlab 2022a
parent
f21577bf39
commit
253c87b894
|
@ -42,6 +42,7 @@ options_.timing = 0;
|
|||
options_.gstep = ones(2,1);
|
||||
options_.gstep(1) = 1e-2;
|
||||
options_.gstep(2) = 1.0;
|
||||
options_.jacobian_tolerance = []; %tolerance for rank of Jacobian in model_diagnostics
|
||||
options_.scalv = 1;
|
||||
options_.debug = false;
|
||||
options_.initval_file = false;
|
||||
|
|
|
@ -33,8 +33,6 @@ function model_diagnostics(M,options,oo)
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
global jacob
|
||||
|
||||
endo_nbr = M.endo_nbr;
|
||||
endo_names = M.endo_names;
|
||||
lead_lag_incidence = M.lead_lag_incidence;
|
||||
|
@ -174,7 +172,11 @@ for b=1:nb
|
|||
display_problematic_vars_Jacobian(imagrow,imagcol,M,dr.ys,'static','MODEL_DIAGNOSTICS: ')
|
||||
end
|
||||
try
|
||||
rank_jacob = rank(jacob); %can sometimes fail
|
||||
if isoctave || matlab_ver_less_than('9.12') || isempty(options_.jacobian_tolerance)
|
||||
rank_jacob = rank(jacob); %can sometimes fail
|
||||
else
|
||||
rank_jacob = rank(jacob,options_.jacobian_tolerance); %can sometimes fail
|
||||
end
|
||||
catch
|
||||
rank_jacob=size(jacob,1);
|
||||
end
|
||||
|
@ -185,7 +187,11 @@ for b=1:nb
|
|||
'singular'])
|
||||
disp(['MODEL_DIAGNOSTICS: there is ' num2str(endo_nbr-rank_jacob) ...
|
||||
' colinear relationships between the variables and the equations'])
|
||||
ncol = null(jacob);
|
||||
if isoctave || matlab_ver_less_than('9.12') || isempty(options_.jacobian_tolerance)
|
||||
ncol = null(jacob);
|
||||
else
|
||||
ncol = null(jacob,options_.jacobian_tolerance); %can sometimes fail
|
||||
end
|
||||
n_rel = size(ncol,2);
|
||||
for i = 1:n_rel
|
||||
if n_rel > 1
|
||||
|
@ -200,7 +206,11 @@ for b=1:nb
|
|||
end
|
||||
fprintf('%s\n',endo_names{k})
|
||||
end
|
||||
neq = null(jacob');
|
||||
if isoctave || matlab_ver_less_than('9.12') || isempty(options_.jacobian_tolerance)
|
||||
neq = null(jacob'); %can sometimes fail
|
||||
else
|
||||
neq = null(jacob',options_.jacobian_tolerance); %can sometimes fail
|
||||
end
|
||||
n_rel = size(neq,2);
|
||||
for i = 1:n_rel
|
||||
if n_rel > 1
|
||||
|
|
Loading…
Reference in New Issue