Commit f36247ce authored by Michel Juillard's avatar Michel Juillard
Browse files

modifications to ramsey_policy code to allow for estimation

parent 22d5bd16
......@@ -136,21 +136,10 @@ if options_.ramsey_policy
return
end
[jacobia_,M_] = dyn_ramsey_dynamic_(oo_.steady_state,multbar,M_,options_,oo_,it_);
[jacobia_,M_,dr] = dyn_ramsey_dynamic_(oo_.steady_state,multbar,M_,options_,dr,it_);
klen = M_.maximum_lag + M_.maximum_lead + 1;
dr.ys = [oo_.steady_state;zeros(M_.exo_nbr,1);multbar];
oo_.steady_state = dr.ys;
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,:), ...
dr.ys(i)));
end
end
end
else
klen = M_.maximum_lag + M_.maximum_lead + 1;
iyv = M_.lead_lag_incidence';
......
function [J,M_] = dyn_ramsey_dynamic_(ys,lbar,M_,options_,oo_,it_)
function [J,M_,dr] = dyn_ramsey_dynamic_(ys,lbar,M_,options_,dr,it_)
% function J = dyn_ramsey_dynamic_(ys,lbar)
% dyn_ramsey_dynamic_ sets up the Jacobian of the expanded model for optimal
% policies. It modifies several fields of M_
......@@ -30,6 +30,8 @@ function [J,M_] = dyn_ramsey_dynamic_(ys,lbar,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/>.
persistent old_lead_lag
% retrieving model parameters
endo_nbr = M_.endo_nbr;
i_endo_nbr = 1:endo_nbr;
......@@ -71,7 +73,7 @@ Uy = Uy';
Uyy = reshape(Uyy,endo_nbr,endo_nbr);
% retrieving derivatives of original model
[f,fJ,fH] = feval([fname '_dynamic'],y(k),[oo_.exo_simul oo_.exo_det_simul], M_.params, it_);
[f,fJ,fH] = feval([fname '_dynamic'],y(k),zeros(2,exo_nbr), M_.params, it_);
instr_nbr = endo_nbr - size(f,1);
mult_nbr = endo_nbr-instr_nbr;
......@@ -248,3 +250,31 @@ M_.maximum_endo_lead = max_lead1;
M_.maximum_lag = max_lag1;
M_.maximum_endo_lag = max_lag1;
M_.orig_model = orig_model;
if isfield(options_,'varobs') && (any(size(i_leadlag1,2) ~= size(old_lead_lag,2)) || any(any(i_leadlag1 ~= old_lead_lag)))
global bayestopt_
dr = set_state_space(dr,M_);
nstatic = dr.nstatic; % Number of static variables.
npred = dr.npred; % Number of predetermined variables.
var_obs_index = [];
k1 = [];
for i=1:size(options_.varobs,1);
var_obs_index = [var_obs_index strmatch(deblank(options_.varobs(i,:)),M_.endo_names(dr.order_var,:),'exact')];
k1 = [k1 strmatch(deblank(options_.varobs(i,:)),M_.endo_names, 'exact')];
end
% Define union of observed and state variables
k2 = union(var_obs_index',[nstatic+1:nstatic+npred]');
% Set restrict_state to postion of observed + state variables in expanded state vector.
dr.restrict_var_list = k2;
[junk,ic] = intersect(k2,nstatic+(1:npred)');
dr.restrict_columns = ic;
% set mf0 to positions of state variables in restricted state vector for likelihood computation.
[junk,bayestopt_.mf0] = ismember([dr.nstatic+1:dr.nstatic+dr.npred]',k2);
% Set mf1 to positions of observed variables in restricted state vector for likelihood computation.
[junk,bayestopt_.mf1] = ismember(var_obs_index,k2);
% Set mf2 to positions of observed variables in expanded state vector for filtering and smoothing.
bayestopt_.mf2 = var_obs_index;
bayestopt_.mfys = k1;
old_lead_lag = i_leadlag1;
end
\ No newline at end of file
......@@ -198,7 +198,7 @@ end
% Define union of observed and state variables
k2 = union(var_obs_index',[dr.nstatic+1:dr.nstatic+dr.npred]', 'rows');
% Set restrict_state to postion of observed + state variables in expanded state vector.
bayestopt_.restrict_var_list = k2;
oo_.dr.restrict_var_list = k2;
% set mf0 to positions of state variables in restricted state vector for likelihood computation.
[junk,bayestopt_.mf0] = ismember([dr.nstatic+1:dr.nstatic+dr.npred]',k2);
% Set mf1 to positions of observed variables in restricted state vector for likelihood computation.
......@@ -208,12 +208,7 @@ bayestopt_.mf2 = var_obs_index;
bayestopt_.mfys = k1;
[junk,ic] = intersect(k2,nstatic+(1:npred)');
bayestopt_.restrict_columns = [ic; length(k2)+(1:nspred-npred)'];
aux = dr.transition_auxiliary_variables;
aux(:,2) = aux(:,2) + sum(k2 <= nstatic);
k = find(aux(:,2) > npred);
aux(k,2) = aux(k,2) + sum(k2 > nstatic+npred);
bayestopt_.restrict_aux = aux;
oo_.dr.restrict_columns = [ic; length(k2)+(1:nspred-npred)'];
k3 = [];
if options_.selected_variables_only
......
......@@ -19,11 +19,22 @@ function info = ramsey_policy(var_list)
global options_ oo_ M_
oldoptions = options_;
options_.ramsey_policy = 1;
oldoptions = options_;
options_.order = 1;
info = stoch_simul(var_list);
oo_ = evaluate_planner_objective(oo_.dr,M_,oo_,options_);
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_.dr.ys(i)));
end
end
end
%oo_ = evaluate_planner_objective(oo_.dr,M_,oo_,options_);
options_ = oldoptions;
\ No newline at end of file
......@@ -47,6 +47,10 @@ global it_
jacobian_flag = 0;
if isfield(oo_,'dr');
dr = oo_.dr;
end
options_ = set_default_option(options_,'jacobian_flag',1);
info = 0;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment