Discretionary policy: preparatory work for estimation
This removes global variables from discretionary_policy_1.m, and also adapts the behaviour and interface of the function so that it is similar to resol.m (in particular, it no longer returns an empty “dr” in case of failure, and it sets “oo_.dr”). Ref. #1173time-shift
parent
929b34a168
commit
59e11615a0
|
@ -1,6 +1,8 @@
|
||||||
function [dr,ys,info]=discretionary_policy_1(oo_,Instruments)
|
function [dr, info, M_, options_, oo_]=discretionary_policy_1(Instruments, M_, options_, oo_)
|
||||||
|
% Higher-level function for solving discretionary optimal policy
|
||||||
|
% Has the same interface as resol.m
|
||||||
|
|
||||||
% Copyright (C) 2007-2018 Dynare Team
|
% Copyright (C) 2007-2020 Dynare Team
|
||||||
%
|
%
|
||||||
% This file is part of Dynare.
|
% This file is part of Dynare.
|
||||||
%
|
%
|
||||||
|
@ -17,11 +19,8 @@ function [dr,ys,info]=discretionary_policy_1(oo_,Instruments)
|
||||||
% You should have received a copy of the GNU General Public License
|
% You should have received a copy of the GNU General Public License
|
||||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
global M_ options_
|
|
||||||
persistent Hold
|
persistent Hold
|
||||||
|
|
||||||
dr = [];
|
|
||||||
ys = [];
|
|
||||||
info = 0;
|
info = 0;
|
||||||
|
|
||||||
if isempty(options_.qz_criterium)
|
if isempty(options_.qz_criterium)
|
||||||
|
@ -150,15 +149,15 @@ else
|
||||||
[H,G,info]=discretionary_policy_engine(Alag,A0,Alead,B,W,instr_id,beta,solve_maxit,discretion_tol,qz_criterium);
|
[H,G,info]=discretionary_policy_engine(Alag,A0,Alead,B,W,instr_id,beta,solve_maxit,discretion_tol,qz_criterium);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
% set the state
|
||||||
|
dr=oo_.dr;
|
||||||
|
|
||||||
if info
|
if info
|
||||||
dr=[];
|
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
Hold=H; %save previous solution
|
Hold=H; %save previous solution
|
||||||
% Hold=[]; use this line if persistent command is not used.
|
% Hold=[]; use this line if persistent command is not used.
|
||||||
end
|
end
|
||||||
% set the state
|
|
||||||
dr=oo_.dr;
|
|
||||||
dr.ys =zeros(endo_nbr,1);
|
dr.ys =zeros(endo_nbr,1);
|
||||||
dr=set_state_space(dr,M_,options_);
|
dr=set_state_space(dr,M_,options_);
|
||||||
order_var=dr.order_var;
|
order_var=dr.order_var;
|
||||||
|
@ -168,8 +167,8 @@ dr.ghu=G(order_var,:);
|
||||||
Selection=lead_lag_incidence(1,order_var)>0;%select state variables
|
Selection=lead_lag_incidence(1,order_var)>0;%select state variables
|
||||||
dr.ghx=T(:,Selection);
|
dr.ghx=T(:,Selection);
|
||||||
|
|
||||||
ys=NondistortionarySteadyState(M_);
|
dr.ys=NondistortionarySteadyState(M_);
|
||||||
dr.ys=ys; % <--- dr.ys =zeros(NewEndo_nbr,1);
|
oo_.dr = dr;
|
||||||
|
|
||||||
function ys=NondistortionarySteadyState(M_)
|
function ys=NondistortionarySteadyState(M_)
|
||||||
if exist([M_.fname,'_steadystate.m'],'file')
|
if exist([M_.fname,'_steadystate.m'],'file')
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
function [info, oo_, options_] = stoch_simul(M_, options_, oo_, var_list)
|
function [info, oo_, options_] = stoch_simul(M_, options_, oo_, var_list)
|
||||||
|
|
||||||
% Copyright (C) 2001-2019 Dynare Team
|
% Copyright (C) 2001-2020 Dynare Team
|
||||||
%
|
%
|
||||||
% This file is part of Dynare.
|
% This file is part of Dynare.
|
||||||
%
|
%
|
||||||
|
@ -82,7 +82,7 @@ elseif options_.discretionary_policy
|
||||||
if ~options_.linear
|
if ~options_.linear
|
||||||
error('discretionary_policy: only linear-quadratic problems can be solved');
|
error('discretionary_policy: only linear-quadratic problems can be solved');
|
||||||
end
|
end
|
||||||
[oo_.dr, ~, info] = discretionary_policy_1(oo_,options_.instruments);
|
[~,info,M_,options_,oo_] = discretionary_policy_1(options_.instruments,M_,options_,oo_);
|
||||||
else
|
else
|
||||||
if options_.logged_steady_state %if steady state was previously logged, undo this
|
if options_.logged_steady_state %if steady state was previously logged, undo this
|
||||||
oo_.dr.ys=exp(oo_.dr.ys);
|
oo_.dr.ys=exp(oo_.dr.ys);
|
||||||
|
|
Loading…
Reference in New Issue