Debian Codegraph @

tests/optimal_policy/neo_growth_ramsey_k_order.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 kth-order approximation of the neo-classical growth model.
21 * It assesses the conditional welfare and the derivatives of the felicity and welfare functions computed by the k_order_welfare function
22 * and compares them to a by-hand assessment stemming from the results the model neo_growth_k_order.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=6, irf=0);
33
34 evaluate_planner_objective(periods=10000,drop=1000);
35
36 [W_dynpp] = k_order_welfare(oo_.dr, M_, options_);
37
38 if ~isfile('neo_growth_k_order/Output/neo_growth_k_order_results.mat')
39 error('neo_growth_k_order must be run first');
40 end;
41
42 oo = load(['neo_growth_k_order' filesep 'Output' filesep 'neo_growth_k_order_results'],'oo_');
43 M = load(['neo_growth_k_order' filesep 'Output' filesep 'neo_growth_k_order_results'],'M_');
44 options = load(['neo_growth_k_order' filesep 'Output' filesep 'neo_growth_k_order_results'],'options_');
45
46 ind_W = strmatch('W', M.M_.endo_names,'exact');
47
48 err = -1e6;
49 for i = 1:options_.order
50 field_W = strcat('W_', num2str(i));
51 g_i = eval(strcat('oo.oo_.dr.g_', num2str(i)));
52 tmp_err = max(W_dynpp.(field_W) - g_i(ind_W, :));
53 err = max(err, tmp_err);
54 end
55
56 if err > 1e-10;
57 error('Inaccurate assessment of the derivatives of the welfare function');
58 end;