-
Notifications
You must be signed in to change notification settings - Fork 12
/
ff_abzr_fibs_ds_wrapper.m
127 lines (100 loc) · 4.13 KB
/
ff_abzr_fibs_ds_wrapper.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
%% Derive Distributions for For+Inf+Borr+Save+RShock One Asset (Wrapper)
% *back to <https://fanwangecon.github.io Fan>'s
% <https://fanwangecon.github.io/CodeDynaAsset/ Dynamic Assets Repository>
% Table of Content.*
%%
function [result_map] = ff_abzr_fibs_ds_wrapper(varargin)
%% FF_abzr_fibs_FIBS_DS_WRAPPER finds the stationary asset distributions
% This is a warpper function. Note that _abzr_ and _abzr_fibs_ will not
% produce the same results even when formal and informal borrowing rates
% are the same, because they are solved differently, one where asset is
% principles only, and the other where asset has both principles as well as
% interest rates.
%% Default
% # it_subset = 5 is basic invoke quick test
% # it_subset = 6 is invoke full test
% # it_subset = 7 is profiling invoke
% # it_subset = 8 is matlab publish
% # it_subset = 9 is invoke operational (only final stats) and coh graph
it_param_set = 8;
bl_input_override = true;
[param_map, support_map] = ffs_abzr_fibs_set_default_param(it_param_set);
% Note: param_map and support_map can be adjusted here or outside to override defaults
% param_map('it_a_n') = 750;
% param_map('it_z_n') = 15;
% param_map('fl_r_fsv') = 0.025;
% param_map('fl_r_fbr') = 0.065;
% param_map('fl_z_r_borr_poiss_mean') = 5;
% param_map('fl_c_min') = 0.02;
% param_map('st_analytical_stationary_type') = 'loop';
% param_map('st_analytical_stationary_type') = 'vector';
param_map('st_analytical_stationary_type') = 'eigenvector';
% get armt and func map
[armt_map, func_map] = ffs_abzr_fibs_get_funcgrid(param_map, support_map, bl_input_override); % 1 for override
default_params = {param_map support_map armt_map func_map};
%% Parse Parameters 1
% if varargin only has param_map and support_map,
params_len = length(varargin);
[default_params{1:params_len}] = varargin{:};
param_map = [param_map; default_params{1}];
support_map = [support_map; default_params{2}];
if params_len >= 1 && params_len <= 2
% If override param_map, re-generate armt and func if they are not
% provided
bl_input_override = true;
[armt_map, func_map] = ffs_abzr_fibs_get_funcgrid(param_map, support_map, bl_input_override);
else
% Override all
armt_map = [armt_map; default_params{3}];
func_map = [func_map; default_params{4}];
end
% if profile, profile DP + Dist here
support_map('bl_profile_dist') = false;
% append function name
st_func_name = 'ff_abzr_fibs_ds_wrapper';
support_map('st_profile_name_main') = [st_func_name support_map('st_profile_name_main')];
support_map('st_mat_name_main') = [st_func_name support_map('st_mat_name_main')];
support_map('st_img_name_main') = [st_func_name support_map('st_img_name_main')];
%% Parse Parameters
% param_map
params_group = values(param_map, {'st_analytical_stationary_type'});
[st_analytical_stationary_type] = params_group{:};
% support_map
params_group = values(support_map, ...
{'st_profile_path', 'st_profile_prefix', 'st_profile_name_main', 'st_profile_suffix','bl_time'});
[st_profile_path, st_profile_prefix, st_profile_name_main, st_profile_suffix, bl_time] = params_group{:};
%% Start Profiler and Timer
% Start Profile
if (it_param_set == 7)
close all;
profile off;
profile on;
end
% Start Timer
if (bl_time)
tic;
end
%% Solve DP
bl_input_override = true;
result_map = ff_abzr_fibs_vf_vecsv(param_map, support_map, armt_map, func_map);
%% Derive Distribution
if (strcmp(st_analytical_stationary_type, 'loop'))
result_map = ff_az_ds(param_map, support_map, armt_map, func_map, result_map, bl_input_override);
elseif (strcmp(st_analytical_stationary_type, 'vector'))
result_map = ff_az_ds_vec(param_map, support_map, armt_map, func_map, result_map, bl_input_override);
elseif (strcmp(st_analytical_stationary_type, 'eigenvector'))
result_map = ff_az_ds_vecsv(param_map, support_map, armt_map, func_map, result_map, bl_input_override);
end
%% End Profiler and Timer
% End Timer
if (bl_time)
toc;
end
% End Profile
if (it_param_set == 7)
profile off
profile viewer
st_file_name = [st_profile_prefix st_profile_name_main st_profile_suffix];
profsave(profile('info'), strcat(st_profile_path, st_file_name));
end
end