correct bug when <fname>_steadystate.m file changes the value of parameters + display steady state in Ramsey policy
parent
508422307e
commit
124a6c5c12
|
@ -0,0 +1,39 @@
|
|||
function disp_steady_state(M,oo)
|
||||
% function disp_steady_state(M,oo)
|
||||
% computes and prints the steady state calculations
|
||||
%
|
||||
% INPUTS
|
||||
% M structure of parameters
|
||||
% oo structure of results
|
||||
%
|
||||
% OUTPUTS
|
||||
% none
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright (C) 2001-2010 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
disp(' ')
|
||||
disp('STEADY-STATE RESULTS:')
|
||||
disp(' ')
|
||||
endo_names = M.endo_names;
|
||||
steady_state = oo.steady_state;
|
||||
for i=1:M.orig_endo_nbr
|
||||
disp(sprintf('%s \t\t %g',endo_names(i,:),steady_state(i)));
|
||||
end
|
11
matlab/dr1.m
11
matlab/dr1.m
|
@ -95,6 +95,7 @@ if options_.ramsey_policy
|
|||
[inst_val,info1] = dynare_solve('dyn_ramsey_static_', ...
|
||||
oo_.steady_state(k_inst),0, ...
|
||||
M_,options_,oo_,it_);
|
||||
M_.params = evalin('base','M_.params;');
|
||||
ys(k_inst) = inst_val;
|
||||
[x,check] = feval([M_.fname '_steadystate'],...
|
||||
ys,[oo_.exo_steady_state; ...
|
||||
|
@ -127,6 +128,16 @@ if options_.ramsey_policy
|
|||
info(2) = check1'*check1;
|
||||
return
|
||||
end
|
||||
|
||||
if options_.noprint == 0
|
||||
disp_steady_state(M_,oo_)
|
||||
for i=M_.orig_endo_nbr:M_.endo_nbr
|
||||
if strmatch('mult_',M_.endo_names(i,:))
|
||||
disp(sprintf('%s \t\t %g',M_.endo_names(i,:), ...
|
||||
oo_.steady_state(i)));
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
[jacobia_,M_] = dyn_ramsey_dynamic_(oo_.steady_state,multbar,M_,options_,oo_,it_);
|
||||
klen = M_.maximum_lag + M_.maximum_lead + 1;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
function [resids, rJ,mult] = dyn_ramsey_static_(x,M_,options_,oo_,it_)
|
||||
function [resids, rJ,mult] = dyn_ramsey_static_(x,M,options_,oo,it_)
|
||||
|
||||
% function [resids, rJ,mult] = dyn_ramsey_static_(x)
|
||||
% Computes the static first order conditions for optimal policy
|
||||
|
@ -30,52 +30,53 @@ function [resids, rJ,mult] = dyn_ramsey_static_(x,M_,options_,oo_,it_)
|
|||
%
|
||||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
global oo_ M_
|
||||
|
||||
% recovering usefull fields
|
||||
endo_nbr = M_.endo_nbr;
|
||||
exo_nbr = M_.exo_nbr;
|
||||
fname = M_.fname;
|
||||
% inst_nbr = M_.inst_nbr;
|
||||
% i_endo_no_inst = M_.endogenous_variables_without_instruments;
|
||||
max_lead = M_.maximum_lead;
|
||||
max_lag = M_.maximum_lag;
|
||||
endo_nbr = M.endo_nbr;
|
||||
exo_nbr = M.exo_nbr;
|
||||
fname = M.fname;
|
||||
% inst_nbr = M.inst_nbr;
|
||||
% i_endo_no_inst = M.endogenous_variables_without_instruments;
|
||||
max_lead = M.maximum_lead;
|
||||
max_lag = M.maximum_lag;
|
||||
beta = options_.planner_discount;
|
||||
|
||||
% indices of all endogenous variables
|
||||
i_endo = [1:endo_nbr]';
|
||||
% indices of endogenous variable except instruments
|
||||
% i_inst = M_.instruments;
|
||||
% i_inst = M.instruments;
|
||||
% lead_lag incidence matrix for endogenous variables
|
||||
i_lag = M_.lead_lag_incidence;
|
||||
i_lag = M.lead_lag_incidence;
|
||||
|
||||
if options_.steadystate_flag
|
||||
k_inst = [];
|
||||
instruments = options_.instruments;
|
||||
for i = 1:size(instruments,1)
|
||||
k_inst = [k_inst; strmatch(options_.instruments(i,:), ...
|
||||
M_.endo_names,'exact')];
|
||||
M.endo_names,'exact')];
|
||||
end
|
||||
oo_.steady_state(k_inst) = x;
|
||||
[x,check] = feval([M_.fname '_steadystate'],...
|
||||
oo_.steady_state,...
|
||||
[oo_.exo_steady_state; ...
|
||||
oo_.exo_det_steady_state]);
|
||||
if size(x,1) < M_.endo_nbr
|
||||
if length(M_.aux_vars) > 0
|
||||
x = add_auxiliary_variables_to_steadystate(x,M_.aux_vars,...
|
||||
M_.fname,...
|
||||
oo_.exo_steady_state,...
|
||||
oo_.exo_det_steady_state,...
|
||||
oo.steady_state(k_inst) = x;
|
||||
[x,check] = feval([M.fname '_steadystate'],...
|
||||
oo.steady_state,...
|
||||
[oo.exo_steady_state; ...
|
||||
oo.exo_det_steady_state]);
|
||||
if size(x,1) < M.endo_nbr
|
||||
if length(M.aux_vars) > 0
|
||||
x = add_auxiliary_variables_to_steadystate(x,M.aux_vars,...
|
||||
M.fname,...
|
||||
oo.exo_steady_state,...
|
||||
oo.exo_det_steady_state,...
|
||||
M_.params);
|
||||
else
|
||||
error([M_.fname '_steadystate.m doesn''t match the model']);
|
||||
error([M.fname '_steadystate.m doesn''t match the model']);
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
oo_.steady_state = x;
|
||||
% value and Jacobian of objective function
|
||||
ex = zeros(1,M_.exo_nbr);
|
||||
ex = zeros(1,M.exo_nbr);
|
||||
[U,Uy,Uyy] = feval([fname '_objective_static'],x(i_endo),ex, M_.params);
|
||||
Uy = Uy';
|
||||
Uyy = reshape(Uyy,endo_nbr,endo_nbr);
|
||||
|
@ -85,7 +86,7 @@ y = repmat(x(i_endo),1,max_lag+max_lead+1);
|
|||
k = find(i_lag');
|
||||
it_ = 1;
|
||||
% [f,fJ,fH] = feval([fname '_dynamic'],y(k),ex);
|
||||
[f,fJ] = feval([fname '_dynamic'],y(k),[oo_.exo_simul oo_.exo_det_simul], M_.params, it_);
|
||||
[f,fJ] = feval([fname '_dynamic'],y(k),[oo.exo_simul oo.exo_det_simul], M_.params, it_);
|
||||
% indices of Lagrange multipliers
|
||||
inst_nbr = endo_nbr - size(f,1);
|
||||
i_mult = [endo_nbr+1:2*endo_nbr-inst_nbr]';
|
||||
|
@ -110,6 +111,7 @@ resids1 = Uy+A*mult;
|
|||
[q,r,e] = qr([A Uy]');
|
||||
if options_.steadystate_flag
|
||||
resids = [r(end,(endo_nbr-inst_nbr+1:end))'];
|
||||
resids = resids1'*resids1;
|
||||
else
|
||||
resids = [f; r(end,(endo_nbr-inst_nbr+1:end))'];
|
||||
end
|
||||
|
|
|
@ -78,6 +78,7 @@ fh = str2func([M_.fname '_static']);
|
|||
if options_.steadystate_flag
|
||||
[ys,check1] = feval([M_.fname '_steadystate'],dr.ys,...
|
||||
[oo_.exo_steady_state; oo_.exo_det_steady_state]);
|
||||
M_.params = evalin('base','M_.params;');
|
||||
if size(ys,1) < M_.endo_nbr
|
||||
if length(M_.aux_vars) > 0
|
||||
ys = add_auxiliary_variables_to_steadystate(ys,M_.aux_vars,...
|
||||
|
|
|
@ -11,7 +11,7 @@ function steady()
|
|||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright (C) 2001-2009 Dynare Team
|
||||
% Copyright (C) 2001-2010 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -51,15 +51,7 @@ end
|
|||
|
||||
steady_;
|
||||
|
||||
disp(' ')
|
||||
disp('STEADY-STATE RESULTS:')
|
||||
disp(' ')
|
||||
endo_names = M_.endo_names;
|
||||
steady_state = oo_.steady_state;
|
||||
for i=1:M_.orig_endo_nbr
|
||||
disp(sprintf('%s \t\t %g',endo_names(i,:),steady_state(i)));
|
||||
end
|
||||
|
||||
disp_steady_state(M_,oo_);
|
||||
|
||||
if isempty(ys0_)
|
||||
oo_.endo_simul(:,1:M_.maximum_lag) = oo_.steady_state * ones(1, M_.maximum_lag);
|
||||
|
|
Loading…
Reference in New Issue