diff --git a/matlab/disp_steady_state.m b/matlab/disp_steady_state.m new file mode 100644 index 0000000000000000000000000000000000000000..b6068206bf82cd86ccf6b8fd661a4a27e4b53a9a --- /dev/null +++ b/matlab/disp_steady_state.m @@ -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 diff --git a/matlab/dr1.m b/matlab/dr1.m index fea5b7c297d22ca84daf4b89f8bb785ec6e680d9..636287ad8b415a49cb419a2d764f597a01b6190e 100644 --- a/matlab/dr1.m +++ b/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; diff --git a/matlab/dyn_ramsey_static_.m b/matlab/dyn_ramsey_static_.m index f887de4db8bf765f44855873050654c107e580ba..ec2a874f6894db132e61ac9fa57c65a0062e21d9 100644 --- a/matlab/dyn_ramsey_static_.m +++ b/matlab/dyn_ramsey_static_.m @@ -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 diff --git a/matlab/model_diagnostics.m b/matlab/model_diagnostics.m index a5089c4a7794a7532cbc129dcccf769dabaf26c6..afb1fac9669477802af77c2ecc61fe3a7b3cc656 100644 --- a/matlab/model_diagnostics.m +++ b/matlab/model_diagnostics.m @@ -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,... diff --git a/matlab/steady.m b/matlab/steady.m index 5c92f2d7cfa36e51762bc7f6f131f9ea07ddcc2c..d03cf79789c1a39b7a95b92413d72d67fbdf3b0f 100644 --- a/matlab/steady.m +++ b/matlab/steady.m @@ -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);