Debian Codegraph @

tests/heterogeneity/hank_1a.mod

raw
1 heterogeneity_dimension households;
2
3 var(heterogeneity=households)
4 c // consumption
5 n // labor supply
6 ns // effective labor supply
7 a // assets
8 Va // derivative of value function w.r.t. a
9 ;
10
11 varexo(heterogeneity=households)
12 e // idiosyncratic efficiency
13 ;
14
15 var
16 Y L w pi Div Tax r
17 ;
18
19 varexo G markup rstar;
20
21 @#ifdef DET_SHOCKS
22 seq = 0.01*0.8.^(0:49);
23 @#endif
24
25 shocks;
26 @#ifndef DET_SHOCKS
27 var G; stderr 0.01;
28 var markup; stderr 0.01;
29 var rstar; stderr 0.01;
30 @#else
31 var G;
32 periods 1;
33 values 0.01;
34 var markup;
35 periods 4:5;
36 values 0.01;
37 var rstar;
38 periods 1:50;
39 values (seq);
40 @#endif
41 end;
42
43 parameters
44 beta vphi
45 eis frisch
46 rho_e sig_e
47 rho_Z sig_Z
48 mu kappa phi
49 Z B r_ss
50 ;
51
52 model(heterogeneity=households);
53 // Euler equation with borrowing constraint
54 c^(-1/eis) - beta * Va(+1) = 0 ⟂ a >= 0;
55
56 // Budget constraint
57 (1 + r) * a(-1) + w * n * e + (Div-Tax) * e - c - a;
58
59 // Envelope condition
60 Va = (1 + r) * c^(-1/eis);
61
62 // Intratemporal FOC for labor supply
63 vphi*n^(1/frisch) - w*e*c^(-1/eis);
64
65 // Definition of the effective labor supply
66 ns = n * e;
67 end;
68
69 model;
70 // Firm
71 L - Y / Z;
72 Div - (Y - w * L - mu / (mu - 1) / (2 * kappa) * log(1 + pi)^2 * Y);
73
74 // Monetary policy (Taylor rule)
75 (1 + r_ss + rstar(-1) + phi * pi(-1)) / (1 + pi) - 1 - r;
76
77 // Fiscal policy
78 Tax - (r * B) - G;
79
80 // NKPC
81 kappa * (w / Z - 1 / mu)
82 + Y(+1)/Y * log(1 + pi(+1)) / (1 + r(+1))
83 + markup
84 - log(1 + pi);
85
86 // Market clearing
87 SUM(a) - B; // asset market
88 sum(ns) - L; // labor market
89 end;
90
91 load 'hank_1a.mat';
92
93 param_names = fieldnames(steady_state.params);
94 for i=1:numel(param_names)
95 param = param_names{i};
96 set_param_value(param, steady_state.params.(param));
97 end
98
99 % Initialize steady state once for all tests
100 heterogeneity_load_steady_state(filename = hank_1a);
101 % Check that required fields exist
102 assert(isfield(oo_, 'heterogeneity'), 'oo_.heterogeneity field missing');
103 assert(isfield(oo_.heterogeneity, 'steady_state'), 'oo_.heterogeneity.ss field missing');
104 assert(isfield(oo_.heterogeneity, 'sizes'), 'oo_.heterogeneity.sizes field missing');
105 assert(isfield(oo_.heterogeneity, 'mat'), 'oo_.heterogeneity.mat field missing');
106 assert(isfield(oo_.heterogeneity, 'indices'), 'oo_.heterogeneity.indices field missing');
107
108 % Solve once for all tests
109 heterogeneity_solve;
110
111 verbatim;
112 testFailed = 0;
113 testResults = []; % Array to collect all test results
114
115 % Test heterogeneity.simulate function (reuse initialized and solved model)
116 @#ifdef DET_SHOCKS
117 [testFailed, testResults] = test_simulate_news_shocks(M_, options_, oo_, steady_state, sim_result, testFailed, testResults);
118 @#else
119 [testFailed, testResults] = test_simulate_stochastic(M_, options_, oo_, steady_state, testFailed, testResults);
120 @#endif
121
122 % Print test summary
123 print_test_summary(testResults);
124
125 if testFailed > 0
126 error('Some unit tests failed!');
127 end
128 end;