| 1 |
heterogeneity_dimension households; |
| 2 |
|
| 3 |
var(heterogeneity=households) |
| 4 |
c // Consumption |
| 5 |
a // Assets |
| 6 |
Va // Derivative of the value function w.r.t assets |
| 7 |
; |
| 8 |
|
| 9 |
varexo(heterogeneity=households) |
| 10 |
e |
| 11 |
; |
| 12 |
|
| 13 |
var |
| 14 |
Y // Aggregate output |
| 15 |
r // Rate of return on capital net of depreciation |
| 16 |
w // Wage rate |
| 17 |
K // Aggregate capital |
| 18 |
; |
| 19 |
|
| 20 |
varexo Z; // Aggregate productivity shock |
| 21 |
|
| 22 |
parameters |
| 23 |
L // Labor |
| 24 |
alpha // Share of capital in production fuction |
| 25 |
beta // Subjective discount rate of houselholds |
| 26 |
delta // Capital depreciation rate |
| 27 |
eis // Elasticity of intertemporal substitution |
| 28 |
rho_Z // Aggregate TFP shock persistence |
| 29 |
sig_Z // Aggregate TFP shock innovation std err |
| 30 |
Z_ss // Aggregate TFP shock average value |
| 31 |
; |
| 32 |
|
| 33 |
model(heterogeneity=households); |
| 34 |
c^(-1/eis)-beta*Va(+1)=0 ⟂ a>=0; |
| 35 |
(1+r)*a(-1)+w*e-c-a; |
| 36 |
Va = (1+r)*c^(-1/eis); |
| 37 |
end; |
| 38 |
|
| 39 |
model; |
| 40 |
(Z_ss+Z) * K(-1)^alpha * L^(1 - alpha) - Y; |
| 41 |
alpha * (Z_ss+Z) * (K(-1) / L)^(alpha - 1) - delta - r; |
| 42 |
(1 - alpha) * (Z_ss+Z) * (K(-1) / L)^alpha - w; |
| 43 |
K - SUM(a); |
| 44 |
end; |
| 45 |
|
| 46 |
shocks; |
| 47 |
var Z; stderr 0.01; |
| 48 |
end; |
| 49 |
|
| 50 |
verbatim; |
| 51 |
mat_file = 'ks_ssj.mat'; |
| 52 |
if ~exist(mat_file, 'file') |
| 53 |
url = sprintf('https://dynare.org/test-data/%s', mat_file); |
| 54 |
websave(mat_file, url); |
| 55 |
end |
| 56 |
load(mat_file); |
| 57 |
|
| 58 |
param_names = fieldnames(steady_state.params); |
| 59 |
for i=1:numel(param_names) |
| 60 |
param = param_names{i}; |
| 61 |
set_param_value(param, steady_state.params.(param)); |
| 62 |
end |
| 63 |
end; |
| 64 |
|
| 65 |
% Initialize steady state once for all tests |
| 66 |
heterogeneity_load_steady_state(filename = ks_ssj); |
| 67 |
|
| 68 |
verbatim; |
| 69 |
testFailed = 0; |
| 70 |
testResults = []; % Array to collect all test results |
| 71 |
|
| 72 |
% Test the solve routine with custom impulse responses (calls solve with custom impulses) |
| 73 |
[testFailed, result] = run_test('heterogeneity.solve with custom impulse responses', @() test_solve_with_custom_impulse_responses(M_, options_, oo_, x_hat_dash, G, J, F, curlyDs, curlyYs, interpolation_indices, interpolation_weights), testFailed); |
| 74 |
testResults = [testResults; result]; |
| 75 |
|
| 76 |
% Print test summary |
| 77 |
print_test_summary(testResults); |
| 78 |
|
| 79 |
if testFailed > 0 |
| 80 |
error('Some unit tests failed!'); |
| 81 |
end |
| 82 |
end; |