From a93d68fb357929beb4bbf17524b224dcb2f6b89e Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Fri, 25 Mar 2016 20:16:43 +0100 Subject: [PATCH] Make evaluate_steady_state.m honor nocheck flag Closes #1054 --- matlab/dyn_ramsey_static.m | 26 +++++++++++++---------- matlab/evaluate_steady_state.m | 4 ++-- matlab/evaluate_steady_state_file.m | 8 +++---- matlab/perfect-foresight-models/make_y_.m | 2 +- 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/matlab/dyn_ramsey_static.m b/matlab/dyn_ramsey_static.m index c2b619b3f..9bf40cf82 100644 --- a/matlab/dyn_ramsey_static.m +++ b/matlab/dyn_ramsey_static.m @@ -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_(x) -% Computes the static first order conditions for optimal policy +% function [steady_state,params,check] = dyn_ramsey_static_(ys_init,M,options_,oo) +% Computes the steady state for optimal policy % % 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 -% resids: residuals of non linear equations -% rJ: Jacobian -% mult: Lagrangian multipliers +% steady_state: steady state value +% params: parameters at steady state, potentially updated by +% steady_state file +% check: Lagrangian multipliers % % SPECIAL REQUIREMENTS % none -% Copyright (C) 2003-2015 Dynare Team +% Copyright (C) 2003-2016 Dynare Team % % 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; 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 nl_func = @(x) dyn_ramsey_static_1(x,M,options_,oo); @@ -62,7 +66,7 @@ elseif options_.steadystate_flag end ys_init(k_inst) = inst_val; 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 else 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 [oo.exo_steady_state; ... oo.exo_det_steady_state], ... - M,options_); + M,options_,~options_.steadystate.nocheck); end xx = zeros(endo_nbr,1); %initialize steady state vector diff --git a/matlab/evaluate_steady_state.m b/matlab/evaluate_steady_state.m index aec3a1b3f..0f10fc605 100644 --- a/matlab/evaluate_steady_state.m +++ b/matlab/evaluate_steady_state.m @@ -57,7 +57,7 @@ function [ys,params,info] = evaluate_steady_state(ys_init,M,options,oo,steadysta if steadystate_flag % explicit steady state file [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 resids = evaluate_static_model(ys,exo_ss,params,M,options); 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 % explicit steady state file [ys,params,info] = evaluate_steady_state_file(ys_init,exo_ss,M, ... - options); + options,steadystate_check_flag); if size(ys,2)>size(ys,1) error('STEADY: steady_state-file must return a column vector, not a row vector.') end diff --git a/matlab/evaluate_steady_state_file.m b/matlab/evaluate_steady_state_file.m index 4a1c38c59..8f67a5b87 100644 --- a/matlab/evaluate_steady_state_file.m +++ b/matlab/evaluate_steady_state_file.m @@ -1,5 +1,5 @@ -function [ys,params,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) +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,steady_state_checkflag) % Evaluates steady state files % % 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 % M struct model parameters % options struct options -% +% steady_state_checkflag boolean indicator whether to check steady state returned % OUTPUTS % ys vector steady state % params1 vector model parameters possibly @@ -128,7 +128,7 @@ function [ys,params,info] = evaluate_steady_state_file(ys_init,exo_ss,M,options) end check1 = 0; - if ~options.steadystate.nocheck + if steady_state_checkflag % 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); if check diff --git a/matlab/perfect-foresight-models/make_y_.m b/matlab/perfect-foresight-models/make_y_.m index 1badcb5e4..f3c8f686f 100644 --- a/matlab/perfect-foresight-models/make_y_.m +++ b/matlab/perfect-foresight-models/make_y_.m @@ -38,7 +38,7 @@ global ys0_ if options_.steadystate_flag [oo_.steady_state,M_.params,check] = ... evaluate_steady_state_file(oo_.steady_state,oo_.exo_steady_state,M_, ... - options_); + options_,~options_.steadystate.nocheck); end if isempty(oo_.steady_state)