Cosmetic fixes to dyn_ramsey_static.m
Also makes sure that the check flag is returned and the steady state file always called if it exists. Otherwise, parameters might not be updated and NaN not detected.time-shift
parent
7ead968240
commit
3f72f394aa
|
@ -14,7 +14,7 @@ function [steady_state,params,check] = dyn_ramsey_static(x,M,options_,oo)
|
||||||
% SPECIAL REQUIREMENTS
|
% SPECIAL REQUIREMENTS
|
||||||
% none
|
% none
|
||||||
|
|
||||||
% Copyright (C) 2003-2012 Dynare Team
|
% Copyright (C) 2003-2014 Dynare Team
|
||||||
%
|
%
|
||||||
% This file is part of Dynare.
|
% This file is part of Dynare.
|
||||||
%
|
%
|
||||||
|
@ -32,7 +32,6 @@ function [steady_state,params,check] = dyn_ramsey_static(x,M,options_,oo)
|
||||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
steady_state = [];
|
|
||||||
params = M.params;
|
params = M.params;
|
||||||
check = 0;
|
check = 0;
|
||||||
options_.steadystate.nocheck = 1;
|
options_.steadystate.nocheck = 1;
|
||||||
|
@ -40,12 +39,11 @@ options_.steadystate.nocheck = 1;
|
||||||
nl_func = @(x) dyn_ramsey_static_1(x,M,options_,oo);
|
nl_func = @(x) dyn_ramsey_static_1(x,M,options_,oo);
|
||||||
|
|
||||||
% check_static_model is a subfunction
|
% check_static_model is a subfunction
|
||||||
if check_static_model(oo.steady_state,M,options_,oo)
|
if check_static_model(oo.steady_state,M,options_,oo) && ~options_.steadystate_flag
|
||||||
steady_state = oo.steady_state;
|
steady_state = oo.steady_state;
|
||||||
return
|
return
|
||||||
elseif options_.steadystate_flag
|
elseif options_.steadystate_flag
|
||||||
k_inst = [];
|
k_inst = [];
|
||||||
instruments = options_.instruments;
|
|
||||||
inst_nbr = size(options_.instruments,1);
|
inst_nbr = size(options_.instruments,1);
|
||||||
for i = 1:inst_nbr
|
for i = 1:inst_nbr
|
||||||
k_inst = [k_inst; strmatch(options_.instruments(i,:), ...
|
k_inst = [k_inst; strmatch(options_.instruments(i,:), ...
|
||||||
|
@ -54,16 +52,16 @@ elseif options_.steadystate_flag
|
||||||
if inst_nbr == 1
|
if inst_nbr == 1
|
||||||
inst_val = csolve(nl_func,oo.steady_state(k_inst),'',options_.solve_tolf,100);
|
inst_val = csolve(nl_func,oo.steady_state(k_inst),'',options_.solve_tolf,100);
|
||||||
else
|
else
|
||||||
[inst_val,info1] = dynare_solve(nl_func,ys(k_inst),0);
|
[inst_val,check] = dynare_solve(nl_func,ys(k_inst),0);
|
||||||
end
|
end
|
||||||
ys(k_inst) = inst_val;
|
ys(k_inst) = inst_val;
|
||||||
exo_ss = [oo.exo_steady_state oo.exo_det_steady_state];
|
exo_ss = [oo.exo_steady_state oo.exo_det_steady_state];
|
||||||
[xx,params,check] = evaluate_steady_state_file(ys,exo_ss,M,options_);
|
[xx,params,check] = evaluate_steady_state_file(ys,exo_ss,M,options_);
|
||||||
[junk,jun,steady_state] = nl_func(inst_val);
|
[junk,junk,steady_state] = nl_func(inst_val);
|
||||||
else
|
else
|
||||||
n_var = M.orig_endo_nbr;
|
n_var = M.orig_endo_nbr;
|
||||||
xx = oo.steady_state(1:n_var);
|
xx = oo.steady_state(1:n_var);
|
||||||
[xx,info1] = dynare_solve(nl_func,xx,0);
|
[xx,check] = dynare_solve(nl_func,xx,0);
|
||||||
[junk,junk,steady_state] = nl_func(xx);
|
[junk,junk,steady_state] = nl_func(xx);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -78,24 +76,14 @@ mult = [];
|
||||||
params = M.params;
|
params = M.params;
|
||||||
endo_nbr = M.endo_nbr;
|
endo_nbr = M.endo_nbr;
|
||||||
endo_names = M.endo_names;
|
endo_names = M.endo_names;
|
||||||
exo_nbr = M.exo_nbr;
|
|
||||||
orig_endo_nbr = M.orig_endo_nbr;
|
orig_endo_nbr = M.orig_endo_nbr;
|
||||||
aux_vars_type = [M.aux_vars.type];
|
aux_vars_type = [M.aux_vars.type];
|
||||||
orig_endo_aux_nbr = orig_endo_nbr + min(find(aux_vars_type == 6)) - 1;
|
orig_endo_aux_nbr = orig_endo_nbr + min(find(aux_vars_type == 6)) - 1;
|
||||||
orig_eq_nbr = M.orig_eq_nbr;
|
orig_eq_nbr = M.orig_eq_nbr;
|
||||||
inst_nbr = orig_endo_aux_nbr - orig_eq_nbr;
|
inst_nbr = orig_endo_aux_nbr - orig_eq_nbr;
|
||||||
% indices of Lagrange multipliers
|
% indices of Lagrange multipliers
|
||||||
i_mult = [orig_endo_aux_nbr+(1:orig_eq_nbr)]';
|
|
||||||
fname = M.fname;
|
fname = M.fname;
|
||||||
max_lead = M.maximum_lead;
|
|
||||||
max_lag = M.maximum_lag;
|
|
||||||
|
|
||||||
% indices of all endogenous variables
|
|
||||||
i_endo = [1:endo_nbr]';
|
|
||||||
% indices of endogenous variable except instruments
|
|
||||||
% i_inst = M.instruments;
|
|
||||||
% lead_lag incidence matrix
|
|
||||||
i_lag = M.lead_lag_incidence;
|
|
||||||
|
|
||||||
if options_.steadystate_flag
|
if options_.steadystate_flag
|
||||||
k_inst = [];
|
k_inst = [];
|
||||||
|
@ -130,7 +118,6 @@ end
|
||||||
% value and Jacobian of objective function
|
% 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,ex, params);
|
[U,Uy,Uyy] = feval([fname '_objective_static'],x,ex, params);
|
||||||
Uy = Uy';
|
|
||||||
Uyy = reshape(Uyy,endo_nbr,endo_nbr);
|
Uyy = reshape(Uyy,endo_nbr,endo_nbr);
|
||||||
|
|
||||||
% set multipliers and auxiliary variables that
|
% set multipliers and auxiliary variables that
|
||||||
|
|
Loading…
Reference in New Issue