Debian Codegraph @

tests/optimal_policy/neo_growth_ramsey.mod

raw
1 /*
2 * Copyright © 2021 Dynare Team
3 *
4 * This file is part of Dynare.
5 *
6 * Dynare is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * Dynare is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with Dynare. If not, see <https://www.gnu.org/licenses/>.
18 */
19 /*
20 * This file computes a second-order approximation of the neo-classical growth model.
21 * It assesses the conditional and unconditional welfares computed by the evaluate_planner_objective function
22 * and compares them to a by-hand assessment stemming from the results the model neo_growth.mod incur.
23 */
24
25 @#include "neo_growth_ramsey_common.inc"
26
27 shocks;
28 var e;
29 stderr 1;
30 end;
31
32 stoch_simul(order=2, irf=0);
33
34 planner_objective_value = evaluate_planner_objective(M_, options_, oo_);
35
36 if ~isfile('neo_growth/Output/neo_growth_results.mat')
37 error('neo_growth must be run first');
38 end;
39
40 oo1 = load(['neo_growth' filesep 'Output' filesep 'neo_growth_results'],'oo_');
41 M1 = load(['neo_growth' filesep 'Output' filesep 'neo_growth_results'],'M_');
42 options1 = load(['neo_growth' filesep 'Output' filesep 'neo_growth_results'],'options_');
43 unc_W_hand = oo1.oo_.mean(strmatch('W',M1.M_.endo_names,'exact'));
44
45 initial_condition_states = repmat(oo1.oo_.dr.ys,1,M1.M_.maximum_lag);
46 shock_matrix = zeros(1,M1.M_.exo_nbr);
47 y_sim = simult_(M1.M_,options1.options_,initial_condition_states,oo1.oo_.dr,shock_matrix,options1.options_.order);
48 cond_W_hand_L_SS=y_sim(strmatch('W',M1.M_.endo_names,'exact'),2);
49
50 if abs((unc_W_hand - planner_objective_value.unconditional)/unc_W_hand) > 1e-6;
51 error('Inaccurate unconditional welfare assessment');
52 end;
53 if abs(cond_W_hand_L_SS - planner_objective_value.conditional.steady_initial_multiplier) > 1e-6;
54 error('Inaccurate conditional welfare with Lagrange multiplier set to its steady-state value');
55 end;
56
57 if abs(oo_.mean(strmatch('U',M_.endo_names,'exact'))-oo1.oo_.mean(strmatch('U',M1.M_.endo_names,'exact')))>1e-6
58 error('Utility inconsistent');
59 end
60
61 if abs(planner_objective_value.unconditional-oo_.mean(strmatch('U',M_.endo_names,'exact'))/(1-beta)) > 1e-6;
62 error('Unconditional welfare assessment does not match utility');
63 end;
64
65
66 initial_condition_states = zeros(M1.M_.endo_nbr,M1.M_.maximum_lag);
67 initial_condition_states(1:M1.M_.orig_endo_nbr,:) = repmat(oo1.oo_.dr.ys(1:M1.M_.orig_endo_nbr),1,M1.M_.maximum_lag);
68 shock_matrix = zeros(1,M1.M_.exo_nbr);
69 y_sim = simult_(M1.M_,options1.options_,initial_condition_states,oo1.oo_.dr,shock_matrix,options1.options_.order);
70 cond_W_hand_L_0=y_sim(strmatch('W',M1.M_.endo_names,'exact'),2);
71 if abs(cond_W_hand_L_0 - planner_objective_value.conditional.zero_initial_multiplier) > 1e-6;
72 error('Inaccurate conditional welfare with zero Lagrange multiplier');
73 end;