Set Model Parameters (Risky + Safe Asset)
back to Fan's Dynamic Assets Repository Table of Content.
Contents
function [param_map, support_map] = ffs_akz_set_default_param(varargin)
FFS_AKZ_SET_DEFAULT_PARAM setting model default parameters
two groups of default parameters stored in container maps. Explicitly solving for both a and k grids exponentially increase problem size, and we can not have state and choice grids that are as tight as for the az problem. Note that the defaults set it_w_n to have a far more limited number of points. For each w, we allow for combinations of a and k choices. Before, each aggregate savings choice only had one a associated with it.
The biggest change from ffs_az_set_default_param is that now we have two asset choices. Previous we had the a grid for the cash-on-hand and z (az) model.
Now a is w. There was only one asset before, so a was total savings. Now w is total savings w = a' + k'. Define choice grid in terms of the total savings, rather than a and k grids separately. If we define a and k with min and max separately, we will have a choice combo max(a) + max(k), this corresponds to one very high level of aggregate savings, but we are implicitly only allowing for dividing a and k evenly when we choose this. Implicitly, the higher the aggregate savings, the more limited the a and k combinations becomes when we define a and k grids separately. Geometrically, With aprime as the x-axis and kprime as the y-axis of choices, we need to define choices in terms of diagnoals (triangles) rather than vertical and horizontal lines (rectangles). See this graphically at the end of this page: ffs_akz_get_funcgrid which shows the triangular choice grids.
With our triangular shape, with w_n total saving grid points, we will have : w_n*(w_n-1)/2 + w_n total grid of a and k jointly. Specifically, with the benchmark grid of w_n = 45 points, we have (45-1)*45/2 + 45 = 1035 total a and k joint grid points.
@param it_subset integer default parameter control subsetting. it_subset = 1 is basic invoke quick test. it_subset = 2 is main invoke. it_subset = 3 is profiling invoke. it_subset = 4 is matlab publish.
@param bl_display_defparam boolean local printing
@return param_map container parameters needed for solving the model
@return support_map container programming control parameters like to graph to print etc
@example
it_param_set = 1; [param_map, support_map] = ffs_akz_set_default_param(it_param_set);
Default
it_subset = 0; if (isempty(varargin)) bl_display_defparam = true; else bl_display_defparam = false; end default_params = {it_subset bl_display_defparam}; [default_params{1:length(varargin)}] = varargin{:}; [it_subset, bl_display_defparam] = default_params{:};
Setting param_map container
param_map = containers.Map('KeyType','char', 'ValueType','any'); % model name param_map('st_model') = 'akz_wkz_iwkz'; % Preferences param_map('fl_crra') = 1.5; param_map('fl_beta') = 0.94; % Production Function Productivity Shock Parameters param_map('it_z_n') = 15; param_map('fl_z_mu') = 0; param_map('fl_z_rho') = 0.8; param_map('fl_z_sig') = 0.2; % CD Production Function Parameters param_map('fl_Amean') = 1; param_map('fl_alpha') = 0.36; param_map('fl_delta') = 0.08; % Prices shock is on k, not on labor, fl_w is fixed wage income param_map('fl_w') = 1.28*0.3466; % min(z*w) from benchmark az model param_map('fl_r_save') = 0.025; param_map('fl_r_borr') = 0.025; % Minimum Consumption, utility lower bound. The cmin parameter and % fl_nan_replace parameter have no effects on value function, just for % resetting invalid choice grid values. fl_nan_replace reset invalid k % choice given w. fl_c_min resets invalid consumption levels due to w % choices that are invalid. But this is the case when fl_w > 0. param_map('fl_c_min') = 0.001; param_map('fl_nan_replace') = -9999; % Borrowing Related Parameters for AKBZ models the % <https://github.com/FanWangEcon/CodeDynaAsset/tree/master/m_akz m_akz> % models do not deal with default, % <https://github.com/FanWangEcon/CodeDynaAsset/tree/master/m_akbz m_akbz> % files do. param_map('fl_b_bd') = 0; % borrow bound, = 0 if save only param_map('fl_default_aprime') = 0; % if default, next period aprime param_map('bl_default') = 0; % if borrowing is default allowed % Assest Grids Toal savings aggregate grid (see discussion on top). 35 % points picked for % param_map('fl_w_min') = param_map('fl_b_bd'); % but b_bd overrides this param_map('fl_w_max') = 50; param_map('it_w_n') = 50; % Risky Capital Asset Vector see graph below for how it looks graphically % in principle keep it_k_n the same as it_w_n to have equi-distance points % in triangle choice grid. param_map('fl_k_min') = 0; % param_map('fl_k_max') = (param_map('fl_w_max') - param_map('fl_b_bd')); param_map('it_ak_n') = param_map('it_w_n'); % grid for a and k the same % Interpolation fl_coh_interp_grid_gap controls the number of coh points at % which to solve the model it_c_interp_grid_gap determines the gap between % consumption terpolation points. For consumption interpolation 10^-4 is % extremely accurate, there should be no perceptible differences in value % and policy functions when the it_c_interp_grid_gap <= 0.001 compared to % actual evaluation param_map('fl_coh_interp_grid_gap') = 0.1; % param_map('it_coh_interp_n') = 500; param_map('it_c_interp_grid_gap') = 10^-4; % Solution Accuracy param_map('it_maxiter_val') = 250; param_map('it_maxiter_dist') = 1000; param_map('st_analytical_stationary_type') = 'eigenvector'; param_map('fl_tol_val') = 10^-5; param_map('fl_tol_pol') = 10^-5; param_map('fl_tol_dist') = 10^-5; param_map('it_tol_pol_nochange') = 25; % number of iterations where policy does not change
Setting support_map container
support_map = containers.Map('KeyType','char', 'ValueType','any'); % root directory [st_root_path] = preamble(false); st_matimg_path_root = [st_root_path '/m_akz/']; support_map('st_matimg_path_root') = st_matimg_path_root; % timer support_map('bl_time') = true; % Print Controls support_map('bl_display_defparam') = false; support_map('bl_display') = true; support_map('bl_display_dist') = false; support_map('it_display_every') = 5; % how often to print results % Profile Controls support_map('bl_profile') = false; support_map('bl_profile_dist') = false; % distribution profile support_map('st_profile_path') = [st_matimg_path_root '/solve/profile/']; support_map('st_profile_prefix') = ['']; support_map('st_profile_name_main') = ['_default']; support_map('st_profile_suffix') = ['_p' num2str(it_subset)]; support_map('bl_post') = false; % Final Print support_map('bl_display_final') = false; % print finalized results support_map('bl_display_final_dist') = false; % print finalized results support_map('bl_display_final_dist_detail') = false; support_map('it_display_final_rowmax') = 100; % max row to print (states/iters) support_map('it_display_final_colmax') = 12; % max col to print (shocks) it_display_summmat_rowmax = 7; it_display_summmat_colmax = 7; support_map('it_display_summmat_rowmax') = it_display_summmat_rowmax; support_map('it_display_summmat_colmax') = it_display_summmat_colmax; % Mat File Controls support_map('bl_mat') = false; support_map('st_mat_path') = [st_matimg_path_root '/solve/mat/']; support_map('st_mat_prefix') = ['']; support_map('st_mat_name_main') = ['_default']; support_map('st_mat_suffix') = ['_p' num2str(it_subset)]; % Graphing Controls support_map('bl_graph') = false; support_map('bl_graph_onebyones') = true; support_map('bl_graph_val') = true; support_map('bl_graph_pol_lvl') = true; support_map('bl_graph_pol_pct') = true; support_map('bl_graph_coh_t_coh') = true; % Image Saving Controls (given graphing) support_map('st_title_prefix') = ''; support_map('bl_img_save') = false; support_map('st_img_path') = [st_matimg_path_root '/solve/img/']; support_map('st_img_prefix') = ['']; support_map('st_img_name_main') = ['_default']; support_map('st_img_suffix') = ['_p' num2str(it_subset) '.png']; % Sub-function graphing controls support_map('bl_graph_funcgrids') = false; support_map('bl_display_funcgrids') = false; support_map('bl_graph_evf') = false; support_map('bl_display_evf') = false;
Subset Options
- it_subset = 1 is basic invoke quick test
- it_subset = 2 is main invoke
- it_subset = 3 is profiling invoke
- it_subset = 4 is matlab publish.
if (ismember(it_subset, [1,2,3,4])) if (ismember(it_subset, [1])) % TEST quick param_map('it_w_n') = 20; param_map('it_k_n') = param_map('it_w_n'); param_map('it_z_n') = 3; param_map('it_maxiter_val') = 50; param_map('fl_coh_interp_grid_gap') = 0.25; param_map('it_c_interp_grid_gap') = 0.001; param_map('it_tol_pol_nochange') = 1000; support_map('bl_display') = true; support_map('it_display_every') = 1; end if (ismember(it_subset, [2, 4])) % close figures close all; % Main Run support_map('bl_time') = true; support_map('bl_display_defparam') = true; support_map('bl_display') = true; support_map('it_display_every') = 5; support_map('bl_post') = true; support_map('bl_display_final') = true; support_map('bl_mat') = false; support_map('bl_graph') = true; support_map('bl_graph_onebyones') = false; support_map('bl_img_save') = true; if (ismember(it_subset, [4])) support_map('bl_time') = false; support_map('bl_display') = false; support_map('bl_graph_onebyones') = true; support_map('bl_img_save') = false; end end if (ismember(it_subset, [3])) % Profile run support_map('bl_profile') = true; support_map('bl_display') = false; % don't print support_map('bl_time') = true; end end
Subset Options for Distribution solutions
- 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
if (ismember(it_subset, [5,6,7,8,9])) if (ismember(it_subset, [5])) % TEST quick (need to enough to have distribution) param_map('it_w_n') = 20; param_map('it_k_n') = param_map('it_w_n'); param_map('it_z_n') = 3; param_map('it_maxiter_val') = 50; param_map('fl_coh_interp_grid_gap') = 0.25; param_map('it_c_interp_grid_gap') = 0.001; param_map('it_tol_pol_nochange') = 1000; support_map('bl_display') = true; support_map('it_display_every') = 1; support_map('bl_display_dist') = true; end if (ismember(it_subset, [6, 8, 9])) % close all close all; % Main Run support_map('bl_time') = true; support_map('bl_display_defparam') = true; support_map('bl_display') = false; support_map('bl_display_dist') = true; support_map('it_display_every') = 20; support_map('bl_post') = true; support_map('bl_display_final_dist') = true; support_map('bl_mat') = false; support_map('bl_graph') = true; support_map('bl_graph_onebyones') = false; support_map('bl_img_save') = true; % do not generate all graphs when solving for distribution support_map('bl_graph_val') = false; support_map('bl_graph_pol_lvl') = false; support_map('bl_graph_pol_pct') = false; support_map('bl_graph_coh_t_coh') = true; if (ismember(it_subset, [8, 9])) support_map('bl_time') = false; support_map('bl_display') = false; support_map('bl_display_dist') = false; support_map('bl_display_final_dist_detail') = true; support_map('bl_graph_onebyones') = true; support_map('bl_img_save') = false; if (ismember(it_subset, [9])) % quietly turn off all graphs, only tables support_map('bl_display_final_dist_detail') = false; support_map('bl_display_defparam') = false; support_map('bl_graph_coh_t_coh') = false; end end end if (ismember(it_subset, [7])) % Profile run support_map('bl_profile_dist') = true; support_map('bl_display') = false; % don't print support_map('bl_display_dist') = false; % don't print support_map('bl_time') = true; end end
Display
if (bl_display_defparam) fft_container_map_display(param_map, it_display_summmat_rowmax, it_display_summmat_colmax); fft_container_map_display(support_map, it_display_summmat_rowmax, it_display_summmat_colmax); end
---------------------------------------- ---------------------------------------- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Begin: Show all key and value pairs from container CONTAINER NAME: PARAM_MAP ---------------------------------------- Map with properties: Count: 31 KeyType: char ValueType: any xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ---------------------------------------- ---------------------------------------- pos = 1 ; key = bl_default ; val = 0 pos = 2 ; key = fl_Amean ; val = 1 pos = 3 ; key = fl_alpha ; val = 0.36 pos = 4 ; key = fl_b_bd ; val = 0 pos = 5 ; key = fl_beta ; val = 0.94 pos = 6 ; key = fl_c_min ; val = 0.001 pos = 7 ; key = fl_coh_interp_grid_gap ; val = 0.1 pos = 8 ; key = fl_crra ; val = 1.5 pos = 9 ; key = fl_default_aprime ; val = 0 pos = 10 ; key = fl_delta ; val = 0.08 pos = 11 ; key = fl_k_min ; val = 0 pos = 12 ; key = fl_nan_replace ; val = -9999 pos = 13 ; key = fl_r_borr ; val = 0.025 pos = 14 ; key = fl_r_save ; val = 0.025 pos = 15 ; key = fl_tol_dist ; val = 1e-05 pos = 16 ; key = fl_tol_pol ; val = 1e-05 pos = 17 ; key = fl_tol_val ; val = 1e-05 pos = 18 ; key = fl_w ; val = 0.44365 pos = 19 ; key = fl_w_max ; val = 50 pos = 20 ; key = fl_z_mu ; val = 0 pos = 21 ; key = fl_z_rho ; val = 0.8 pos = 22 ; key = fl_z_sig ; val = 0.2 pos = 23 ; key = it_ak_n ; val = 50 pos = 24 ; key = it_c_interp_grid_gap ; val = 0.0001 pos = 25 ; key = it_maxiter_dist ; val = 1000 pos = 26 ; key = it_maxiter_val ; val = 250 pos = 27 ; key = it_tol_pol_nochange ; val = 25 pos = 28 ; key = it_w_n ; val = 50 pos = 29 ; key = it_z_n ; val = 15 pos = 30 ; key = st_analytical_stationary_type ; val = eigenvector pos = 31 ; key = st_model ; val = akz_wkz_iwkz ---------------------------------------- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Scalars in Container and Sizes and Basic Statistics xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx i idx value __ ___ _______ bl_default 1 1 0 fl_Amean 2 2 1 fl_alpha 3 3 0.36 fl_b_bd 4 4 0 fl_beta 5 5 0.94 fl_c_min 6 6 0.001 fl_coh_interp_grid_gap 7 7 0.1 fl_crra 8 8 1.5 fl_default_aprime 9 9 0 fl_delta 10 10 0.08 fl_k_min 11 11 0 fl_nan_replace 12 12 -9999 fl_r_borr 13 13 0.025 fl_r_save 14 14 0.025 fl_tol_dist 15 15 1e-05 fl_tol_pol 16 16 1e-05 fl_tol_val 17 17 1e-05 fl_w 18 18 0.44365 fl_w_max 19 19 50 fl_z_mu 20 20 0 fl_z_rho 21 21 0.8 fl_z_sig 22 22 0.2 it_ak_n 23 23 50 it_c_interp_grid_gap 24 24 0.0001 it_maxiter_dist 25 25 1000 it_maxiter_val 26 26 250 it_tol_pol_nochange 27 27 25 it_w_n 28 28 50 it_z_n 29 29 15 ---------------------------------------- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Strings in Container and Sizes and Basic Statistics xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx i idx _ ___ st_analytical_stationary_type 1 30 st_model 2 31 ---------------------------------------- ---------------------------------------- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Begin: Show all key and value pairs from container CONTAINER NAME: SUPPORT_MAP ---------------------------------------- Map with properties: Count: 41 KeyType: char ValueType: any xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ---------------------------------------- ---------------------------------------- pos = 1 ; key = bl_display ; val = true pos = 2 ; key = bl_display_defparam ; val = false pos = 3 ; key = bl_display_dist ; val = false pos = 4 ; key = bl_display_evf ; val = false pos = 5 ; key = bl_display_final ; val = false pos = 6 ; key = bl_display_final_dist ; val = false pos = 7 ; key = bl_display_final_dist_detail ; val = false pos = 8 ; key = bl_display_funcgrids ; val = false pos = 9 ; key = bl_graph ; val = false pos = 10 ; key = bl_graph_coh_t_coh ; val = true pos = 11 ; key = bl_graph_evf ; val = false pos = 12 ; key = bl_graph_funcgrids ; val = false pos = 13 ; key = bl_graph_onebyones ; val = true pos = 14 ; key = bl_graph_pol_lvl ; val = true pos = 15 ; key = bl_graph_pol_pct ; val = true pos = 16 ; key = bl_graph_val ; val = true pos = 17 ; key = bl_img_save ; val = false pos = 18 ; key = bl_mat ; val = false pos = 19 ; key = bl_post ; val = false pos = 20 ; key = bl_profile ; val = false pos = 21 ; key = bl_profile_dist ; val = false pos = 22 ; key = bl_time ; val = true pos = 23 ; key = it_display_every ; val = 5 pos = 24 ; key = it_display_final_colmax ; val = 12 pos = 25 ; key = it_display_final_rowmax ; val = 100 pos = 26 ; key = it_display_summmat_colmax ; val = 7 pos = 27 ; key = it_display_summmat_rowmax ; val = 7 pos = 28 ; key = st_img_name_main ; val = _default pos = 29 ; key = st_img_path ; val = C:/Users/fan/CodeDynaAsset//m_akz//solve/img/ pos = 30 ; key = st_img_prefix ; val = pos = 31 ; key = st_img_suffix ; val = _p0.png pos = 32 ; key = st_mat_name_main ; val = _default pos = 33 ; key = st_mat_path ; val = C:/Users/fan/CodeDynaAsset//m_akz//solve/mat/ pos = 34 ; key = st_mat_prefix ; val = pos = 35 ; key = st_mat_suffix ; val = _p0 pos = 36 ; key = st_matimg_path_root ; val = C:/Users/fan/CodeDynaAsset//m_akz/ pos = 37 ; key = st_profile_name_main ; val = _default pos = 38 ; key = st_profile_path ; val = C:/Users/fan/CodeDynaAsset//m_akz//solve/profile/ pos = 39 ; key = st_profile_prefix ; val = pos = 40 ; key = st_profile_suffix ; val = _p0 pos = 41 ; key = st_title_prefix ; val = ---------------------------------------- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Scalars in Container and Sizes and Basic Statistics xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx i idx value __ ___ _____ bl_display 1 1 1 bl_display_defparam 2 2 0 bl_display_dist 3 3 0 bl_display_evf 4 4 0 bl_display_final 5 5 0 bl_display_final_dist 6 6 0 bl_display_final_dist_detail 7 7 0 bl_display_funcgrids 8 8 0 bl_graph 9 9 0 bl_graph_coh_t_coh 10 10 1 bl_graph_evf 11 11 0 bl_graph_funcgrids 12 12 0 bl_graph_onebyones 13 13 1 bl_graph_pol_lvl 14 14 1 bl_graph_pol_pct 15 15 1 bl_graph_val 16 16 1 bl_img_save 17 17 0 bl_mat 18 18 0 bl_post 19 19 0 bl_profile 20 20 0 bl_profile_dist 21 21 0 bl_time 22 22 1 it_display_every 23 23 5 it_display_final_colmax 24 24 12 it_display_final_rowmax 25 25 100 it_display_summmat_colmax 26 26 7 it_display_summmat_rowmax 27 27 7 ---------------------------------------- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Strings in Container and Sizes and Basic Statistics xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx i idx __ ___ st_img_name_main 1 28 st_img_path 2 29 st_img_prefix 3 30 st_img_suffix 4 31 st_mat_name_main 5 32 st_mat_path 6 33 st_mat_prefix 7 34 st_mat_suffix 8 35 st_matimg_path_root 9 36 st_profile_name_main 10 37 st_profile_path 11 38 st_profile_prefix 12 39 st_profile_suffix 13 40 st_title_prefix 14 41
end
ans = Map with properties: Count: 31 KeyType: char ValueType: any