Set Model Parameters (ABZR FIBS)

back to Fan's Dynamic Assets Repository Table of Content.

Contents

function [param_map, support_map] = ffs_abzr_fibs_set_default_param(varargin)

FFS_ABZ_FIBS_SET_DEFAULT_PARAM setting model default parameters

two groups of default parameters stored in container maps

@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_abzr_fibs_set_default_param(it_param_set);

@seealso

Default

if (isempty(varargin))
    bl_display_defparam = true;
else
    bl_display_defparam = false;
end

it_subset = 0;
default_params = {it_subset bl_display_defparam};
[default_params{1:length(varargin)}] = varargin{:};
[it_subset, bl_display_defparam] = default_params{:};

1. Initiate Param_map

param_map = containers.Map('KeyType','char', 'ValueType','any');

% model name
param_map('st_model') = 'abzr_fibs';

% Preferences
param_map('fl_crra') = 1.5;
param_map('fl_beta') = 0.94;
param_map('fl_nan_replace') = -99999;

2a. Set Borrowing Control Parameters

% Borrowing
% fl_default_aprime is the next period asset level
% households face if they default.
param_map('fl_b_bd') = -20; % borrow bound, = 0 if save only
param_map('fl_default_aprime') = 0;

% Borrowing Setting 1: Default Allowed, Bridge True, bl_rollover does not matter
% Borrowing Setting 2: Default Allowed, Bridge False, bl_rollover matter
param_map('bl_default') = true; % if borrowing is default allowed
param_map('bl_bridge') = true;
param_map('bl_rollover') = true;

% is save/borr choice principle or principle + interest, matters for
% borrowing grid generation program. the *abzr* problem is written with
% asset choice as principle only, the _abzr_fibs_ problems are written as
% priniple + interest as the state, so there this should be false.
param_map('bl_b_is_principle') = false;

% Minimum Consumption, c_min is for default, when c < 0, replace utility
% with fl_nan_replace.
param_map('fl_c_min') = 0.02;

2b. Set Asset Grid Parameters

see ffs_abzr_gen_borrsave_grid for how these borrowing/saving grid parameters will be used.

% Savings
param_map('fl_a_min') = 0; % if there is minimum savings requirement
param_map('fl_a_max') = 50;
param_map('bl_loglin') = false; % log lin threshold structure
param_map('fl_loglin_threshold') = 1; % dense points before 1
param_map('it_a_n') = 750;

% Prices
param_map('fl_w') = 1.28;

3. Set Interest Rates non-Shock Parameters

% formal informal parameters
% fl_for_br_block are the formal borrowing grid block sizes.
param_map('fl_r_fsv') = 0.025;
param_map('fl_r_fbr') = 0.065;
% see: ffs_for_br_block.m
param_map('st_forbrblk_type') = 'seg3';
param_map('fl_forbrblk_brmost') = -19;
param_map('fl_forbrblk_brleast') = -1;
param_map('fl_forbrblk_gap') = -1.5;

4a. Set Shock 1 Borrowing Interest Rate Parameters

See fft_gen_discrete_var for how these parameters will be used to generate a discrete random variable for the interest rate. And also various formal and informal files.

% Borrowing Interest rate
param_map('st_z_r_infbr_drv_ele_type') = 'unif';
param_map('st_z_r_infbr_drv_prb_type') = 'poiss';
param_map('fl_z_r_infbr_poiss_mean') = 20;
param_map('fl_z_r_infbr_max') = 0.095;
param_map('fl_z_r_infbr_min') = 0.025;
param_map('fl_z_r_infbr_n') = 5;
% param_map('fl_z_r_infbr_max') = 0.095;
% param_map('fl_z_r_infbr_min') = 0.095;
% param_map('fl_z_r_infbr_n') = 1;

4b. Set Shock 2 Wage Shock Parameters

See ffto_gen_tauchen_jhl for standard implementation of ar1 shock process using these parameters.

% Shock Parameters
param_map('it_z_wage_n') = 15;
param_map('fl_z_wage_mu') = 0;
param_map('fl_z_wage_rho') = 0.8;
param_map('fl_z_wage_sig') = 0.2;

4c. Set Overall Shock Grid Count

param_map('it_z_n') = param_map('it_z_wage_n') * param_map('fl_z_r_infbr_n');

5. Set Solution Control Parameters

% Solution Accuracy
param_map('it_maxiter_val') = 1000;
param_map('it_maxiter_dist') = 1000;
param_map('it_trans_power_dist') = 1000;
param_map('st_analytical_stationary_type') = 'eigenvector'; % could be eigenvector, projection, power
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

6. 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_fibs/'];
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 '/m_abzr_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; % print finalized results
support_map('it_display_final_rowmax') = 100; % max row to print (states/iters)
support_map('it_display_final_colmax') = 15; % max col to print (shocks)
% Mat File Controls
support_map('bl_mat') = false;
support_map('st_mat_path') = [st_matimg_path_root '/m_abzr_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;
support_map('bl_graph_discrete') = true;
% Formal Informal Specific Graphs
support_map('bl_graph_forinf_discrete') = true;
support_map('bl_graph_forinf_pol_lvl') = true;
support_map('bl_graph_forinf_pol_pct') = 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 '/m_abzr_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_display_minccost') = false;
support_map('bl_display_infbridge') = false;

Subset Options

  1. it_subset = 1 is basic invoke quick test
  2. it_subset = 2 is main invoke
  3. it_subset = 3 is profiling invoke
  4. it_subset = 4 is matlab publish.
% close figures
close all;

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;

elseif (ismember(it_subset, [1,2,4]))

    % 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, [1]))

        % TEST quick
        param_map('it_a_n') = 25;

        param_map('it_z_wage_n') = 3;
        param_map('fl_z_r_infbr_n') = 2;
        param_map('it_z_n') = param_map('it_z_wage_n') * param_map('fl_z_r_infbr_n');

        param_map('it_maxiter_val') = 50;
        support_map('it_display_every') = 1;

        support_map('bl_graph') = false;

    end

    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

Subset Options for Distribution solutions

  1. it_subset = 5 is basic invoke quick test
  2. it_subset = 6 is invoke full test
  3. it_subset = 7 is profiling invoke
  4. it_subset = 8 is matlab publish
  5. it_subset = 9 is invoke operational (only final stats) and coh graph
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;

elseif (ismember(it_subset, [5,6,8,9]))

    % 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;
    support_map('bl_graph_forinf_discrete') = false;
    support_map('bl_graph_forinf_pol_lvl') = false;
    support_map('bl_graph_forinf_pol_pct') = true;

    if (ismember(it_subset, [5]))

        % TEST quick (need to enough to have distribution)
        param_map('it_a_n') = 100;

        param_map('it_z_wage_n') = 5;
        param_map('fl_z_r_infbr_n') = 2;
        param_map('it_z_n') = param_map('it_z_wage_n') * param_map('fl_z_r_infbr_n');

        param_map('it_maxiter_val') = 50;
        param_map('it_maxiter_dist') = 50;

        support_map('bl_display_dist') = true;
        support_map('bl_graph') = false;

    end

    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]))
            support_map('bl_display_final_dist_detail') = false;
            support_map('bl_display_defparam') = false;
            support_map('bl_graph_coh_t_coh') = false;
            support_map('bl_graph_forinf_pol_pct') = false;
        end

    end
end

Display

if (bl_display_defparam)
    fft_container_map_display(param_map);
    fft_container_map_display(support_map);
end
----------------------------------------
----------------------------------------
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Begin: Show all key and value pairs from container
CONTAINER NAME: PARAM_MAP
----------------------------------------
  Map with properties:

        Count: 42
      KeyType: char
    ValueType: any

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
----------------------------------------
----------------------------------------
pos = 1 ; key = bl_b_is_principle ; val = false
pos = 2 ; key = bl_bridge ; val = true
pos = 3 ; key = bl_default ; val = true
pos = 4 ; key = bl_loglin ; val = false
pos = 5 ; key = bl_rollover ; val = true
pos = 6 ; key = fl_a_max ; val = 50
pos = 7 ; key = fl_a_min ; val = 0
pos = 8 ; key = fl_b_bd ; val = -20
pos = 9 ; key = fl_beta ; val = 0.94
pos = 10 ; key = fl_c_min ; val = 0.02
pos = 11 ; key = fl_crra ; val = 1.5
pos = 12 ; key = fl_default_aprime ; val = 0
pos = 13 ; key = fl_forbrblk_brleast ; val = -1
pos = 14 ; key = fl_forbrblk_brmost ; val = -19
pos = 15 ; key = fl_forbrblk_gap ; val = -1.5
pos = 16 ; key = fl_loglin_threshold ; val = 1
pos = 17 ; key = fl_nan_replace ; val = -99999
pos = 18 ; key = fl_r_fbr ; val = 0.065
pos = 19 ; key = fl_r_fsv ; val = 0.025
pos = 20 ; key = fl_tol_dist ; val = 1e-05
pos = 21 ; key = fl_tol_pol ; val = 1e-05
pos = 22 ; key = fl_tol_val ; val = 1e-05
pos = 23 ; key = fl_w ; val = 1.28
pos = 24 ; key = fl_z_r_infbr_max ; val = 0.095
pos = 25 ; key = fl_z_r_infbr_min ; val = 0.025
pos = 26 ; key = fl_z_r_infbr_n ; val = 5
pos = 27 ; key = fl_z_r_infbr_poiss_mean ; val = 20
pos = 28 ; key = fl_z_wage_mu ; val = 0
pos = 29 ; key = fl_z_wage_rho ; val = 0.8
pos = 30 ; key = fl_z_wage_sig ; val = 0.2
pos = 31 ; key = it_a_n ; val = 750
pos = 32 ; key = it_maxiter_dist ; val = 1000
pos = 33 ; key = it_maxiter_val ; val = 1000
pos = 34 ; key = it_tol_pol_nochange ; val = 25
pos = 35 ; key = it_trans_power_dist ; val = 1000
pos = 36 ; key = it_z_n ; val = 75
pos = 37 ; key = it_z_wage_n ; val = 15
pos = 38 ; key = st_analytical_stationary_type ; val = eigenvector
pos = 39 ; key = st_forbrblk_type ; val = seg3
pos = 40 ; key = st_model ; val = abzr_fibs
pos = 41 ; key = st_z_r_infbr_drv_ele_type ; val = unif
pos = 42 ; key = st_z_r_infbr_drv_prb_type ; val = poiss
----------------------------------------
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Scalars in Container and Sizes and Basic Statistics
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                               i     idx    value 
                               __    ___    ______

    bl_b_is_principle           1     1          0
    bl_bridge                   2     2          1
    bl_default                  3     3          1
    bl_loglin                   4     4          0
    bl_rollover                 5     5          1
    fl_a_max                    6     6         50
    fl_a_min                    7     7          0
    fl_b_bd                     8     8        -20
    fl_beta                     9     9       0.94
    fl_c_min                   10    10       0.02
    fl_crra                    11    11        1.5
    fl_default_aprime          12    12          0
    fl_forbrblk_brleast        13    13         -1
    fl_forbrblk_brmost         14    14        -19
    fl_forbrblk_gap            15    15       -1.5
    fl_loglin_threshold        16    16          1
    fl_nan_replace             17    17     -99999
    fl_r_fbr                   18    18      0.065
    fl_r_fsv                   19    19      0.025
    fl_tol_dist                20    20      1e-05
    fl_tol_pol                 21    21      1e-05
    fl_tol_val                 22    22      1e-05
    fl_w                       23    23       1.28
    fl_z_r_infbr_max           24    24      0.095
    fl_z_r_infbr_min           25    25      0.025
    fl_z_r_infbr_n             26    26          5
    fl_z_r_infbr_poiss_mean    27    27         20
    fl_z_wage_mu               28    28          0
    fl_z_wage_rho              29    29        0.8
    fl_z_wage_sig              30    30        0.2
    it_a_n                     31    31        750
    it_maxiter_dist            32    32       1000
    it_maxiter_val             33    33       1000
    it_tol_pol_nochange        34    34         25
    it_trans_power_dist        35    35       1000
    it_z_n                     36    36         75
    it_z_wage_n                37    37         15

----------------------------------------
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Strings in Container and Sizes and Basic Statistics
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                                     i    idx
                                     _    ___

    st_analytical_stationary_type    1    38 
    st_forbrblk_type                 2    39 
    st_model                         3    40 
    st_z_r_infbr_drv_ele_type        4    41 
    st_z_r_infbr_drv_prb_type        5    42 

----------------------------------------
----------------------------------------
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Begin: Show all key and value pairs from container
CONTAINER NAME: SUPPORT_MAP
----------------------------------------
  Map with properties:

        Count: 43
      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_final ; val = false
pos = 5 ; key = bl_display_final_dist ; val = false
pos = 6 ; key = bl_display_final_dist_detail ; val = false
pos = 7 ; key = bl_display_funcgrids ; val = false
pos = 8 ; key = bl_display_infbridge ; val = false
pos = 9 ; key = bl_display_minccost ; val = false
pos = 10 ; key = bl_graph ; val = false
pos = 11 ; key = bl_graph_coh_t_coh ; val = true
pos = 12 ; key = bl_graph_discrete ; val = true
pos = 13 ; key = bl_graph_forinf_discrete ; val = true
pos = 14 ; key = bl_graph_forinf_pol_lvl ; val = true
pos = 15 ; key = bl_graph_forinf_pol_pct ; val = true
pos = 16 ; key = bl_graph_funcgrids ; val = false
pos = 17 ; key = bl_graph_onebyones ; val = true
pos = 18 ; key = bl_graph_pol_lvl ; val = true
pos = 19 ; key = bl_graph_pol_pct ; val = true
pos = 20 ; key = bl_graph_val ; val = true
pos = 21 ; key = bl_img_save ; val = false
pos = 22 ; key = bl_mat ; val = false
pos = 23 ; key = bl_post ; val = false
pos = 24 ; key = bl_profile ; val = false
pos = 25 ; key = bl_profile_dist ; val = false
pos = 26 ; key = bl_time ; val = true
pos = 27 ; key = it_display_every ; val = 5
pos = 28 ; key = it_display_final_colmax ; val = 15
pos = 29 ; key = it_display_final_rowmax ; val = 100
pos = 30 ; key = st_img_name_main ; val = _default
pos = 31 ; key = st_img_path ; val = C:/Users/fan/CodeDynaAsset//m_fibs//m_abzr_solve/img/
pos = 32 ; key = st_img_prefix ; val = 
pos = 33 ; key = st_img_suffix ; val = _p0.png
pos = 34 ; key = st_mat_name_main ; val = _default
pos = 35 ; key = st_mat_path ; val = C:/Users/fan/CodeDynaAsset//m_fibs//m_abzr_solve/mat/
pos = 36 ; key = st_mat_prefix ; val = 
pos = 37 ; key = st_mat_suffix ; val = _p0
pos = 38 ; key = st_matimg_path_root ; val = C:/Users/fan/CodeDynaAsset//m_fibs/
pos = 39 ; key = st_profile_name_main ; val = _default
pos = 40 ; key = st_profile_path ; val = C:/Users/fan/CodeDynaAsset//m_fibs//m_abzr_solve/profile/
pos = 41 ; key = st_profile_prefix ; val = 
pos = 42 ; key = st_profile_suffix ; val = _p0
pos = 43 ; 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_final                 4     4        0 
    bl_display_final_dist            5     5        0 
    bl_display_final_dist_detail     6     6        0 
    bl_display_funcgrids             7     7        0 
    bl_display_infbridge             8     8        0 
    bl_display_minccost              9     9        0 
    bl_graph                        10    10        0 
    bl_graph_coh_t_coh              11    11        1 
    bl_graph_discrete               12    12        1 
    bl_graph_forinf_discrete        13    13        1 
    bl_graph_forinf_pol_lvl         14    14        1 
    bl_graph_forinf_pol_pct         15    15        1 
    bl_graph_funcgrids              16    16        0 
    bl_graph_onebyones              17    17        1 
    bl_graph_pol_lvl                18    18        1 
    bl_graph_pol_pct                19    19        1 
    bl_graph_val                    20    20        1 
    bl_img_save                     21    21        0 
    bl_mat                          22    22        0 
    bl_post                         23    23        0 
    bl_profile                      24    24        0 
    bl_profile_dist                 25    25        0 
    bl_time                         26    26        1 
    it_display_every                27    27        5 
    it_display_final_colmax         28    28       15 
    it_display_final_rowmax         29    29      100 

----------------------------------------
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Strings in Container and Sizes and Basic Statistics
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                            i     idx
                            __    ___

    st_img_name_main         1    30 
    st_img_path              2    31 
    st_img_prefix            3    32 
    st_img_suffix            4    33 
    st_mat_name_main         5    34 
    st_mat_path              6    35 
    st_mat_prefix            7    36 
    st_mat_suffix            8    37 
    st_matimg_path_root      9    38 
    st_profile_name_main    10    39 
    st_profile_path         11    40 
    st_profile_prefix       12    41 
    st_profile_suffix       13    42 
    st_title_prefix         14    43 

end
ans = 

  Map with properties:

        Count: 42
      KeyType: char
    ValueType: any