-
Notifications
You must be signed in to change notification settings - Fork 12
/
fsi_abz_ds_vecsv_default.m
297 lines (249 loc) · 13.8 KB
/
fsi_abz_ds_vecsv_default.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
%% Test Borrowing Default (Save + Borr Distribution)
% *back to <https://fanwangecon.github.io Fan>'s
% <https://fanwangecon.github.io/CodeDynaAsset/ Dynamic Assets Repository>
% Table of Content.*
%
% @seealso
%
% * test speed: <https://fanwangecon.github.io/CodeDynaAsset/m_abz/test/ff_az_ds_vecsv/test_speed/html/fsi_abz_ds_vecsv_speed.html fsi_abz_ds_vecsv_speed>
% * test joint *RANDOM*: <https://fanwangecon.github.io/CodeDynaAsset/m_abz/test/ff_az_ds_vecsv/test_joint/html/fsi_abz_ds_vecsv_joint_rand.html fsi_abz_ds_vecsv_joint_rand>
%
% * test price no default *CROSS*: <https://fanwangecon.github.io/CodeDynaAsset/m_abz/test/ff_az_ds_vecsv/test_price/html/fsi_abz_ds_vecsv_price_nbc_cross.html fsi_abz_ds_vecsv_price_nbc_cross>
% * test price default *CROSS*: <https://fanwangecon.github.io/CodeDynaAsset/m_abz/test/ff_az_ds_vecsv/test_price/html/fsi_abz_ds_vecsv_price_default_cross.html fsi_abz_ds_vecsv_price_default_cross>
%
% * test interest rate no default: <https://fanwangecon.github.io/CodeDynaAsset/m_abz/test/ff_az_ds_vecsv/test_borr/html/fsi_abz_ds_vecsv_nbc.html fsi_abz_ds_vecsv_nbc>
% * test interest rate no default *CROSS*: <https://fanwangecon.github.io/CodeDynaAsset/m_abz/test/ff_az_ds_vecsv/test_borr/html/fsi_abz_ds_vecsv_nbc_cross.html fsi_abz_ds_vecsv_nbc_cross>
% * test interest rate no default *GRID*: <https://fanwangecon.github.io/CodeDynaAsset/m_abz/test/ff_az_ds_vecsv/test_borr/html/fsi_abz_ds_vecsv_nbc_grid.html fsi_abz_ds_vecsv_nbc_grid>
% * test interest rate default: <https://fanwangecon.github.io/CodeDynaAsset/m_abz/test/ff_az_ds_vecsv/test_borr/html/fsi_abz_ds_vecsv_default.html fsi_abz_ds_vecsv_default>
% * test interest rate default *V(a,z)* Comparison: <https://fanwangecon.github.io/CodeDynaAsset/m_abz/test/ff_az_ds_vecsv/test_borr/html/fsi_abz_ds_vecsv_default_compaz.html fsi_abz_ds_vecsv_default_compaz>
% * test interest rate default *CROSS*: <https://fanwangecon.github.io/CodeDynaAsset/m_abz/test/ff_az_ds_vecsv/test_borr/html/fsi_abz_ds_vecsv_default_cross.html fsi_abz_ds_vecsv_default_cross>
% * test interest rate default *GRID*: <https://fanwangecon.github.io/CodeDynaAsset/m_abz/test/ff_az_ds_vecsv/test_borr/html/fsi_abz_ds_vecsv_default_grid.html fsi_abz_ds_vecsv_default_grid>
%
% * test shock default (very low cmin): <https://fanwangecon.github.io/CodeDynaAsset/m_abz/test/ff_az_ds_vecsv/test_shock/html/fsi_abz_ds_vecsv_shk_default_lowcmin.html fsi_abz_ds_vecsv_shk_default_lowcmin>
% * test shock no default: <https://fanwangecon.github.io/CodeDynaAsset/m_abz/test/ff_az_ds_vecsv/test_shock/html/fsi_abz_ds_vecsv_shk_nbc.html fsi_abz_ds_vecsv_shk_nbc>
% * test shock no default *CROSS*: <https://fanwangecon.github.io/CodeDynaAsset/m_abz/test/ff_az_ds_vecsv/test_shock/html/fsi_abz_ds_vecsv_shk_nbc_cross.html fsi_abz_ds_vecsv_shk_nbc_cross>
% * test shock default: <https://fanwangecon.github.io/CodeDynaAsset/m_abz/test/ff_az_ds_vecsv/test_shock/html/fsi_abz_ds_vecsv_shk_default.html fsi_abz_ds_vecsv_shk_default>
% * test shock default *CROSS*: <https://fanwangecon.github.io/CodeDynaAsset/m_abz/test/ff_az_ds_vecsv/test_shock/html/fsi_abz_ds_vecsv_shk_default_cross.html fsi_abz_ds_vecsv_shk_default_cross>
%
% * test preference no default: <https://fanwangecon.github.io/CodeDynaAsset/m_abz/test/ff_az_ds_vecsv/test_pref/html/fsi_abz_ds_vecsv_pref_nbc.html fsi_abz_ds_vecsv_pref_nbc>
% * test preference no default *CROSS*: <https://fanwangecon.github.io/CodeDynaAsset/m_abz/test/ff_az_ds_vecsv/test_pref/html/fsi_abz_ds_vecsv_pref_nbc_cross.html fsi_abz_ds_vecsv_pref_nbc_cross>
% * test preference default: <https://fanwangecon.github.io/CodeDynaAsset/m_abz/test/ff_az_ds_vecsv/test_pref/html/fsi_abz_ds_vecsv_pref_default.html fsi_abz_ds_vecsv_pref_default>
% * test preference default *CROSS*: <https://fanwangecon.github.io/CodeDynaAsset/m_abz/test/ff_az_ds_vecsv/test_pref/html/fsi_abz_ds_vecsv_pref_default_cross.html fsi_abz_ds_vecsv_pref_default_cross>
% * test preference default (very low cmin): <https://fanwangecon.github.io/CodeDynaAsset/m_abz/test/ff_az_ds_vecsv/test_pref/html/fsi_abz_ds_vecsv_pref_default_lowcmin.html fsi_abz_ds_vecsv_pref_default_lowcmin>
%
%% Set Shared Parameters
% Accuracy
ar_fl_z_r_borr_n_hg = 3:5:17;
ar_it_a_n_hg = zeros([1,length(ar_fl_z_r_borr_n_hg)]) + 750;
%% Test Minimum Consumption with Defaults, Vary Borrow Bound
% As Borrowing bound relaxes, more borrowing. As borrowing bound is
% relaxed, the fraction of people defaulting is increasing. *pYisMINY*
% captures fraction of households defaulting. Note that this fraction was
% close to almost exactly zero when default was not allowed due to the
% natural borrowing constraint.
%
% Much greater consumption variance, is this calculated correctly?, when
% there is relaxed borrowing constraint. Consumption is not calculated
% correctly for borrowing.
%
close all;
it_size = 4;
% default or not
bl_default = true;
ar_bl_default = zeros([1,it_size]) + bl_default;
% cmin
fl_c_min = 0.025;
ar_fl_c_min = zeros([1,it_size]) + fl_c_min;
% borrow bound
ar_fl_b_bd = linspace(-20, -5, it_size);
% ar_fl_b_bd = zeros([1,it_size]) + fl_b_bd;
% fl_z_r_borr_poiss_mean
fl_z_r_borr_poiss_mean = 0.10;
% ar_fl_z_r_borr_poiss_mean = linspace(0.20, 0.025, it_size);
ar_fl_z_r_borr_poiss_mean = zeros([1,it_size]) + fl_z_r_borr_poiss_mean;
% Simulate Model with Discount = 0.85
for it_cur_param = 1:1:length(ar_bl_default)
disp('xxxxxxxxxxxxxxxxxxxxxxxxxxx');
disp('xxxxxxxxxxxxxxxxxxxxxxxxxxx');
disp(['ar_bl_default = ' num2str(ar_bl_default(it_cur_param))]);
disp(['ar_fl_c_min = ' num2str(ar_fl_c_min(it_cur_param))]);
disp(['ar_fl_b_bd = ' num2str(ar_fl_b_bd(it_cur_param))]);
disp(['ar_fl_z_r_borr_poiss_mean = ' num2str(ar_fl_z_r_borr_poiss_mean(it_cur_param))]);
disp('xxxxxxxxxxxxxxxxxxxxxxxxxxx');
disp('xxxxxxxxxxxxxxxxxxxxxxxxxxx');
disp('');
disp('');
disp('');
disp('');
% Call Default Parameters <https://fanwangecon.github.io/CodeDynaAsset/m_az/paramfunc/html/ffs_abz_set_default_param.html ffs_abz_set_default_param>
bl_input_override = true;
it_param_set = 9;
[param_map, support_map] = ffs_abz_set_default_param(it_param_set);
% Borrowing Parameters
param_map('bl_default') = ar_bl_default(it_cur_param);
param_map('fl_c_min') = ar_fl_c_min(it_cur_param);
param_map('fl_b_bd') = ar_fl_b_bd(it_cur_param);
% Interest Rates
param_map('fl_z_r_borr_poiss_mean') = ar_fl_z_r_borr_poiss_mean(it_cur_param);
% Display Parameters
support_map('bl_display') = false;
support_map('bl_display_final') = false;
support_map('bl_time') = true;
support_map('bl_profile') = false;
support_map('bl_graph_funcgrids') = false;
for it_accuracy = 1:length(ar_it_a_n_hg)
% Accuracy Regular
param_map('it_a_n') = ar_it_a_n_hg(it_accuracy);
param_map('fl_z_r_borr_n') = ar_fl_z_r_borr_n_hg(it_accuracy);
it_z_n = param_map('it_z_wage_n') * param_map('fl_z_r_borr_n');
param_map('it_z_n') = it_z_n;
disp('xxxxxxxxxxxxxxxxxxxxxxxxxxx');
disp(['it_a_n = ' num2str(ar_it_a_n_hg(it_accuracy)) ', it_z_n = ' num2str(it_z_n)]);
disp('xxxxxxxxxxxxxxxxxxxxxxxxxxx');
% Call Grid Generator <https://fanwangecon.github.io/CodeDynaAsset/m_az/paramfunc/html/ffs_abz_get_funcgrid.html ffs_abz_get_funcgrid>
[armt_map, func_map] = ffs_abz_get_funcgrid(param_map, support_map, bl_input_override);
% Call Dynamic Programming Problem <https://fanwangecon.github.io/CodeDynaAsset/m_az/solve/html/ff_abz_vf_vecsv.html ff_abz_vf_vecsv>
result_map = ff_abz_vf_vecsv(param_map, support_map, armt_map, func_map);
% Call Distribution CProgram
result_map = ff_az_ds_vecsv(param_map, support_map, armt_map, func_map, result_map, bl_input_override);
end
% Snap
snapnow;
end
% close all
close all;
%% Test Minimum Consumption with Defaults, Vary Cmin
% A minimum consumption value increases, default increases. As Cmin
% decreases, households still borrow, but there is eventually 0 percent of
% households that are going to the defaulting bound.
close all;
it_size = 4;
% default or not
bl_default = true;
ar_bl_default = zeros([1,it_size]) + bl_default;
% cmin
ar_fl_c_min = linspace(0.1, 0.001, it_size);
% ar_fl_c_min = zeros([1,it_size]) + fl_c_min;
% borrow bound
fl_b_bd = -12.5;
ar_fl_b_bd = zeros([1,it_size]) + fl_b_bd;
% fl_z_r_borr_poiss_mean
fl_z_r_borr_poiss_mean = 0.10;
ar_fl_z_r_borr_poiss_mean = zeros([1,it_size]) + fl_z_r_borr_poiss_mean;
% Simulate Model with Discount = 0.85
for it_cur_param = 1:1:length(ar_bl_default)
disp('xxxxxxxxxxxxxxxxxxxxxxxxxxx');
disp('xxxxxxxxxxxxxxxxxxxxxxxxxxx');
disp(['ar_bl_default = ' num2str(ar_bl_default(it_cur_param))]);
disp(['ar_fl_c_min = ' num2str(ar_fl_c_min(it_cur_param))]);
disp(['ar_fl_b_bd = ' num2str(ar_fl_b_bd(it_cur_param))]);
disp(['ar_fl_z_r_borr_poiss_mean = ' num2str(ar_fl_z_r_borr_poiss_mean(it_cur_param))]);
disp('xxxxxxxxxxxxxxxxxxxxxxxxxxx');
disp('xxxxxxxxxxxxxxxxxxxxxxxxxxx');
disp('');
disp('');
disp('');
disp('');
% Call Default Parameters <https://fanwangecon.github.io/CodeDynaAsset/m_az/paramfunc/html/ffs_abz_set_default_param.html ffs_abz_set_default_param>
bl_input_override = true;
it_param_set = 9;
[param_map, support_map] = ffs_abz_set_default_param(it_param_set);
% Borrowing Parameters
param_map('bl_default') = ar_bl_default(it_cur_param);
param_map('fl_c_min') = ar_fl_c_min(it_cur_param);
param_map('fl_b_bd') = ar_fl_b_bd(it_cur_param);
% Interest Rates
param_map('fl_z_r_borr_poiss_mean') = ar_fl_z_r_borr_poiss_mean(it_cur_param);
% Display Parameters
support_map('bl_display') = false;
support_map('bl_display_final') = false;
support_map('bl_time') = true;
support_map('bl_profile') = false;
support_map('bl_graph_funcgrids') = false;
for it_accuracy = 1:length(ar_it_a_n_hg)
% Accuracy Regular
param_map('it_a_n') = ar_it_a_n_hg(it_accuracy);
param_map('fl_z_r_borr_n') = ar_fl_z_r_borr_n_hg(it_accuracy);
it_z_n = param_map('it_z_wage_n') * param_map('fl_z_r_borr_n');
param_map('it_z_n') = it_z_n;
disp('xxxxxxxxxxxxxxxxxxxxxxxxxxx');
disp(['it_a_n = ' num2str(ar_it_a_n_hg(it_accuracy)) ', it_z_n = ' num2str(it_z_n)]);
disp('xxxxxxxxxxxxxxxxxxxxxxxxxxx');
% Call Grid Generator <https://fanwangecon.github.io/CodeDynaAsset/m_az/paramfunc/html/ffs_abz_get_funcgrid.html ffs_abz_get_funcgrid>
[armt_map, func_map] = ffs_abz_get_funcgrid(param_map, support_map, bl_input_override);
% Call Dynamic Programming Problem <https://fanwangecon.github.io/CodeDynaAsset/m_az/solve/html/ff_abz_vf_vecsv.html ff_abz_vf_vecsv>
result_map = ff_abz_vf_vecsv(param_map, support_map, armt_map, func_map);
% Call Distribution CProgram
result_map = ff_az_ds_vecsv(param_map, support_map, armt_map, func_map, result_map, bl_input_override);
end
% Snap
snapnow;
end
% close all
close all;
%% Test Minimum Consumption with Defaults, Vary Interest rate
% As borrowing interest rate increases, borrowing decreases
close all;
it_size = 10;
% default or not
bl_default = true;
ar_bl_default = zeros([1,it_size]) + bl_default;
% cmin
fl_c_min = 0.035;
ar_fl_c_min = zeros([1,it_size]) + fl_c_min;
% borrow bound
fl_b_bd = -12.5;
ar_fl_b_bd = zeros([1,it_size]) + fl_b_bd;
% fl_z_r_borr_poiss_mean
ar_fl_z_r_borr_poiss_mean = linspace(5, 20, it_size);
% Simulate Model with Discount = 0.85
for it_cur_param = 1:1:length(ar_bl_default)
disp('xxxxxxxxxxxxxxxxxxxxxxxxxxx');
disp('xxxxxxxxxxxxxxxxxxxxxxxxxxx');
disp(['ar_bl_default = ' num2str(ar_bl_default(it_cur_param))]);
disp(['ar_fl_c_min = ' num2str(ar_fl_c_min(it_cur_param))]);
disp(['ar_fl_b_bd = ' num2str(ar_fl_b_bd(it_cur_param))]);
disp(['ar_fl_z_r_borr_poiss_mean = ' num2str(ar_fl_z_r_borr_poiss_mean(it_cur_param))]);
disp('xxxxxxxxxxxxxxxxxxxxxxxxxxx');
disp('xxxxxxxxxxxxxxxxxxxxxxxxxxx');
disp('');
disp('');
disp('');
disp('');
% Call Default Parameters <https://fanwangecon.github.io/CodeDynaAsset/m_az/paramfunc/html/ffs_abz_set_default_param.html ffs_abz_set_default_param>
bl_input_override = true;
it_param_set = 9;
[param_map, support_map] = ffs_abz_set_default_param(it_param_set);
% Borrowing Parameters
param_map('bl_default') = ar_bl_default(it_cur_param);
param_map('fl_c_min') = ar_fl_c_min(it_cur_param);
param_map('fl_b_bd') = ar_fl_b_bd(it_cur_param);
% Interest Rates
param_map('fl_z_r_borr_poiss_mean') = ar_fl_z_r_borr_poiss_mean(it_cur_param);
% Display Parameters
support_map('bl_display') = false;
support_map('bl_display_final') = false;
support_map('bl_time') = true;
support_map('bl_profile') = false;
support_map('bl_graph_funcgrids') = false;
for it_accuracy = 1:length(ar_it_a_n_hg)
% Accuracy Regular
param_map('it_a_n') = ar_it_a_n_hg(it_accuracy);
param_map('fl_z_r_borr_n') = ar_fl_z_r_borr_n_hg(it_accuracy);
it_z_n = param_map('it_z_wage_n') * param_map('fl_z_r_borr_n');
param_map('it_z_n') = it_z_n;
disp('xxxxxxxxxxxxxxxxxxxxxxxxxxx');
disp(['it_a_n = ' num2str(ar_it_a_n_hg(it_accuracy)) ', it_z_n = ' num2str(it_z_n)]);
disp('xxxxxxxxxxxxxxxxxxxxxxxxxxx');
% Call Grid Generator <https://fanwangecon.github.io/CodeDynaAsset/m_az/paramfunc/html/ffs_abz_get_funcgrid.html ffs_abz_get_funcgrid>
[armt_map, func_map] = ffs_abz_get_funcgrid(param_map, support_map, bl_input_override);
% Call Dynamic Programming Problem <https://fanwangecon.github.io/CodeDynaAsset/m_az/solve/html/ff_abz_vf_vecsv.html ff_abz_vf_vecsv>
result_map = ff_abz_vf_vecsv(param_map, support_map, armt_map, func_map);
% Call Distribution CProgram
result_map = ff_az_ds_vecsv(param_map, support_map, armt_map, func_map, result_map, bl_input_override);
end
% Snap
snapnow;
end
% close all
close all;