4.1 adding instruments option to ramsey_policy; ramsey_policy can now use a *_steadystate.m file

git-svn-id: https://www.dynare.org/svn/dynare/trunk@3219 ac1d8469-bf42-47a9-8791-bf33cf982152
time-shift
michel 2009-12-10 14:59:32 +00:00
parent 203c6582ba
commit 74a8acc29c
4 changed files with 78 additions and 9 deletions

View File

@ -83,11 +83,49 @@ function [dr,info,M_,options_,oo_] = dr1(dr,task,M_,options_,oo_)
M_.maximum_lag = orig_model.maximum_lag;
M_.maximum_endo_lag = orig_model.maximum_endo_lag;
end
old_solve_algo = options_.solve_algo;
% options_.solve_algo = 1;
oo_.steady_state = dynare_solve('dyn_ramsey_static_',oo_.steady_state,0,M_,options_,oo_,it_);
options_.solve_algo = old_solve_algo;
[junk,junk,multbar] = dyn_ramsey_static_(oo_.steady_state,M_,options_,oo_,it_);
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')];
end
ys = oo_.steady_state;
inst_val = dynare_solve('dyn_ramsey_static_', ...
oo_.steady_state(k_inst),0, ...
M_,options_,oo_,it_);
ys(k_inst) = inst_val;
[x,check] = feval([M_.fname '_steadystate'],...
ys,[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']);
end
end
oo_.steady_state = x;
[junk,junk,multbar] = dyn_ramsey_static_(oo_.steady_state(k_inst),M_,options_,oo_,it_);
else
oo_.steady_state = dynare_solve('dyn_ramsey_static_', ...
oo_.steady_state,0,M_,options_,oo_,it_);
[junk,junk,multbar] = dyn_ramsey_static_(oo_.steady_state,M_,options_,oo_,it_);
end
check1 = max(abs(feval([M_.fname '_static'],...
oo_.steady_state,...
[oo_.exo_steady_state; ...
oo_.exo_det_steady_state], M_.params))) > options_.dynatol ;
if check1
error(['The steadystate values returned by ' M_.fname ...
'_steadystate.m don''t solve the static model!' ])
end
[jacobia_,M_] = dyn_ramsey_dynamic_(oo_.steady_state,multbar,M_,options_,oo_,it_);
klen = M_.maximum_lag + M_.maximum_lead + 1;
dr.ys = [oo_.steady_state;zeros(M_.exo_nbr,1);multbar];

View File

@ -49,14 +49,39 @@ function [resids, rJ,mult] = dyn_ramsey_static_(x,M_,options_,oo_,it_)
% lead_lag incidence matrix for endogenous variables
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')];
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,...
M_.params);
else
error([M_.fname '_steadystate.m doesn''t match the model']);
end
end
end
% value and Jacobian of objective function
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);
% value and Jacobian of dynamic function
y = repmat(x(i_endo),1,max_lag+max_lead+1);
% value and Jacobian of dynamic function
k = find(i_lag');
it_ = 1;
% [f,fJ,fH] = feval([fname '_dynamic'],y(k),ex);
@ -83,7 +108,11 @@ function [resids, rJ,mult] = dyn_ramsey_static_(x,M_,options_,oo_,it_)
resids1 = Uy+A*mult;
% resids = [f; sqrt(resids1'*resids1/endo_nbr)];
[q,r,e] = qr([A Uy]');
resids = [f; r(end,(endo_nbr-inst_nbr+1:end))'];
if options_.steadystate_flag
resids = [r(end,(endo_nbr-inst_nbr+1:end))'];
else
resids = [f; r(end,(endo_nbr-inst_nbr+1:end))'];
end
rJ = [];
return;

View File

@ -97,7 +97,7 @@ class ParsingDriver;
%token END ENDVAL EQUAL ESTIMATION ESTIMATED_PARAMS ESTIMATED_PARAMS_BOUNDS ESTIMATED_PARAMS_INIT
%token FILENAME FILTER_STEP_AHEAD FILTERED_VARS FIRST_OBS
%token <string_val> FLOAT_NUMBER
%token FORECAST K_ORDER_SOLVER
%token FORECAST K_ORDER_SOLVER INSTRUMENTS
%token GAMMA_PDF GRAPH CONDITIONAL_VARIANCE_DECOMPOSITION
%token HISTVAL HOMOTOPY_SETUP HOMOTOPY_MODE HOMOTOPY_STEPS HP_FILTER HP_NGRID
%token IDENTIFICATION INF_CONSTANT INITVAL INITVAL_FILE
@ -1293,6 +1293,7 @@ ramsey_policy_options_list : ramsey_policy_options_list COMMA ramsey_policy_opti
ramsey_policy_options : stoch_simul_options
| o_planner_discount
| o_instruments
;
write_latex_dynamic_model : WRITE_LATEX_DYNAMIC_MODEL ';'
@ -1875,6 +1876,7 @@ o_equations : EQUATIONS EQUAL vec_int
| EQUATIONS EQUAL INT_NUMBER
{ driver.option_num("ms.equations",$3); }
;
o_instruments : INSTRUMENTS EQUAL '(' symbol_list ')' {driver.option_symbol_list("instruments"); };
range : symbol ':' symbol
{

View File

@ -315,7 +315,7 @@ int sigma_e = 0;
<DYNARE_STATEMENT>draws_nbr_mean_var_estimate {return token::DRAWS_NBR_MEAN_VAR_ESTIMATE;}
<DYNARE_STATEMENT>draws_nbr_modified_harmonic_mean {return token::DRAWS_NBR_MODIFIED_HARMONIC_MEAN;}
<DYNARE_STATEMENT>dirichlet_scale {return token::DIRICHLET_SCALE;}
<DYNARE_STATEMENT>instruments {return token::INSTRUMENTS;}
/* These four (var, varexo, varexo_det, parameters) are for change_type */
<DYNARE_STATEMENT>var { return token::VAR; }