Skip to content
Snippets Groups Projects
Commit 62f1bceb authored by MichelJuillard's avatar MichelJuillard
Browse files

fixed welfare evaluation for arbirtrary value of the state

variables. The preprocessor still needs to be modified to allow
arbitrary initial value of the Lagrange multipliers
(cherry picked from commit 9eb5b283b1da78b6d3f76739b91802268268b564)
parent be0dd5e5
Branches
Tags
No related merge requests found
function planner_objective_value = evaluate_planner_objective(M,oo,options) function planner_objective_value = evaluate_planner_objective(M,options,oo)
%function oo1 = evaluate_planner_objective(dr,M,oo,options) %function oo1 = evaluate_planner_objective(dr,M,oo,options)
% computes value of planner objective function % computes value of planner objective function
% %
% INPUTS % INPUTS
% dr: (structure) decision rule
% M: (structure) model description % M: (structure) model description
% oo: (structure) output results
% options: (structure) options % options: (structure) options
% oo: (structure) output results
% %
% OUTPUTS
% oo1: (structure) updated output results
%
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% none % none
...@@ -105,30 +101,48 @@ else ...@@ -105,30 +101,48 @@ else
Wyu = Uy*gyu+Uyygygu+beta*(Wy*Gyu+Wyygygu); Wyu = Uy*gyu+Uyygygu+beta*(Wy*Gyu+Wyygygu);
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
% initialize yhat1 at the steady state
yhat1 = oo.steady_state;
if options.ramsey_policy if options.ramsey_policy
yhat = zeros(M.endo_nbr,1); % initialize le Lagrange multipliers to 0 in yhat2
yhat(1:M.orig_endo_nbr) = oo.steady_state(1:M.orig_endo_nbr); yhat2 = zeros(M.endo_nbr,1);
else yhat2(1:M.orig_endo_nbr) = oo.steady_state(1:M.orig_endo_nbr);
yhat = oo.endo_simul;
end end
yhat = yhat(dr.order_var(nstatic+(1:npred)),1)-dr.ys(dr.order_var(nstatic+(1:npred))); if ~isempty(M.endo_histval)
% initialize endogenous state variable to histval if necessary
yhat1(1:M.orig_endo_nbr) = M.endo_histval(1:M.orig_endo_nbr);
if options.ramsey_policy
yhat12(1:M.orig_endo_nbr) = M.endo_histval(1:M.orig_endo_nbr);
end
end
yhat1 = yhat1(dr.order_var(nstatic+(1:npred)),1)-dr.ys(dr.order_var(nstatic+(1:npred)));
yhat2 = yhat2(dr.order_var(nstatic+(1:npred)),1)-dr.ys(dr.order_var(nstatic+(1:npred)));
u = oo.exo_simul(1,:)'; u = oo.exo_simul(1,:)';
[Wyyyhatyhat, err] = A_times_B_kronecker_C(Wyy,yhat,yhat,options.threads.kronecker.A_times_B_kronecker_C); [Wyyyhatyhat1, err] = A_times_B_kronecker_C(Wyy,yhat1,yhat1,options.threads.kronecker.A_times_B_kronecker_C);
mexErrCheck('A_times_B_kronecker_C', err); mexErrCheck('A_times_B_kronecker_C', err);
[Wuuuu, err] = A_times_B_kronecker_C(Wuu,u,u,options.threads.kronecker.A_times_B_kronecker_C); [Wuuuu, err] = A_times_B_kronecker_C(Wuu,u,u,options.threads.kronecker.A_times_B_kronecker_C);
mexErrCheck('A_times_B_kronecker_C', err); mexErrCheck('A_times_B_kronecker_C', err);
[Wyuyhatu, err] = A_times_B_kronecker_C(Wyu,yhat,u,options.threads.kronecker.A_times_B_kronecker_C); [Wyuyhatu1, err] = A_times_B_kronecker_C(Wyu,yhat1,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(1) = Wbar+Wy*yhat+Wu*u+Wyuyhatu ... planner_objective_value(1) = Wbar+Wy*yhat1+Wu*u+Wyuyhatu1 ...
+ 0.5*(Wyyyhatyhat + Wuuuu+Wss); + 0.5*(Wyyyhatyhat1 + Wuuuu+Wss);
planner_objective_value(2) = Wbar + 0.5*Wss; if options.ramsey_policy
[Wyyyhatyhat2, err] = A_times_B_kronecker_C(Wyy,yhat2,yhat2,options.threads.kronecker.A_times_B_kronecker_C);
mexErrCheck('A_times_B_kronecker_C', err);
[Wyuyhatu2, err] = A_times_B_kronecker_C(Wyu,yhat2,u,options.threads.kronecker.A_times_B_kronecker_C);
mexErrCheck('A_times_B_kronecker_C', err);
planner_objective_value(2) = Wbar+Wy*yhat2+Wu*u+Wyuyhatu2 ...
+ 0.5*(Wyyyhatyhat2 + Wuuuu+Wss);
end
if ~options.noprint if ~options.noprint
disp(' ') disp(' ')
disp('Approximated value of planner objective function') disp('Approximated value of planner objective function')
disp([' - with initial Lagrange multipliers set to 0: ' ... 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)) ]) num2str(planner_objective_value(2)) ])
disp([' - with initial Lagrange multipliers set to steady state: ' ...
num2str(planner_objective_value(1)) ])
disp(' ') disp(' ')
end end
\ No newline at end of file
...@@ -37,6 +37,6 @@ if options_.noprint == 0 ...@@ -37,6 +37,6 @@ if options_.noprint == 0
end end
oo_.planner_objective_value = evaluate_planner_objective(M_,oo_,options_); oo_.planner_objective_value = evaluate_planner_objective(M_,options_,oo_);
options_ = oldoptions; options_ = oldoptions;
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment