dynatol.{f,x} -> simul.tol{x,f}

fix-tolerance-parameters
Stéphane Adjemian (Ryûk) 2022-05-19 09:45:21 +02:00
parent 40871519fc
commit 7a438d52fd
Signed by: stepan
GPG Key ID: 295C1FE89E17EB3C
46 changed files with 112 additions and 114 deletions

View File

@ -11838,12 +11838,12 @@ Performing identification analysis
derivatives (only at order=1)
* ``-1``: numerical two-sided finite difference method
to compute all identification Jacobians (numerical tolerance
level is equal to ``options_.dynatol.x``)
level is equal to ``options_.simul.tolx``)
* ``-2``: numerical two-sided finite difference method
to compute derivatives of steady state and dynamic
model numerically, the identification Jacobians are
then computed analytically (numerical tolerance
level is equal to ``options_.dynatol.x``)
level is equal to ``options_.simul.tolx``)
Default: ``0``.

View File

@ -109,7 +109,7 @@ for t = 1:nobs(constraints)
z = [Y(freeendogenousvariables_id,ity-1); zeros(nxfree, 1)];
% Solves for z.
[z, failed, ~, ~, errorcode] = dynare_solve(model_dtransf, z, ...
DynareOptions.simul.maxit, DynareOptions.dynatol.f, DynareOptions.dynatol.x, ...
DynareOptions.simul.maxit, DynareOptions.simul.tolf, DynareOptions.simul.tolx, ...
DynareOptions, model_dynamic, ylag, ycur, X, DynareModel.params, DynareOutput.steady_state, itx, ModelInversion);
if failed
error('Nonlinear solver failed with errorcode=%i', errorcode)

View File

@ -57,14 +57,14 @@ for it = initialconditions.nobs+(1:samplesize)
try
if ismember(DynareOptions.solve_algo, [12,14])
[DynareOutput.endo_simul(:,it), errorflag, ~, ~, errorcode] = dynare_solve(model_dynamic_s, y, ...
DynareOptions.simul.maxit, DynareOptions.dynatol.f, DynareOptions.dynatol.x, ...
DynareOptions.simul.maxit, DynareOptions.simul.tolf, DynareOptions.simul.tolx, ...
DynareOptions, ...
DynareModel.isloggedlhs, DynareModel.isauxdiffloggedrhs, DynareModel.endo_names, DynareModel.lhs, ...
model_dynamic, ylag, DynareOutput.exo_simul, DynareModel.params, DynareOutput.steady_state, it);
else
[DynareOutput.endo_simul(:,it), errorflag, ~, ~, errorcode] = ...
dynare_solve(model_dynamic_s, y, ...
DynareOptions.simul.maxit, DynareOptions.dynatol.f, DynareOptions.dynatol.x, ...
DynareOptions.simul.maxit, DynareOptions.simul.tolf, DynareOptions.simul.tolx, ...
DynareOptions, ...
model_dynamic, ylag, DynareOutput.exo_simul, DynareModel.params, DynareOutput.steady_state, it);
end

View File

@ -36,8 +36,8 @@ options_.verbosity = 1;
options_.terminal_condition = 0;
options_.rplottype = 0;
options_.smpl = 0;
options_.dynatol.f = 1e-5;
options_.dynatol.x = 1e-5;
options_.simul.tolf = 1e-5;
options_.simul.tolx = 1e-5;
options_.timing = 0;
options_.gstep = ones(2,1);
options_.gstep(1) = 1e-2;

View File

@ -71,4 +71,4 @@ if ~DynareOptions.bytecode
end
pfm.verbose = DynareOptions.ep.verbosity;
pfm.maxit_ = DynareOptions.simul.maxit;
pfm.tolerance = DynareOptions.dynatol.f;
pfm.tolerance = DynareOptions.simul.tolf;

View File

@ -143,5 +143,5 @@ Options.steady.maxit = 100;
y = repmat(steady_state,block_nbr,1);
Options.solve_algo = Options.ep.solve_algo;
Options.steady.maxit = Options.ep.maxit;
[y, errorflag, ~, ~, errorcode] = dynare_solve(@ep_problem_2, y, Options.simul.maxit, Options.dynatol.f, Options.dynatol.x, Options, exo_simul, pfm);
[y, errorflag, ~, ~, errorcode] = dynare_solve(@ep_problem_2, y, Options.simul.maxit, Options.simul.tolf, Options.simul.tolx, Options, exo_simul, pfm);
endo_simul(:,2) = y(1:ny);

View File

@ -127,5 +127,5 @@ elseif ~isempty(options.steadystate_partial)
for i = 1:nov
indv(i) = strmatch(ssvar(i), M.endo_names, 'exact');
end
ys = dynare_solve('restricted_steadystate', ys(indv), options.steady.maxit, options.dynatol.f, options.dynatol.x, options, exo_ss, indv);
ys = dynare_solve('restricted_steadystate', ys(indv), options.steady.maxit, options.simul.tolf, options.simul.tolx, options, exo_ss, indv);
end

View File

@ -31,7 +31,7 @@ ff=feval(f,x,varargin{:});
tol = eps.^(1/3); %some default value
if strcmp(func2str(f),'get_perturbation_params_derivs_numerical_objective') || strcmp(func2str(f),'identification_numerical_objective')
tol= varargin{5}.dynatol.x;
tol= varargin{5}.simul.tolx;
end
h = tol.*max(abs(x),1);
xh1=x+h; xh0=x-h;
@ -66,7 +66,7 @@ function disp_info_error_identification_perturbation(info,j)
fprintf(' -- check your mod file, calibration and steady state computations carefully\n');
fprintf(' -- use analytic derivatives, i.e. set analytic_derivation_mode=0\n');
fprintf(' -- use an estimated_params block without %s or change its value\n', probl_par);
fprintf(' -- change numerical tolerance level in fjaco.m (you can tune ''options_.dynatol.x'' or change fjaco.m function directly)\n');
fprintf(' -- change numerical tolerance level in fjaco.m (you can tune ''options_.simul.tolx'' or change fjaco.m function directly)\n');
error('fjaco.m: numerical two-sided difference method yields errors in solution algorithm');
end

View File

@ -159,10 +159,10 @@ else
end
if options_.bytecode
save_options_dynatol_f = options_.dynatol.f;
options_.dynatol.f = 1e-7;
save_options_simul.tolf = options_.simul.tolf;
options_.simul.tolf = 1e-7;
[endo, exo] = bytecode('extended_path', plan, oo_.endo_simul, oo_.exo_simul, M_.params, oo_.steady_state, options_.periods);
options_.dynatol.f = save_options_dynatol_f;
options_.simul.tolf = save_options_simul.tolf;
oo_.endo_simul = endo;
oo_.exo_simul = exo;
@ -393,8 +393,8 @@ maxit = options_.simul.maxit;
past_val = 0;
save_options_periods = options_.periods;
options_.periods = options_cond_fcst.periods;
save_options_dynatol_f = options_.dynatol.f;
options_.dynatol.f = 1e-8;
save_options_simul.tolf = options_.simul.tolf;
options_.simul.tolf = 1e-8;
eps1 = 1e-7;%1e-4;
exo = zeros(maximum_lag + options_cond_fcst.periods, nx);
endo = zeros(maximum_lag + options_cond_fcst.periods, ny);
@ -910,7 +910,7 @@ else
end
end
options_.periods = save_options_periods;
options_.dynatol.f = save_options_dynatol_f;
options_.simul.tolf = save_options_simul.tolf;
options_.initval_file = save_options_initval_file;
options_.verbosity = verbosity;
oo_.endo_simul = endo';

View File

@ -159,7 +159,7 @@ for iter = 1:options_.simul.maxit
last_line = iter;
break
end
if err < options_.dynatol.f
if err < options_.simul.tolf
stop = 1;
info.time = etime(clock,h1);
info.error = err;

View File

@ -118,7 +118,7 @@ if ~oo_.deterministic_simulation.status && ~options_.no_homotopy
fprintf('Iter. \t | Lambda \t | status \t | Max. residual\n')
fprintf('++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n')
end
while (step > options_.dynatol.x)
while (step > options_.simul.tolx)
if ~isequal(step,1)
options_.verbosity = 0;
@ -209,7 +209,7 @@ if ~isreal(oo_.endo_simul(:)) % cannot happen with bytecode or the perfect_fores
residuals = perfect_foresight_problem(yy(:), y0, yT, oo_.exo_simul, M_.params, oo_.steady_state, periods, M_, options_);
if max(abs(residuals))< options_.dynatol.f
if max(abs(residuals))< options_.simul.tolf
oo_.deterministic_simulation.status = true;
oo_.endo_simul=real(oo_.endo_simul);
else

View File

@ -90,7 +90,7 @@ for iter = 1:options.simul.maxit
end
if options.endogenous_terminal_period && iter > 1
for it = 1:periods
if max(abs(res((it-1)*ny+(1:ny)))) < options.dynatol.f/1e7
if max(abs(res((it-1)*ny+(1:ny)))) < options.simul.tolf/1e7
if it < periods
res = res(1:(it*ny));
A = A(1:(it*ny), 1:(it*ny));
@ -116,7 +116,7 @@ for iter = 1:options.simul.maxit
if verbose
fprintf('Iter: %d,\t err. = %g,\t time = %g\n', iter, err, etime(clock,h2));
end
if err < options.dynatol.f
if err < options.simul.tolf
stop = true;
break
end

View File

@ -102,7 +102,7 @@ for iter = 1:options.simul.maxit
str = sprintf('Iter: %s,\t err. = %s, \t time = %s', num2str(iter), num2str(err), num2str(etime(clock, h2)));
disp(str);
end
if err < options.dynatol.f
if err < options.simul.tolf
stop = true;
if verbose
skipline()

View File

@ -40,12 +40,12 @@ for it = M.maximum_lag + (1:options.periods)
ylag = y(iyb);
if ismember(options.solve_algo, [12,14])
[tmp, check, ~, ~, errorcode] = dynare_solve(dynamicmodel_s, y, ...
options.simul.maxit, options.dynatol.f, options.dynatol.x, ...
options.simul.maxit, options.simul.tolf, options.simul.tolx, ...
options, M.isloggedlhs, M.isauxdiffloggedrhs, M.endo_names, M.lhs, ...
dynamicmodel, ylag, exogenousvariables, M.params, steadystate, it);
else
[tmp, check, ~, ~, errorcode] = dynare_solve(dynamicmodel_s, y, ...
options.simul.maxit, options.dynatol.f, options.dynatol.x, ...
options.simul.maxit, options.simul.tolf, options.simul.tolx, ...
options, dynamicmodel, ylag, exogenousvariables, M.params, steadystate, it);
end
if check

View File

@ -34,12 +34,12 @@ for it = options.periods:-1:1
yf = endogenousvariables(:,it+1); % Values at next period, also used as guess value for current period
if ismember(options.solve_algo, [12,14])
[tmp, check, ~, ~, errorcode] = dynare_solve(dynamicmodel_s, yf, ...
options.simul.maxit, options.dynatol.f, options.dynatol.x, ...
options.simul.maxit, options.simul.tolf, options.simul.tolx, ...
options, M.isloggedlhs, M.isauxdiffloggedrhs, M.endo_names, M.lhs, ...
dynamicmodel, yf(iyf), exogenousvariables, M.params, steadystate, it);
else
[tmp, check, ~, ~, errorcode] = dynare_solve(dynamicmodel_s, yf, ...
options.simul.maxit, options.dynatol.f, options.dynatol.x, ...
options.simul.maxit, options.simul.tolf, options.simul.tolx, ...
options, ...
dynamicmodel, yf(iyf), exogenousvariables, M.params, steadystate, it);
end

View File

@ -37,12 +37,12 @@ y = endogenousvariables(:,1);
for it = 1:options.periods
if ismember(options.solve_algo, [12,14])
[tmp, check, ~, ~, errorcode] = dynare_solve(dynamicmodel_s, y, ...
options.simul.maxit, options.dynatol.f, options.dynatol.x, ...
options.simul.maxit, options.simul.tolf, options.simul.tolx, ...
options, M.isloggedlhs, M.isauxdiffloggedrhs, M.endo_names, M.lhs, ...
dynamicmodel, exogenousvariables, M.params, steadystate, it);
else
[tmp, check, ~, ~, errorcode] = dynare_solve(dynamicmodel_s, y, ...
options.simul.maxit, options.dynatol.f, options.dynatol.x, ...
options.simul.maxit, options.simul.tolf, options.simul.tolx, ...
options, dynamicmodel, exogenousvariables, M.params, steadystate, it);
end
if check

View File

@ -72,10 +72,10 @@ for blk = 1:length(M_.block_structure.block)
M_.block_structure.block(blk).Simulation_Type == 6 || ... % solveForwardComplete
M_.block_structure.block(blk).Simulation_Type == 7 % solveBackwardComplete
is_forward = M_.block_structure.block(blk).Simulation_Type == 3 || M_.block_structure.block(blk).Simulation_Type == 6;
[y, T, oo_] = solve_one_boundary(funcname, y, oo_.exo_simul, M_.params, oo_.steady_state, T, y_index, M_.block_structure.block(blk).NNZDerivatives, options_.periods, M_.block_structure.block(blk).is_linear, blk, M_.maximum_lag, options_.simul.maxit, options_.dynatol.f, cutoff, options_.stack_solve_algo, is_forward, true, false, M_, options_, oo_);
[y, T, oo_] = solve_one_boundary(funcname, y, oo_.exo_simul, M_.params, oo_.steady_state, T, y_index, M_.block_structure.block(blk).NNZDerivatives, options_.periods, M_.block_structure.block(blk).is_linear, blk, M_.maximum_lag, options_.simul.maxit, options_.simul.tolf, cutoff, options_.stack_solve_algo, is_forward, true, false, M_, options_, oo_);
elseif M_.block_structure.block(blk).Simulation_Type == 5 || ... % solveTwoBoundariesSimple
M_.block_structure.block(blk).Simulation_Type == 8 % solveTwoBoundariesComplete
[y, T, oo_] = solve_two_boundaries(funcname, y, oo_.exo_simul, M_.params, oo_.steady_state, T, y_index, M_.block_structure.block(blk).NNZDerivatives, options_.periods, M_.block_structure.block(blk).maximum_lag, M_.block_structure.block(blk).maximum_lead, M_.block_structure.block(blk).is_linear, blk, M_.maximum_lag, options_.simul.maxit, options_.dynatol.f, cutoff, options_.stack_solve_algo, options_, M_, oo_);
[y, T, oo_] = solve_two_boundaries(funcname, y, oo_.exo_simul, M_.params, oo_.steady_state, T, y_index, M_.block_structure.block(blk).NNZDerivatives, options_.periods, M_.block_structure.block(blk).maximum_lag, M_.block_structure.block(blk).maximum_lead, M_.block_structure.block(blk).is_linear, blk, M_.maximum_lag, options_.simul.maxit, options_.simul.tolf, cutoff, options_.stack_solve_algo, options_, M_, oo_);
end
tmp = y(M_.block_structure.block(blk).variable, :);

View File

@ -42,7 +42,7 @@ z = bsxfun(@minus, z, steadystate_y);
x = bsxfun(@minus, exogenousvariables, steadystate_x');
[y, check, ~, ~, errorcode] = dynare_solve(@linear_perfect_foresight_problem, z(:), ...
options.simul.maxit, options.dynatol.f, options.dynatol.x, ...
options.simul.maxit, options.simul.tolf, options.simul.tolx, ...
options, ...
jacobian, y0-steadystate_y, yT-steadystate_y, ...
x, M.params, steadystate_y, ...
@ -50,7 +50,7 @@ x = bsxfun(@minus, exogenousvariables, steadystate_x');
i_cols_J1, i_cols_1, i_cols_T, i_cols_j, i_cols_0, i_cols_J0, ...
jendo, jexog);
if all(imag(y)<.1*options.dynatol.x)
if all(imag(y)<.1*options.simul.tolx)
if ~isreal(y)
y = real(y);
end

View File

@ -47,7 +47,7 @@ if (options.solve_algo == 10 || options.solve_algo == 11)% mixed complementarity
options.mcppath.ub = repmat(ub,options.periods,1);
end
[y, check, ~, ~, errorcode] = dynare_solve(@perfect_foresight_mcp_problem, z(:), ...
options.simul.maxit, options.dynatol.f, options.dynatol.x, ...
options.simul.maxit, options.simul.tolf, options.simul.tolx, ...
options, ...
dynamicmodel, y0, yT, ...
exogenousvariables, M.params, steadystate, ...
@ -56,11 +56,11 @@ if (options.solve_algo == 10 || options.solve_algo == 11)% mixed complementarity
eq_index);
else
[y, check, ~, ~, errorcode] = dynare_solve(@perfect_foresight_problem, z(:), ...
options.simul.maxit, options.dynatol.f, options.dynatol.x, ...
options.simul.maxit, options.simul.tolf, options.simul.tolx, ...
options, y0, yT, exogenousvariables, M.params, steadystate, options.periods, M, options);
end
if all(imag(y)<.1*options.dynatol.x)
if all(imag(y)<.1*options.simul.tolx)
if ~isreal(y)
y = real(y);
end

View File

@ -88,7 +88,7 @@ staticmodel = str2fun(sprintf('%s.static', M_.fname));
% Simulations (call a Newton-like algorithm for each period).
for t=1:samplesize
y = zeros(M_.endo_nbr, 1);
[oo_.endo_simul(:,t), errorflag, ~, ~, errorcode] = dynare_solve(staticmodel, y, options_.simul.maxit, options_.dynatol.f, options_.dynatol.x, options_, oo_.exo_simul(t,:), M_.params);
[oo_.endo_simul(:,t), errorflag, ~, ~, errorcode] = dynare_solve(staticmodel, y, options_.simul.maxit, options_.simul.tolf, options_.simul.tolx, options_, oo_.exo_simul(t,:), M_.params);
if errorflag
dprintf('simul_static_mode: Nonlinear solver failed with errorcode=%i in period %i.', errorcode, t)
oo_.endo_simul(:,t) = nan;

View File

@ -103,7 +103,7 @@ for t = 1:nobs(constraints)
% values) and the free exogenous variables (initialized with 0).
z = [Y(freeendogenousvariables_id,ity); zeros(nxfree, 1)];
% Solves for z.
[z, errorflag, ~, ~, errorcode] = dynare_solve(model_stransf, z, DynareOptions.simul.maxit, DynareOptions.dynatol.f, DynareOptions.dynatol.x, ...
[z, errorflag, ~, ~, errorcode] = dynare_solve(model_stransf, z, DynareOptions.simul.maxit, DynareOptions.simul.tolf, DynareOptions.simul.tolx, ...
DynareOptions, model_dynamic, ycur, X(itx, :), DynareModel.params, ModelInversion);
if errorflag
error('Enable to solve the system of equations (with error code %i).', errorcode)

@ -1 +1 @@
Subproject commit 3e942505829b911aacb96f7eabe2e954303826b7
Subproject commit 462dceec4632edb5757e5b08bdd851b8092585ff

View File

@ -133,13 +133,13 @@ indpstderr = estim_params_.var_exo(:,1);
indpcorr = estim_params_.corrx(:,1:2);
[I,~] = find(M_.lead_lag_incidence');
%% Parameter derivatives of perturbation
%% Parameter derivatives of perturbation
@#if CREATE_SYMBOLIC == 1
syms Y_ Y0 Yp C_ C0 Cp K_ K0 Kp A_ A0 Ap X_ X0 Xp W_ W0 Wp Z_ Z0 Zp;
syms epsA0 epsX0 epsY0;
syms RHO_AX SE_A SE_X SE_Y ALPH BETTA RHOA SIGA SIGX XSS DUMA DUMK DUMEPSA DUMEPSX;
syms sig;
SYM.corr_params = [RHO_AX];
SYM.stderr_params_decl = [SE_A SE_X SE_Y];
SYM.modparams_decl = [ALPH BETTA RHOA SIGA SIGX XSS DUMA DUMK DUMEPSA DUMEPSX];
@ -341,7 +341,7 @@ indpcorr = estim_params_.corrx(:,1:2);
save('nBrockMirmanSYM.mat','nSYMprior')
elseif jj==2
nSYMcalib = nSYM;
save('nBrockMirmanSYM.mat','nSYMcalib','-append')
save('nBrockMirmanSYM.mat','nSYMcalib','-append')
end
end
@#endif
@ -397,7 +397,7 @@ tol_dvars.d2KalmanA = [1e-3 1e-3 1e-13 1e-13];
tol_dvars.d2Om = [1e-3 1e-3 1e-13 1e-13];
tol_dvars.d2Yss = [1e-3 1e-3 1e-13 1e-13];
options_.dynatol.x = eps.^(1/3); %set numerical differentiation step in fjaco.m
options_.simul.tolx = eps.^(1/3); %set numerical differentiation step in fjaco.m
for jj = 1:2
lst_vars = {'Yss', 'Sigma_e', 'Correlation_matrix','g1','ghx','ghu'};
@ -408,7 +408,7 @@ for jj = 1:2
lst_vars = [lst_vars, 'g3','ghxxx','ghxxu','ghxuu','ghuuu','ghxss','ghuss'];
@#endif
lst_dvars = {'dYss','dSigma_e','dg1','dghx','dghu'};
@#if ORDER > 1
@#if ORDER > 1
lst_dvars = [lst_dvars, 'dg2','dghxx','dghxu','dghuu','dghs2'];
@#endif
@#if ORDER > 2
@ -425,7 +425,7 @@ for jj = 1:2
nSYM = nSYMcalib;
xparam1_calib = [];
for j = 1:length(indpstderr)
xparam1_calib = [xparam1_calib; sqrt(calib_Sigma_e(j,j))];
xparam1_calib = [xparam1_calib; sqrt(calib_Sigma_e(j,j))];
end
for j = 1:size(indpcorr,1)
xparam1_calib = [xparam1_calib; calib_Sigma_e(indpcorr(j,1),indpcorr(j,2))/( sqrt(calib_Sigma_e(indpcorr(j,1),indpcorr(j,1))) * sqrt(calib_Sigma_e(indpcorr(j,2),indpcorr(j,2))) )];
@ -448,18 +448,18 @@ for jj = 1:2
fprintf('Max absolute deviation for %s: %e\n', lst_vars{id_var}, dx);
if dx > tol_vars.(sprintf('%s',lst_vars{id_var}))
error('Something wrong in steady state computation, solution algorithm or preprocessor')
end
end
end
for d2flag = [0 1];
if d2flag
lst_dvars = [lst_dvars {'d2KalmanA', 'd2Om', 'd2Yss'}];
end
KRONFLAG = [-1 -2 0 1];
end
KRONFLAG = [-1 -2 0 1];
for id_kronflag = 1:length(KRONFLAG)
fprintf('***** %s: d2flag=%d and kronflag=%d *****\n',strparamset, d2flag,KRONFLAG(id_kronflag))
options_.analytic_derivation_mode = KRONFLAG(id_kronflag);
options_.analytic_derivation_mode = KRONFLAG(id_kronflag);
DERIVS = get_perturbation_params_derivs(M_, options_, estim_params_, oo_, indpmodel, indpstderr, indpcorr, d2flag);
for id_var = 1:size(lst_dvars,2)
dx = norm( vec(nSYM.(sprintf('%s',lst_dvars{id_var}))) - vec(DERIVS.(sprintf('%s',lst_dvars{id_var}))), Inf);

View File

@ -59,10 +59,10 @@ k=k+0.000001;
end;
options_.dynatol.f=1e-12;
options_.simul.tolf=1e-12;
steady(solve_algo=2,maxit=50);
options_.dynatol.f=4e-5;
options_.simul.tolf=4e-5;
shocks;
var e;

View File

@ -7,6 +7,6 @@
mfs0=load(['lola_solve_one_boundary' filesep 'Output' filesep 'lola_solve_one_boundary_results']);
if max(max(oo_.endo_simul-mfs0.oo_.endo_simul)) > options_.dynatol.x
error('Inconsistency with mfs=0')
if max(max(oo_.endo_simul-mfs0.oo_.endo_simul)) > options_.simul.tolx
error('Inconsistency with mfs=0')
end

View File

@ -7,6 +7,6 @@
mfs0=load(['lola_solve_one_boundary' filesep 'Output' filesep 'lola_solve_one_boundary_results']);
if max(max(oo_.endo_simul-mfs0.oo_.endo_simul)) > 20*options_.dynatol.x
error('Inconsistency with mfs=0')
if max(max(oo_.endo_simul-mfs0.oo_.endo_simul)) > 20*options_.simul.tolx
error('Inconsistency with mfs=0')
end

View File

@ -7,6 +7,6 @@
mfs0=load(['lola_solve_one_boundary' filesep 'Output' filesep 'lola_solve_one_boundary_results']);
if max(max(oo_.endo_simul-mfs0.oo_.endo_simul)) > options_.dynatol.x
error('Inconsistency with mfs=0')
if max(max(oo_.endo_simul-mfs0.oo_.endo_simul)) > options_.simul.tolx
error('Inconsistency with mfs=0')
end

View File

@ -51,7 +51,7 @@ steady_state_model;
q = 1 - d;
e = 1;
gp_obs = m/dA;
gy_obs = dA;
end;
@ -62,7 +62,7 @@ f = dseries(kron([oo_.steady_state; oo_.exo_steady_state],ones(1,34))',2012Q3:20
f_r = f;
frng = 2015Q3:2016Q4;
frng = 2015Q3:2016Q4;
disp('computing the conditional forecast');
@ -89,6 +89,4 @@ f_r = det_cond_forecast(fplan_r, f_r, frng);
e_r = f_r(frng(1:5)).data(:,1:M_.orig_endo_nbr) - f(frng(1:5)).data(:,1:M_.orig_endo_nbr);
assert(max(max(abs(e_r))) < options_.dynatol.f,'Error in conditional forecats');
assert(max(max(abs(e_r))) < options_.simul.tolf,'Error in conditional forecats');

View File

@ -90,8 +90,8 @@ oo6 = oo_;
maxabsdiff = max(max(abs(oo0.endo_simul-oo6.endo_simul)));
if max(max(abs(oo0.endo_simul-oo6.endo_simul)))>options_.dynatol.x
error('stack_solve_algo={0,6} return different paths for the endogenous variables!')
if max(max(abs(oo0.endo_simul-oo6.endo_simul)))>options_.simul.tolx
error('stack_solve_algo={0,6} return different paths for the endogenous variables!')
else
skipline()
fprintf('Maximum (absolute) differrence between paths is %s', num2str(maxabsdiff))

View File

@ -127,6 +127,6 @@ if ~oo_.deterministic_simulation.status
error('Perfect foresight simulation failed')
end
if max(abs(endo_simul_0(:)-endo_simul_1(:)))>.01*options_.dynatol.f
error('Something is wrong!')
if max(abs(endo_simul_0(:)-endo_simul_1(:)))>.01*options_.simul.tolf
error('Something is wrong!')
end

View File

@ -99,6 +99,6 @@ end
% For the 2nd simulation, since the guess values are different, there are some
% numerical differences
if max(max(abs(pfwee2-oo_.endo_simul))) > 10*options_.dynatol.f
error('Error in perfect_foresight_with_expectation_errors + terminal_steady_state_as_guess_value')
if max(max(abs(pfwee2-oo_.endo_simul))) > 10*options_.simul.tolf
error('Error in perfect_foresight_with_expectation_errors + terminal_steady_state_as_guess_value')
end

View File

@ -98,6 +98,6 @@ end
% For the 2nd simulation, since the guess values are different, there are some
% numerical differences
if max(max(abs(pfwee2-oo_.endo_simul))) > 40*options_.dynatol.f
if max(max(abs(pfwee2-oo_.endo_simul))) > 40*options_.simul.tolf
error('Error in perfect_foresight_with_expectation_errors + terminal_steady_state_as_guess_value')
end

View File

@ -143,6 +143,6 @@ end
% For the 2nd simulation, since the guess values are different, there are some
% numerical differences
if max(max(abs(pfwee2-oo_.endo_simul))) > 10*options_.dynatol.f
error('Error in perfect_foresight_with_expectation_errors + terminal_steady_state_as_guess_value')
if max(max(abs(pfwee2-oo_.endo_simul))) > 10*options_.simul.tolf
error('Error in perfect_foresight_with_expectation_errors + terminal_steady_state_as_guess_value')
end

View File

@ -31,6 +31,6 @@ if ~oo_.deterministic_simulation.status
error('Perfect foresight simulation failed')
end
if max(abs(y-[1; exp(cumprod([1; rho*ones(9, 1)]))]))>options_.dynatol.x
error('Wrong solution!')
if max(abs(y-[1; exp(cumprod([1; rho*ones(9, 1)]))]))>options_.simul.tolx
error('Wrong solution!')
end

View File

@ -32,6 +32,6 @@ expected_y = ones(1, 6);
expected_y(2) = exp(-1);
expected_y(1) = sqrt(exp(-1))*exp(1);
if max(abs(oo_.endo_simul-expected_y))>options_.dynatol.x
error('Wrong solution!')
if max(abs(oo_.endo_simul-expected_y))>options_.simul.tolx
error('Wrong solution!')
end

View File

@ -73,8 +73,8 @@ else
end
% Compare the paths returned by sim1_purely_forward routine and the analytical solution.
if max(abs(oo_.endo_simul(1,:)-expected_y))>options_.dynatol.x || ...
max(abs(oo_.endo_simul(2,:)-expected_i))>options_.dynatol.x || ...
max(abs(oo_.endo_simul(3,:)-expected_pi))>options_.dynatol.x
error('Wrong solution!')
if max(abs(oo_.endo_simul(1,:)-expected_y))>options_.simul.tolx || ...
max(abs(oo_.endo_simul(2,:)-expected_i))>options_.dynatsimul.tolx..
max(abs(oo_.endo_simul(3,:)-expected_pi))>options_.simul.tolx
error('Wrong solution!')
end

View File

@ -86,9 +86,9 @@ D = load(['rbc_det' filesep 'Output' filesep 'rbc_det_results']);
if norm(D.oo_.endo_simul - oo_.endo_simul) > 1e-30;
disp(norm(D.oo_.endo_simul - oo_.endo_simul));
error('rbc_det_stack_solve_algo_7 failed');
end;
end;
options_.dynatol.f=1e-10;
options_.simul.tolf=1e-10;
@#define J = [0,1,2,3,4,9,10]
@#for solve_algo_iter in J
@ -107,10 +107,10 @@ if isoctave && options_.solve_algo==0
%%acount for somehow weaker convergence criterion in Octave's fsolve
tol_crit=1e-4;
else
tol_crit=1e-8;
tol_crit=1e-8;
end
if norm(D.oo_.endo_simul - oo_.endo_simul) > tol_crit;
disp(norm(D.oo_.endo_simul - oo_.endo_simul));
error(sprintf('rbc_det_stack_solve_algo_7 failed with solve_algo=%u',options_.solve_algo));
end;
@#endfor
@#endfor

View File

@ -86,9 +86,9 @@ D = load(['rbc_det' filesep 'Output' filesep 'rbc_det_results']);
if norm(D.oo_.endo_simul(1:D.M_.orig_endo_nbr,D.M_.maximum_lag+1:end-D.M_.maximum_lead) - oo_.endo_simul(1:M_.orig_endo_nbr,M_.maximum_lag+1:end-M_.maximum_lead)) > 1e-30;
disp(D.oo_.endo_simul(1:D.M_.orig_endo_nbr,D.M_.maximum_lag+1:end-D.M_.maximum_lead) - oo_.endo_simul(1:M_.orig_endo_nbr,M_.maximum_lag+1:end-M_.maximum_lead));
error('rbc_det_stack_solve_algo_7 failed');
end;
end;
options_.dynatol.f=1e-10;
options_.simul.tolf=1e-10;
@#define J = [0,1,2,3,4,9,10]
@#for solve_algo_iter in J
@ -107,7 +107,7 @@ if isoctave && options_.solve_algo==0
%%acount for somehow weaker convergence criterion in Octave's fsolve
tol_crit=1e-4;
else
tol_crit=1e-8;
tol_crit=1e-8;
end
if norm(D.oo_.endo_simul(1:D.M_.orig_endo_nbr,D.M_.maximum_lag+1:end-D.M_.maximum_lead) - oo_.endo_simul(1:M_.orig_endo_nbr,M_.maximum_lag+1:end-M_.maximum_lead)) > tol_crit;
disp(D.oo_.endo_simul(1:D.M_.orig_endo_nbr,D.M_.maximum_lag+1:end-D.M_.maximum_lead) - oo_.endo_simul(1:M_.orig_endo_nbr,M_.maximum_lag+1:end-M_.maximum_lead));

View File

@ -86,9 +86,9 @@ D = load(['rbc_det' filesep 'Output' filesep 'rbc_det_results']);
if norm(D.oo_.endo_simul(1:D.M_.orig_endo_nbr,D.M_.maximum_lag+1:end-D.M_.maximum_lead) - oo_.endo_simul(1:M_.orig_endo_nbr,M_.maximum_lag+1:end-M_.maximum_lead)) > 1e-30;
disp(D.oo_.endo_simul(1:D.M_.orig_endo_nbr,D.M_.maximum_lag+1:end-D.M_.maximum_lead) - oo_.endo_simul(1:M_.orig_endo_nbr,M_.maximum_lag+1:end-M_.maximum_lead));
error('rbc_det_stack_solve_algo_7 failed');
end;
end;
options_.dynatol.f=1e-10;
options_.simul.tolf=1e-10;
@#define J = [0,1,2,3,4,9,10]
@#for solve_algo_iter in J
@ -107,7 +107,7 @@ if isoctave && options_.solve_algo==0
%%acount for somehow weaker convergence criterion in Octave's fsolve
tol_crit=1e-4;
else
tol_crit=1e-8;
tol_crit=1e-8;
end
if norm(D.oo_.endo_simul(1:D.M_.orig_endo_nbr,D.M_.maximum_lag+1:end-D.M_.maximum_lead) - oo_.endo_simul(1:M_.orig_endo_nbr,M_.maximum_lag+1:end-M_.maximum_lead)) > tol_crit;
disp(D.oo_.endo_simul(1:D.M_.orig_endo_nbr,D.M_.maximum_lag+1:end-D.M_.maximum_lead) - oo_.endo_simul(1:M_.orig_endo_nbr,M_.maximum_lag+1:end-M_.maximum_lead));

View File

@ -44,6 +44,6 @@ sts = extended_path([], 100, [], options_, M_, oo_);
// The model is backward, we do not care about future uncertainty, extended path and stochastic extended path
// should return the same results.
if max(max(abs(ts.data-sts.data)))>pi*options_.dynatol.x
disp('Stochastic Extended Path:: Something is wrong here (potential bug in extended_path.m)!!!')
if max(max(abs(ts.data-sts.data)))>pi*options_.simul.tolx
disp('Stochastic Extended Path:: Something is wrong here (potential bug in extended_path.m)!!!')
end

View File

@ -24,7 +24,7 @@
% Declare endogenous variables
% =========================================================================
var
var
% Staggered-price economy
c ${c}$ (long_name='consumption')
lam ${\lambda}$ (long_name='lagrange multiplier budget')
@ -41,10 +41,10 @@ var
a ${a}$ (long_name='auxiliary variable for nonlinear pricing 3')
ptilde ${\tilde{p}}$ (long_name='reoptimized price')
delta1 ${\Delta_1}$ (long_name='price dispersion 1')
delta2 ${\Delta_2}$ (long_name='price dispersion 2')
delta2 ${\Delta_2}$ (long_name='price dispersion 2')
delta3 ${\Delta_3}$ (long_name='price dispersion 3')
b ${b}$ (long_name='bonds')
tau ${\tau}$ (long_name='lump-sum tax')
b ${b}$ (long_name='bonds')
tau ${\tau}$ (long_name='lump-sum tax')
g
nu %consumption preference shock
@ -54,17 +54,17 @@ var
wpot ${w^{pot}}$ (long_name='flex-price real wage')
rrpot ${r^{pot}}$ (long_name='flex-price interest rate')
ypot ${y^{pot}}$ (long_name='flex-price output')
bpot ${b^{pot}}$ (long_name='flex-price bonds')
taupot ${\tau^{pot}}$ (long_name='flex-price lump-sum tax')
bpot ${b^{pot}}$ (long_name='flex-price bonds')
taupot ${\tau^{pot}}$ (long_name='flex-price lump-sum tax')
% Added variables for capital and investment
k ${k}$ (long_name='capital')
rk ${r^{K}}$ (long_name='rental rate on capital')
iv ${i}$ (long_name='investment')
q ${q}$ (long_name='Tobins Q')
q ${q}$ (long_name='Tobins Q')
kpot ${k^{pot}}$ (long_name='flex-price capital')
rkpot ${r^{K,pot}}$ (long_name='flex-price rental rate on capital')
ivpot ${i^{pot}}$ (long_name='flex-price investment')
ivpot ${i^{pot}}$ (long_name='flex-price investment')
;
% =========================================================================
@ -187,10 +187,10 @@ s = OMEGAP*lam*y*vartheta^(OMEGAP/(OMEGAP-1))*mc + BETA*XIP*(gammap/pie(+1))^(OM
[name='Nonlinear pricing 2']
f = lam*y*vartheta^(OMEGAP/(OMEGAP-1)) + BETA*XIP*(gammap/pie(+1))^(1/(1-OMEGAP))*f(+1);
[name='Nonlinear pricing 3']
a = PSI*(OMEGAP-1)*lam*y + BETA*XIP*(gammap/pie(+1))*a(+1);
[name='Nonlinear pricing 4']
s = f*ptilde -a*ptilde^(1+OMEGAP/(OMEGAP-1));
@ -372,9 +372,9 @@ check;
identification(order=1,no_identification_strength,analytic_derivation_mode= 0,ar=5); %works
%identification(no_identification_strength,analytic_derivation_mode= 1,ar=5); %works, this takes the longest due to Kronecker products
options_.dynatol.x = 1e-9;
options_.simul.tolx = 1e-9;
identification(order=1,no_identification_strength,analytic_derivation_mode=-1,ar=5); %works, but tolerance is way too small
identification(order=1,no_identification_strength,analytic_derivation_mode=-2,ar=5); %works, but tolerance is way to small
options_.dynatol.x = 1e-5; %this is the default value
options_.simul.tolx = 1e-5; %this is the default value
identification(order=1,no_identification_strength,analytic_derivation_mode=-1,ar=5); %works only if GBAR_o_YBAR is uncommented
identification(order=1,no_identification_strength,analytic_derivation_mode=-2,ar=5); %works only if GBAR_o_YBAR is uncommented

View File

@ -69,13 +69,13 @@ end;
simul(periods=1000);
newton_solution_is_wrong = abs(evaluate_max_dynamic_residual(str2func('sw_newton.dynamic'), oo_.endo_simul, oo_.exo_simul, M_.params, oo_.steady_state, 1000, size(oo_.endo_simul, 1), 1, M_.lead_lag_incidence))>options_.dynatol.f;
newton_solution_is_wrong = abs(evaluate_max_dynamic_residual(str2func('sw_newton.dynamic'), oo_.endo_simul, oo_.exo_simul, M_.params, oo_.steady_state, 1000, size(oo_.endo_simul, 1), 1, M_.lead_lag_incidence))>options_.simul.tolf;
lmmcp = load(['sw_lmmcp' filesep 'Output' filesep 'sw_lmmcp_results']);
lmmcp_solution_is_wrong = abs(evaluate_max_dynamic_residual(str2func('sw_newton.dynamic'), lmmcp.oo_.endo_simul, lmmcp.oo_.exo_simul, M_.params, oo_.steady_state, 1000, size(oo_.endo_simul, 1), 1, M_.lead_lag_incidence))>options_.dynatol.f;
lmmcp_solution_is_wrong = abs(evaluate_max_dynamic_residual(str2func('sw_newton.dynamic'), lmmcp.oo_.endo_simul, lmmcp.oo_.exo_simul, M_.params, oo_.steady_state, 1000, size(oo_.endo_simul, 1), 1, M_.lead_lag_incidence))>options_.simul.tolf;
solutions_are_different = max(max(abs(lmmcp.oo_.endo_simul-oo_.endo_simul)))>options_.dynatol.x;
solutions_are_different = max(max(abs(lmmcp.oo_.endo_simul-oo_.endo_simul)))>options_.simul.tolx;
if newton_solution_is_wrong
error('Failed to solve SW with ZLB (using Newton algorithm on stacked model)')
@ -87,4 +87,4 @@ end
if lmmcp_solution_is_wrong
error('Failed to solve SW with ZLB (using LMMCP algorithm on stacked model)!')
end
end

View File

@ -122,7 +122,7 @@ init = rand(10, M_.endo_nbr+M_.exo_nbr);
initialconditions = dseries(init, 2000Q1, vertcat(M_.endo_names,M_.exo_names));
// Simulate the model for 500 periods
options_.dynatol.f = 1e-9;
options_.simul.tolf = 1e-9;
TrueData = simul_backward_model(initialconditions, 500);
TrueData_ = copy(TrueData);

View File

@ -119,7 +119,7 @@ init = ones(10, M_.endo_nbr+M_.exo_nbr);
initialconditions = dseries(init, 2000Q1, vertcat(M_.endo_names,M_.exo_names));
// Simulate the model for 500 periods
options_.dynatol.f = 1e-9;
options_.simul.tolf = 1e-9;
TrueData = simul_backward_model(initialconditions, 5000);
TrueData_ = copy(TrueData);

View File

@ -92,7 +92,7 @@ for blockFlag = 0:1
% Test against the reference simulation path
load('test.mat','y_ref');
diff = oo_.endo_simul - y_ref;
if max(max(abs(diff))) > options_.dynatol.x
if max(max(abs(diff))) > options_.simul.tolx
failedBlock{size(failedBlock,2)+1} = ['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(storageFlag) ',' num2str(solve_algos(i)) ',' num2str(default_stack_solve_algo) ')'];
exception = MException('Dynare:simerr', 'ERROR: simulation path differs from the reference path');
printMakeCheckMatlabErrMsg(['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(storageFlag) ',' num2str(solve_algos(i)) ',' num2str(default_stack_solve_algo) ')'], exception);
@ -119,7 +119,7 @@ for blockFlag = 0:1
% Test against the reference simulation path
load('test.mat','y_ref');
diff = oo_.endo_simul - y_ref;
if max(max(abs(diff))) > options_.dynatol.x
if max(max(abs(diff))) > options_.simul.tolx
failedBlock{size(failedBlock,2)+1} = ['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(storageFlag) ',' num2str(default_solve_algo) ',' num2str(stack_solve_algos(i)) ')'];
exception = MException('Dynare:simerr', 'ERROR: simulation path difers from the reference path');
printMakeCheckMatlabErrMsg(['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(storageFlag) ',' num2str(default_solve_algo) ',' num2str(stack_solve_algos(i)) ')'], exception);

View File

@ -91,7 +91,7 @@ for blockFlag = 0:1
## Test against the reference simulation path
load('test.mat','y_ref');
diff = oo_.endo_simul - y_ref;
if max(max(abs(diff))) > options_.dynatol.x
if max(max(abs(diff))) > options_.simul.tolx
failedBlock{size(failedBlock,2)+1} = ['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(storageFlag) ',' num2str(solve_algos(i)) ',' num2str(default_stack_solve_algo) ')'];
differr.message = ["ERROR: simulation path differs from the reference path" ];
printMakeCheckOctaveErrMsg(['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(storageFlag) ',' num2str(solve_algos(i)) ',' num2str(default_stack_solve_algo) ')'], differr);
@ -116,7 +116,7 @@ for blockFlag = 0:1
## Test against the reference simulation path
load('test.mat','y_ref');
diff = oo_.endo_simul - y_ref;
if max(max(abs(diff))) > options_.dynatol.x
if max(max(abs(diff))) > options_.simul.tolx
failedBlock{size(failedBlock,2)+1} = ['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(storageFlag) ',' num2str(default_solve_algo) ',' num2str(stack_solve_algos(i)) ')'];
differr.message = ["ERROR: simulation path differs from the reference path" ];
printMakeCheckOctaveErrMsg(['block_bytecode' filesep 'run_ls2003.m(' num2str(blockFlag) ',' num2str(storageFlag) ',' num2str(default_solve_algo) ',' num2str(stack_solve_algos(i)) ')'], differr);