2021-06-22 14:28:46 +02:00
|
|
|
function [dr, info, M, oo] = resol(check_flag, M, options, oo)
|
2011-09-17 12:33:07 +02:00
|
|
|
|
2018-05-05 21:58:52 +02:00
|
|
|
% Computes the perturbation based decision rules of the DSGE model (orders 1 to 3)
|
|
|
|
%
|
|
|
|
% INPUTS
|
|
|
|
% - check_flag [integer] scalar, equal to 0 if all the approximation is required, equal to 1 if only the eigenvalues are to be computed.
|
|
|
|
% - M [structure] Matlab's structure describing the model (M_).
|
|
|
|
% - options [structure] Matlab's structure describing the current options (options_).
|
|
|
|
% - oo [structure] Matlab's structure containing the results (oo_).
|
|
|
|
%
|
|
|
|
% OUTPUTS
|
|
|
|
% - dr [structure] Reduced form model.
|
|
|
|
% - info [integer] scalar or vector, error code.
|
|
|
|
% - M [structure] Matlab's structure describing the model (M_).
|
|
|
|
% - oo [structure] Matlab's structure containing the results (oo_).
|
|
|
|
%
|
|
|
|
% REMARKS
|
|
|
|
% Possible values for the error codes are:
|
|
|
|
%
|
|
|
|
% info(1)=0 -> No error.
|
|
|
|
% info(1)=1 -> The model doesn't determine the current variables uniquely.
|
|
|
|
% info(1)=2 -> MJDGGES returned an error code.
|
|
|
|
% info(1)=3 -> Blanchard & Kahn conditions are not satisfied: no stable equilibrium.
|
|
|
|
% info(1)=4 -> Blanchard & Kahn conditions are not satisfied: indeterminacy.
|
|
|
|
% info(1)=5 -> Blanchard & Kahn conditions are not satisfied: indeterminacy due to rank failure.
|
|
|
|
% info(1)=6 -> The jacobian evaluated at the deterministic steady state is complex.
|
|
|
|
% info(1)=19 -> The steadystate routine has thrown an exception (inconsistent deep parameters).
|
|
|
|
% info(1)=20 -> Cannot find the steady state, info(2) contains the sum of square residuals (of the static equations).
|
|
|
|
% info(1)=21 -> The steady state is complex, info(2) contains the sum of square of imaginary parts of the steady state.
|
|
|
|
% info(1)=22 -> The steady has NaNs.
|
|
|
|
% info(1)=23 -> M_.params has been updated in the steadystate routine and has complex valued scalars.
|
|
|
|
% info(1)=24 -> M_.params has been updated in the steadystate routine and has some NaNs.
|
|
|
|
% info(1)=30 -> Ergodic variance can't be computed.
|
2008-08-01 14:40:33 +02:00
|
|
|
|
2022-04-13 13:15:19 +02:00
|
|
|
% Copyright © 2001-2018 Dynare Team
|
2008-08-01 14:40:33 +02: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/>.
|
2008-01-03 13:00:54 +01:00
|
|
|
|
2017-05-16 12:42:01 +02:00
|
|
|
if isfield(oo,'dr')
|
2021-01-28 21:41:05 +01:00
|
|
|
if isfield(oo.dr,'kstate')
|
|
|
|
dr.kstate = oo.dr.kstate;
|
|
|
|
end
|
|
|
|
if isfield(oo.dr,'inv_order_var')
|
|
|
|
dr.inv_order_var = oo.dr.inv_order_var;
|
|
|
|
end
|
|
|
|
if isfield(oo.dr,'order_var')
|
|
|
|
dr.order_var = oo.dr.order_var;
|
|
|
|
end
|
|
|
|
if isfield(oo.dr,'restrict_var_list')
|
|
|
|
dr.restrict_var_list = oo.dr.restrict_var_list;
|
|
|
|
end
|
|
|
|
if isfield(oo.dr,'restrict_columns')
|
|
|
|
dr.restrict_columns = oo.dr.restrict_columns;
|
|
|
|
end
|
|
|
|
if isfield(oo.dr,'obs_var')
|
|
|
|
dr.obs_var = oo.dr.obs_var;
|
|
|
|
end
|
2011-01-26 14:07:40 +01:00
|
|
|
end
|
2005-02-18 20:54:39 +01:00
|
|
|
|
2011-09-17 12:33:07 +02:00
|
|
|
if M.exo_nbr == 0
|
|
|
|
oo.exo_steady_state = [] ;
|
2005-02-18 20:54:39 +01:00
|
|
|
end
|
|
|
|
|
2017-04-21 10:07:54 +02:00
|
|
|
[dr.ys,M.params,info] = evaluate_steady_state(oo.steady_state,M,options,oo,~options.steadystate.nocheck);
|
2009-10-02 14:10:50 +02:00
|
|
|
|
2011-10-12 21:46:50 +02:00
|
|
|
if info(1)
|
2016-11-07 11:36:06 +01:00
|
|
|
oo.dr = dr;
|
2009-04-08 00:08:39 +02:00
|
|
|
return
|
2005-02-18 20:54:39 +01:00
|
|
|
end
|
|
|
|
|
2014-01-30 13:03:03 +01:00
|
|
|
if options.loglinear
|
2017-02-15 12:41:56 +01:00
|
|
|
threshold = 1e-16;
|
2016-05-02 13:51:51 +02:00
|
|
|
% Find variables with non positive steady state. Skip auxiliary
|
|
|
|
% variables for lagges/leaded exogenous variables
|
2017-02-15 12:41:56 +01:00
|
|
|
idx = find(dr.ys(get_all_variables_but_lagged_leaded_exogenous(M))<threshold);
|
2014-01-30 13:03:03 +01:00
|
|
|
if length(idx)
|
2014-12-04 20:04:36 +01:00
|
|
|
if options.debug
|
2017-10-10 10:05:59 +02:00
|
|
|
variables_with_non_positive_steady_state = M.endo_names{idx};
|
2014-12-04 20:04:36 +01:00
|
|
|
skipline()
|
|
|
|
fprintf('You are attempting to simulate/estimate a loglinear approximation of a model, but\n')
|
|
|
|
fprintf('the steady state level of the following variables is not strictly positive:\n')
|
|
|
|
for var_iter=1:length(idx)
|
|
|
|
fprintf(' - %s (%s)\n',deblank(variables_with_non_positive_steady_state(var_iter,:)), num2str(dr.ys(idx(var_iter))))
|
|
|
|
end
|
2017-03-16 15:00:02 +01:00
|
|
|
if isinestimationobjective()
|
2014-12-04 20:04:36 +01:00
|
|
|
fprintf('You should check that the priors and/or bounds over the deep parameters are such\n')
|
|
|
|
fprintf('that the steady state levels of all the variables are strictly positive, or consider\n')
|
|
|
|
fprintf('a linearization of the model instead of a log linearization.\n')
|
|
|
|
else
|
|
|
|
fprintf('You should check that the calibration of the deep parameters is such that the\n')
|
|
|
|
fprintf('steady state levels of all the variables are strictly positive, or consider\n')
|
|
|
|
fprintf('a linearization of the model instead of a log linearization.\n')
|
|
|
|
end
|
2014-01-30 13:03:03 +01:00
|
|
|
end
|
2014-12-04 20:04:36 +01:00
|
|
|
info(1)=26;
|
2017-02-15 12:41:56 +01:00
|
|
|
info(2)=sum(dr.ys(dr.ys<threshold).^2);
|
2014-12-04 20:04:36 +01:00
|
|
|
return
|
2014-01-30 13:03:03 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-09-17 12:33:07 +02:00
|
|
|
if options.block
|
2021-06-22 14:28:46 +02:00
|
|
|
[dr,info,M,oo] = dr_block(dr,check_flag,M,options,oo);
|
2018-05-05 16:36:50 +02:00
|
|
|
dr.edim = nnz(abs(dr.eigval) > options.qz_criterium);
|
|
|
|
dr.sdim = dr.nd-dr.edim;
|
2010-10-27 15:34:48 +02:00
|
|
|
else
|
2011-12-20 16:34:30 +01:00
|
|
|
[dr,info] = stochastic_solvers(dr,check_flag,M,options,oo);
|
2009-04-02 15:40:56 +02:00
|
|
|
end
|
2012-12-06 14:58:58 +01:00
|
|
|
oo.dr = dr;
|