New option “non_zero” to the “resid” command
When this option is given, the “resid” command only displays non-zero residualstrustregion
parent
7f44a28209
commit
3d7299c1e4
|
@ -1928,6 +1928,12 @@ in this case ``initval`` is used to specify the terminal conditions.
|
|||
in the last ``initval`` or ``endval`` block (or the steady state
|
||||
file if you provided one, see :ref:`st-st`).
|
||||
|
||||
*Options*
|
||||
|
||||
.. option:: non_zero
|
||||
|
||||
Only display non-zero residuals.
|
||||
|
||||
.. command:: initval_file (OPTIONS...);
|
||||
|
||||
|br| In a deterministic setup, this command is used to specify a
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
function z = resid(junk)
|
||||
% function z = resid(junk)
|
||||
function z = resid(options_resid_)
|
||||
% function z = resid(options_resid_)
|
||||
%
|
||||
% Computes static residuals associated with the guess values.
|
||||
%
|
||||
% INPUTS
|
||||
% junk: dummy value for backward compatibility
|
||||
% options_resid_: options to resid
|
||||
%
|
||||
% OUTPUTS
|
||||
% z: residuals
|
||||
|
@ -12,7 +12,7 @@ function z = resid(junk)
|
|||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright (C) 2001-2020 Dynare Team
|
||||
% Copyright (C) 2001-2022 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -31,10 +31,7 @@ function z = resid(junk)
|
|||
|
||||
global M_ options_ oo_
|
||||
|
||||
tagname = 'name';
|
||||
if nargin && ischar(junk)
|
||||
tagname = junk;
|
||||
end
|
||||
non_zero = isfield(options_resid_, 'non_zero') && options_resid_.non_zero;
|
||||
|
||||
tags = M_.equations_tags;
|
||||
istag = 0;
|
||||
|
@ -80,24 +77,31 @@ if nargout == 0
|
|||
ind = [];
|
||||
disp('Residuals of the static equations:')
|
||||
skipline()
|
||||
any_non_zero_residual = false;
|
||||
for i=1:M_.orig_eq_nbr
|
||||
if abs(z(i+M_.ramsey_eq_nbr)) < options_.solve_tolf/100
|
||||
tmp = 0;
|
||||
else
|
||||
tmp = z(i+M_.ramsey_eq_nbr);
|
||||
any_non_zero_residual = true;
|
||||
end
|
||||
if istag
|
||||
tg = tags(cell2mat(tags(:,1)) == i,2:3); % all tags for equation i
|
||||
ind = strmatch( tagname, cellstr( tg(:,1) ) );
|
||||
ind = strmatch('name', cellstr( tg(:,1) ) );
|
||||
end
|
||||
if ~istag || length(ind) == 0
|
||||
disp(['Equation number ' int2str(i) ' : ' num2str(tmp)])
|
||||
else
|
||||
t1 = tg( ind , 2 );
|
||||
s = cell2mat(t1);
|
||||
disp( ['Equation number ', int2str(i) ,' : ', num2str(tmp) ,' : ' s])
|
||||
if ~(non_zero && tmp == 0)
|
||||
if ~istag || length(ind) == 0
|
||||
disp(['Equation number ' int2str(i) ' : ' num2str(tmp)])
|
||||
else
|
||||
t1 = tg( ind , 2 );
|
||||
s = cell2mat(t1);
|
||||
disp( ['Equation number ', int2str(i) ,' : ', num2str(tmp) ,' : ' s])
|
||||
end
|
||||
end
|
||||
end
|
||||
if non_zero && ~any_non_zero_residual
|
||||
disp('All residuals are zero')
|
||||
end
|
||||
skipline(2)
|
||||
end
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 17c5e1935d825bb815059a0bfcf67ee71a98daee
|
||||
Subproject commit 9db21a231c5ab8f8aa26680ffecf3abfcf45bfab
|
|
@ -110,7 +110,7 @@ var u_sigma_tb; stderr 1;
|
|||
var u_sigma_r; stderr 1;
|
||||
end;
|
||||
|
||||
resid(1);
|
||||
resid;
|
||||
|
||||
options_.solve_tolf=1E-12;
|
||||
steady(solve_algo=3);
|
||||
|
@ -118,4 +118,4 @@ steady(solve_algo=3);
|
|||
check;
|
||||
stoch_simul(order=3,pruning,irf=0,nofunctions,contemporaneous_correlation,TeX) C I Y H r D K lambda phi;
|
||||
|
||||
comparison_policy_functions_dynare_mathematica;
|
||||
comparison_policy_functions_dynare_mathematica;
|
||||
|
|
|
@ -22,7 +22,7 @@ x = xbar;
|
|||
y = beta*exp(theta*xbar)/(1-beta*exp(theta*xbar));
|
||||
end;
|
||||
|
||||
resid(1);
|
||||
resid;
|
||||
|
||||
steady;
|
||||
|
||||
|
|
|
@ -48,4 +48,4 @@ e = 0;
|
|||
u = 0;
|
||||
end;
|
||||
|
||||
resid('title');
|
||||
resid(non_zero);
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2001-2016 Dynare Team
|
||||
* Copyright (C) 2001-2022 Dynare Team
|
||||
*
|
||||
* This file is part of Dynare.
|
||||
*
|
||||
|
@ -56,7 +56,7 @@ k = log(11.08360443260358);
|
|||
a = 0;
|
||||
b = 0;
|
||||
end;
|
||||
resid(1);
|
||||
resid;
|
||||
shocks;
|
||||
var e; stderr 0.009;
|
||||
var u; stderr 0.009;
|
||||
|
@ -78,4 +78,4 @@ conditional_forecast(parameter_set=calibration, controlled_varexo=(u,e));
|
|||
|
||||
oo_exp=oo_;
|
||||
conditional_forecasts_exp=oo_.conditional_forecast;
|
||||
save results_exp.mat oo_exp conditional_forecasts_exp
|
||||
save results_exp.mat oo_exp conditional_forecasts_exp
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2001-2016 Dynare Team
|
||||
* Copyright (C) 2001-2022 Dynare Team
|
||||
*
|
||||
* This file is part of Dynare.
|
||||
*
|
||||
|
@ -56,7 +56,7 @@ k = log(11.08360443260358);
|
|||
a = 0;
|
||||
b = 0;
|
||||
end;
|
||||
resid(1);
|
||||
resid;
|
||||
shocks;
|
||||
var e; stderr 0.009;
|
||||
var u; stderr 0.009;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2001-2010 Dynare Team
|
||||
* Copyright (C) 2001-2022 Dynare Team
|
||||
*
|
||||
* This file is part of Dynare.
|
||||
*
|
||||
|
@ -56,7 +56,7 @@ k = 11.08360443260358;
|
|||
a = 1;
|
||||
b = 1;
|
||||
end;
|
||||
resid(1);
|
||||
resid;
|
||||
steady;
|
||||
|
||||
shocks;
|
||||
|
@ -132,4 +132,4 @@ end
|
|||
stoch_simul(loglinear,order=1,periods=100000);
|
||||
if abs(mean(y)-0.0776)>0.02
|
||||
error('Simulations are wrong')
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2001-2010 Dynare Team
|
||||
* Copyright (C) 2001-2022 Dynare Team
|
||||
*
|
||||
* This file is part of Dynare.
|
||||
*
|
||||
|
@ -57,7 +57,7 @@ a = 1;
|
|||
b = 1;
|
||||
end;
|
||||
|
||||
resid(1);
|
||||
resid;
|
||||
shocks;
|
||||
var e; stderr 0.009;
|
||||
var u; stderr 0.009;
|
||||
|
|
|
@ -78,7 +78,7 @@ mu = ((c-(chihab*c/g))^(-tau))-chihab*bet*((c*g-chihab*c)^(-tau));
|
|||
ez = 0;
|
||||
end;
|
||||
|
||||
resid(1);
|
||||
resid;
|
||||
|
||||
steady;
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ mu = (((c-(chihab*c/g))^(-tau))-chihab*bet*((c*g-chihab*c)^(-tau)))/1e4;
|
|||
ez = 0;
|
||||
end;
|
||||
|
||||
resid(1);
|
||||
resid;
|
||||
|
||||
steady;
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ mu = (((c-(chihab*c/g))^(-tau))-chihab*bet*((c*g-chihab*c)^(-tau)))/1e4;
|
|||
ez = 0;
|
||||
end;
|
||||
|
||||
resid(1);
|
||||
resid;
|
||||
|
||||
steady;
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ x = xbar;
|
|||
y = beta*exp(theta*xbar)/(1-beta*exp(theta*xbar));
|
||||
end;
|
||||
|
||||
resid(1);
|
||||
resid;
|
||||
|
||||
steady;
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ initval;
|
|||
ze_1 = log(betabar)+yk_1;
|
||||
end;
|
||||
|
||||
resid(1);
|
||||
resid;
|
||||
steady;
|
||||
model_diagnostics;
|
||||
check;
|
||||
|
|
|
@ -62,7 +62,7 @@ initval;
|
|||
ze_1 = log(betabar)+yk_1;
|
||||
end;
|
||||
|
||||
resid(1);
|
||||
resid;
|
||||
steady;
|
||||
model_diagnostics;
|
||||
check;
|
||||
|
@ -74,4 +74,4 @@ oo2 = oo_.dr;
|
|||
if any(abs(oo1.ghxx-oo2.ghxx) > 1e-14);error('ds1 with missing variable doesn''t reproduce ds2');end;
|
||||
if any(abs(oo1.ghuu-oo2.ghuu) > 1e-14);error('ds1 with missing variable doesn''t reproduce ds2');end;
|
||||
if any(abs(oo1.ghxu-oo2.ghxu) > 1e-14);error('ds1 with missing variable doesn''t reproduce ds2');end;
|
||||
if any(abs(oo1.ghs2-oo2.ghs2) > 1e-14);error('ds1 with missing variable doesn''t reproduce ds2');end;
|
||||
if any(abs(oo1.ghs2-oo2.ghs2) > 1e-14);error('ds1 with missing variable doesn''t reproduce ds2');end;
|
||||
|
|
|
@ -58,7 +58,7 @@ y=k^alpha;
|
|||
c=(1-s)*y;
|
||||
invest=y-c;
|
||||
end;
|
||||
resid(1);
|
||||
resid;
|
||||
steady;
|
||||
|
||||
simul(periods=200, solve_algo=4);
|
||||
|
|
Loading…
Reference in New Issue