Make evaluate_steady_state.m honor nocheck flag

Closes #1054
time-shift
Johannes Pfeifer 2016-03-25 20:16:43 +01:00
parent b688cbe5b2
commit a93d68fb35
4 changed files with 22 additions and 18 deletions

View File

@ -1,20 +1,24 @@
function [steady_state,params,check] = dyn_ramsey_static(ys_init,M,options_,oo) function [steady_state,params,check] = dyn_ramsey_static(ys_init,M,options_,oo)
% function [steady_state,params,check] = dyn_ramsey_static_(x) % function [steady_state,params,check] = dyn_ramsey_static_(ys_init,M,options_,oo)
% Computes the static first order conditions for optimal policy % Computes the steady state for optimal policy
% %
% INPUTS % INPUTS
% x: vector of endogenous variables or instruments % ys_init: vector of endogenous variables or instruments
% % M: Dynare model structure
% options: Dynare options structure
% oo: Dynare results structure
%
% OUTPUTS % OUTPUTS
% resids: residuals of non linear equations % steady_state: steady state value
% rJ: Jacobian % params: parameters at steady state, potentially updated by
% mult: Lagrangian multipliers % steady_state file
% check: Lagrangian multipliers
% %
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
% Copyright (C) 2003-2015 Dynare Team % Copyright (C) 2003-2016 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
@ -34,7 +38,7 @@ function [steady_state,params,check] = dyn_ramsey_static(ys_init,M,options_,oo)
params = M.params; params = M.params;
check = 0; check = 0;
options_.steadystate.nocheck = 1; %disable checking because Lagrange multipliers are not accounted for in evaluate_steady_state_file options_.steadystate.nocheck = 1; %locally disable checking because Lagrange multipliers are not accounted for in evaluate_steady_state_file
% dyn_ramsey_static_1 is a subfunction % dyn_ramsey_static_1 is a subfunction
nl_func = @(x) dyn_ramsey_static_1(x,M,options_,oo); nl_func = @(x) dyn_ramsey_static_1(x,M,options_,oo);
@ -62,7 +66,7 @@ elseif options_.steadystate_flag
end end
ys_init(k_inst) = inst_val; ys_init(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_init,exo_ss,M,options_); %run steady state file again to update parameters [xx,params,check] = evaluate_steady_state_file(ys_init,exo_ss,M,options_,~options_.steadystate.nocheck); %run steady state file again to update parameters
[junk,junk,steady_state] = nl_func(inst_val); %compute and return steady state [junk,junk,steady_state] = nl_func(inst_val); %compute and return steady state
else else
n_var = M.orig_endo_nbr; n_var = M.orig_endo_nbr;
@ -105,7 +109,7 @@ if options_.steadystate_flag
[x,params,check] = evaluate_steady_state_file(ys_init,... %returned x now has size endo_nbr as opposed to input size of n_instruments [x,params,check] = evaluate_steady_state_file(ys_init,... %returned x now has size endo_nbr as opposed to input size of n_instruments
[oo.exo_steady_state; ... [oo.exo_steady_state; ...
oo.exo_det_steady_state], ... oo.exo_det_steady_state], ...
M,options_); M,options_,~options_.steadystate.nocheck);
end end
xx = zeros(endo_nbr,1); %initialize steady state vector xx = zeros(endo_nbr,1); %initialize steady state vector

View File

@ -57,7 +57,7 @@ function [ys,params,info] = evaluate_steady_state(ys_init,M,options,oo,steadysta
if steadystate_flag if steadystate_flag
% explicit steady state file % explicit steady state file
[ys,params,info] = evaluate_steady_state_file(ys_init,exo_ss,M, ... [ys,params,info] = evaluate_steady_state_file(ys_init,exo_ss,M, ...
options); options,steadystate_check_flag);
%test whether it solves model conditional on the instruments %test whether it solves model conditional on the instruments
resids = evaluate_static_model(ys,exo_ss,params,M,options); resids = evaluate_static_model(ys,exo_ss,params,M,options);
n_multipliers=M.ramsey_eq_nbr; n_multipliers=M.ramsey_eq_nbr;
@ -186,7 +186,7 @@ function [ys,params,info] = evaluate_steady_state(ys_init,M,options,oo,steadysta
elseif steadystate_flag elseif steadystate_flag
% explicit steady state file % explicit steady state file
[ys,params,info] = evaluate_steady_state_file(ys_init,exo_ss,M, ... [ys,params,info] = evaluate_steady_state_file(ys_init,exo_ss,M, ...
options); options,steadystate_check_flag);
if size(ys,2)>size(ys,1) if size(ys,2)>size(ys,1)
error('STEADY: steady_state-file must return a column vector, not a row vector.') error('STEADY: steady_state-file must return a column vector, not a row vector.')
end end

View File

@ -1,5 +1,5 @@
function [ys,params,info] = evaluate_steady_state_file(ys_init,exo_ss,M,options) function [ys,params,info] = evaluate_steady_state_file(ys_init,exo_ss,M,options,steady_state_checkflag)
% function [ys,params1,info] = evaluate_steady_state_file(ys_init,exo_ss,M,options) % function [ys,params1,info] = evaluate_steady_state_file(ys_init,exo_ss,M,options,steady_state_checkflag)
% Evaluates steady state files % Evaluates steady state files
% %
% INPUTS % INPUTS
@ -8,7 +8,7 @@ function [ys,params,info] = evaluate_steady_state_file(ys_init,exo_ss,M,options)
% exo_ss vector exogenous steady state % exo_ss vector exogenous steady state
% M struct model parameters % M struct model parameters
% options struct options % options struct options
% % steady_state_checkflag boolean indicator whether to check steady state returned
% OUTPUTS % OUTPUTS
% ys vector steady state % ys vector steady state
% params1 vector model parameters possibly % params1 vector model parameters possibly
@ -128,7 +128,7 @@ function [ys,params,info] = evaluate_steady_state_file(ys_init,exo_ss,M,options)
end end
check1 = 0; check1 = 0;
if ~options.steadystate.nocheck if steady_state_checkflag
% Check whether the steady state obtained from the _steadystate file is a steady state. % Check whether the steady state obtained from the _steadystate file is a steady state.
[residuals, check] = evaluate_static_model(ys, exo_ss, params, M, options); [residuals, check] = evaluate_static_model(ys, exo_ss, params, M, options);
if check if check

View File

@ -38,7 +38,7 @@ global ys0_
if options_.steadystate_flag if options_.steadystate_flag
[oo_.steady_state,M_.params,check] = ... [oo_.steady_state,M_.params,check] = ...
evaluate_steady_state_file(oo_.steady_state,oo_.exo_steady_state,M_, ... evaluate_steady_state_file(oo_.steady_state,oo_.exo_steady_state,M_, ...
options_); options_,~options_.steadystate.nocheck);
end end
if isempty(oo_.steady_state) if isempty(oo_.steady_state)