Merge branch 'ramsey'

time-shift
Michel Juillard 2011-06-22 18:41:20 +02:00
commit 219d6766b2
4 changed files with 31 additions and 14 deletions

View File

@ -24,8 +24,10 @@ k = size(ys,1)+1;
aux_lead_nbr = 0; aux_lead_nbr = 0;
for i=1:n for i=1:n
if aux_vars(i).type == 1 if aux_vars(i).type == 1
% lagged variables
ys1(k) = ys(aux_vars(i).orig_index); ys1(k) = ys(aux_vars(i).orig_index);
elseif aux_vars(i).type == 0 elseif aux_vars(i).type == 0
% lead variables
aux_lead_nbr = aux_lead_nbr + 1; aux_lead_nbr = aux_lead_nbr + 1;
end end
k = k+1; k = k+1;

View File

@ -92,14 +92,20 @@ if options_.ramsey_policy
if options_.steadystate_flag if options_.steadystate_flag
k_inst = []; k_inst = [];
instruments = options_.instruments; instruments = options_.instruments;
for i = 1:size(instruments,1) inst_nbr = size(options_.instruments);
for i = 1:inst_nbr
k_inst = [k_inst; strmatch(options_.instruments(i,:), ... k_inst = [k_inst; strmatch(options_.instruments(i,:), ...
M_.endo_names,'exact')]; M_.endo_names,'exact')];
end end
ys = oo_.steady_state; ys = oo_.steady_state;
[inst_val,info1] = dynare_solve('dyn_ramsey_static_', ... if inst_nbr == 1
oo_.steady_state(k_inst),0, ... nl_func = @(x) dyn_ramsey_static_(x,0,M_,options_,oo_,it_);
M_,options_,oo_,it_); inst_val = fzero(nl_func,oo_.steady_state(k_inst));
else
[inst_val,info1] = dynare_solve('dyn_ramsey_static_', ...
oo_.steady_state(k_inst),0, ...
M_,options_,oo_,it_);
end
M_.params = evalin('base','M_.params;'); M_.params = evalin('base','M_.params;');
ys(k_inst) = inst_val; ys(k_inst) = inst_val;
[x,check] = feval([M_.fname '_steadystate'],... [x,check] = feval([M_.fname '_steadystate'],...
@ -120,6 +126,7 @@ if options_.ramsey_policy
end end
oo_.steady_state = x; oo_.steady_state = x;
[junk,junk,multbar] = dyn_ramsey_static_(oo_.steady_state(k_inst),M_,options_,oo_,it_); [junk,junk,multbar] = dyn_ramsey_static_(oo_.steady_state(k_inst),M_,options_,oo_,it_);
oo_.steady_state = [x(1:M_.orig_endo_nbr); multbar];
else else
xx = oo_.steady_state([1:M_.orig_endo_nbr (M_.orig_endo_nbr+M_.orig_eq_nbr+1):end]); xx = oo_.steady_state([1:M_.orig_endo_nbr (M_.orig_endo_nbr+M_.orig_eq_nbr+1):end]);
[xx,info1] = dynare_solve('dyn_ramsey_static_', ... [xx,info1] = dynare_solve('dyn_ramsey_static_', ...

View File

@ -96,11 +96,15 @@ y = f(1:orig_endo_nbr);
mult = -A\y; mult = -A\y;
resids1 = y+A*mult; resids1 = y+A*mult;
[q,r,e] = qr([A y]'); if inst_nbr == 1
if options_.steadystate_flag r1 = sqrt(resids1'*resids1);
resids = [r(end,(orig_endo_nbr-inst_nbr+1:end))'];
resids = resids1'*resids1;
else else
resids = [f(i_mult); r(end,(orig_endo_nbr-inst_nbr+1:end))']; [q,r,e] = qr([A y]');
r1 = r(end,(orig_endo_nbr-inst_nbr+1:end))';
end
if options_.steadystate_flag
resids = r1;
else
resids = [f(i_mult); r1];
end end
rJ = []; rJ = [];

View File

@ -106,8 +106,8 @@ else
Wss = (Uy*gss+beta*(Wuu*M.Sigma_e(:)+Wy*Gss))/(1-beta); Wss = (Uy*gss+beta*(Wuu*M.Sigma_e(:)+Wy*Gss))/(1-beta);
end end
if options.ramsey_policy if options.ramsey_policy
yhat = [oo.endo_simul; ... yhat = zeros(M.endo_nbr,1);
zeros(M.endo_nbr-size(oo.endo_simul,1),1)]; yhat(1:M.orig_endo_nbr) = oo.steady_state(1:M.orig_endo_nbr);
else else
yhat = oo.endo_simul; yhat = oo.endo_simul;
end end
@ -120,11 +120,15 @@ mexErrCheck('A_times_B_kronecker_C', err);
mexErrCheck('A_times_B_kronecker_C', err); mexErrCheck('A_times_B_kronecker_C', err);
[err,Wyuyhatu] = A_times_B_kronecker_C(Wyu,yhat,u,options.threads.kronecker.A_times_B_kronecker_C); [err,Wyuyhatu] = A_times_B_kronecker_C(Wyu,yhat,u,options.threads.kronecker.A_times_B_kronecker_C);
mexErrCheck('A_times_B_kronecker_C', err); mexErrCheck('A_times_B_kronecker_C', err);
planner_objective_value = Wbar+Wy*yhat+Wu*u+Wyuyhatu ... planner_objective_value(1) = Wbar+Wy*yhat+Wu*u+Wyuyhatu ...
+ 0.5*(Wyyyhatyhat + Wuuuu+Wss); + 0.5*(Wyyyhatyhat + Wuuuu+Wss);
planner_objective_value(2) = Wbar + 0.5*Wss;
if ~options.noprint if ~options.noprint
disp(' ') disp(' ')
disp(['Approximated value of planner objective function: ' ... disp('Approximated value of planner objective function')
num2str(planner_objective_value)]) disp([' - with initial Lagrange multipliers set to 0: ' ...
num2str(planner_objective_value(1)) ])
disp([' - with initial Lagrange multipliers set to steady state: ' ...
num2str(planner_objective_value(2)) ])
disp(' ') disp(' ')
end end