This is a static copy of a profile report

Home

Function details for ffs_for_br_block_genThis is a static copy of a profile report

Home

ffs_for_br_block_gen (Calls: 75, Time: 0.024 s)
Generated 14-Jul-2019 00:14:42 using performance time.
function in file C:\Users\fan\CodeDynaAsset\m_fibs\paramfunc_fibs\ffs_for_br_block_gen.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
ffs_for_br_block_matchfunction75
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
127
ar_forbrblk = sort(unique([ar_...
750.012 s52.2%
68
[st_forbrblk_type, fl_forbrblk...
750.003 s12.9%
76
[default_params{1:length(varar...
750.002 s6.8%
77
[fl_r_fbr, st_forbrblk_type, f...
750.001 s5.0%
71
bl_display_forbrblock};
750.001 s3.0%
All other lines  0.005 s20.1%
Totals  0.024 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
uniquefunction750.011 s46.5%
dealfunction750.001 s5.1%
Self time (built-ins, overhead, etc.)  0.012 s48.4%
Totals  0.024 s100% 
Code Analyzer results
Line numberMessage
117The value assigned to variable 'ar_seg3' might be unused.
127Use of brackets [] is unnecessary. Use parentheses to group, if needed.
Coverage results
Show coverage for parent directory
Total lines in function133
Non-code lines (comments, blank lines)96
Code lines (lines that can run)37
Code lines that did run23
Code lines that did not run14
Coverage (did run/can run)62.16 %
Function listing
time 
Calls 
 line
   7 
function [ar_forbrblk, ar_forbrblk_r] = ffs_for_br_block_gen(varargin)
   8 
%% FFS_FOR_BR_BLOCK_GEN formal borrowing blocks
   9 
% Grid of formal borrowing points with associated interest rates. Policies
  10 
% could shift this. This function could be invoked to generate multiple
  11 
% formal borrowing grids from multiple formal borrowing providers, and the
  12 
% overall formal borrowing choice set is a combination of these grids. 
  13 
%
  14 
% @param fl_r_fbr boolean single formal borrowing interest rate
  15 
%
  16 
% @param st_forbrblk_type string different formal borrowing grid
  17 
% structures, some for testing/illustration purposes. Estimation uses real
  18 
% observed blocks from data.
  19 
%
  20 
% @param st_forbrblk_type string different formal borrowing grid
  21 
% structures, some for testing/illustration purposes. Estimation uses real
  22 
% observed blocks from data.
  23 
%
  24 
% # *unif*: uniform grid equal gap from min to
  25 
% # *seg3*: three segment blocks, the first 1/3 gap of the third segement,
  26 
% respect min and max from fl_forbrblk_brmost and fl_forbrblk_brleast,
  27 
% smallest borrowing segment gap is fl_forbrblk_gap
  28 
%
  29 
% @param fl_forbrblk_brmost float maximum formal borrowing allowed on grid,
  30 
% , might not not be relevant for all _st_forbrblk_type_
  31 
%
  32 
% @param fl_forbrblk_brleast float minimum formal borrowing allowed on
  33 
% grid, might not be relevant for all _st_forbrblk_type_
  34 
%
  35 
% @param fl_forbrblk_gap float formal borrowing grid gap, means different
  36 
% things for different _st_forbrblk_type_
  37 
%
  38 
% @return ar_forbrblk array array of formal borrowing grid points. should
  39 
% be ordered from lowest to highest including zero at the top. i.e.: [-4,
  40 
% -2, -1, 0]. These are assumed to be in principles units always.
  41 
% PRINCIPLES only, do not include interest rates.
  42 
%
  43 
% @return ar_forbrblk_r array interest rates associated with equal-length
  44 
% _ar_forbrblk_. ar_forbrblk_r multiplied element-wise with ar_forbrblk
  45 
% will provide the principle + interest rates associated with each formal
  46 
% borrowing grid elements. 
  47 
%
  48 
% @example
  49 
%
  50 
%   [ar_forbrblk, ar_forbrblk_r] = ...
  51 
%        ffs_for_br_block_gen(fl_r_fbr, st_forbrblk_type, fl_forbrblk_brmost, fl_forbrblk_brleast, fl_forbrblk_gap);
  52 
%
  53 
% @seealso
  54 
%
  55 
% * Formal Borrowing Grid: <https://fanwangecon.github.io/CodeDynaAsset/m_fibs/paramfunc_fibs/html/ffs_for_br_block_gen.html ffs_for_br_block_gen>
  56 
% * Informal Interest Rates: <https://fanwangecon.github.io/CodeDynaAsset/m_fibs/paramfunc_fibs/html/ffs_r_inf.html ffs_r_inf>
  57 
% * Match Borrowing to Formal Grid: <https://fanwangecon.github.io/CodeDynaAsset/m_fibs/paramfunc_fibs/html/ffs_for_br_block_match.html ffs_for_br_block_match>
  58 
% * Optimize Formal and Informal, Borrowing and Savings Joint Choices: <https://fanwangecon.github.io/CodeDynaAsset/m_fibs/paramfunc_fibs/html/ffs_fibs_min_c_cost.html ffs_fibs_min_c_cost>
  59 
% * Bridge Loan: <https://fanwangecon.github.io/CodeDynaAsset/m_fibs/paramfunc_fibs/html/ffs_fibs_inf_bridge.html ffs_fibs_inf_bridge>
  60 
% * Overall Optimization: <https://fanwangecon.github.io/CodeDynaAsset/m_fibs/paramfunc_fibs/html/ffs_fibs_min_c_cost_bridge.html ffs_fibs_min_c_cost_bridge>
  61 
% * Discrete Choices: <https://fanwangecon.github.io/CodeDynaAsset/m_fibs/paramfunc_fibs/html/ffs_fibs_identify_discrete.html ffs_fibs_identify_discrete>
  62 
%
  63 

  64 

  65 
%% Default
  66 

< 0.001 
     75 
  67
fl_r_fbr = 0.045; 
  0.003 
     75 
  68
[st_forbrblk_type, fl_forbrblk_brmost, fl_forbrblk_brleast, fl_forbrblk_gap] = deal('seg3', -19, -1, -1.5); 
< 0.001 
     75 
  69
bl_display_forbrblock = false; 
< 0.001 
     75 
  70
default_params = {fl_r_fbr st_forbrblk_type fl_forbrblk_brmost fl_forbrblk_brleast fl_forbrblk_gap ... 
     75 
  71
    bl_display_forbrblock}; 
  72 

  73 
%% Parse Parameters
  74 

  75 
% numvarargs is the number of varagin inputted
  0.002 
     75 
  76
[default_params{1:length(varargin)}] = varargin{:}; 
  0.001 
     75 
  77
[fl_r_fbr, st_forbrblk_type, fl_forbrblk_brmost, fl_forbrblk_brleast, fl_forbrblk_gap, ... 
     75 
  78
    bl_display_forbrblock] = default_params{:}; 
  79 

  80 
%% Set Formal Borrowing Grid Uniform
  81 

< 0.001 
     75 
  82
if (strcmp(st_forbrblk_type, 'unif')) 
  83 
    ar_forbrblk = fl_forbrblk_brleast:fl_forbrblk_gap:fl_forbrblk_brmost;
  84 
end
  85 

  86 
%% Set Formal Borrowing Grid Three Segment
  87 
% An example grid with three segments, the first segement has
  88 
% fl_forbrblk_gap as gap, the second segment gap is twice, the third
  89 
% segement the gap is 3 times as large as fl_forbrblk_gap. Respect
  90 
% fl_forbrblk_brmost fl_forbrblk_brleast, which means divided into three
  91 
% parts based on them as much as possible
  92 

< 0.001 
     75 
  93
if (strcmp(st_forbrblk_type, 'seg3')) 
< 0.001 
     75 
  94
    fl_most_least_gap = (fl_forbrblk_brmost - fl_forbrblk_brleast); 
< 0.001 
     75 
  95
    fl_most_least_seg3_interval = fl_most_least_gap/3; 
  96 
    
< 0.001 
     75 
  97
    ar_seg1 = fl_forbrblk_brleast:fl_forbrblk_gap:fl_most_least_seg3_interval; 
< 0.001 
     75 
  98
    ar_seg2 = max(ar_seg1):(fl_forbrblk_gap*2):fl_most_least_seg3_interval*2; 
< 0.001 
     75 
  99
    ar_seg3 = max(ar_seg2):(fl_forbrblk_gap*3):fl_forbrblk_brmost; 
 100 
    
< 0.001 
     75 
 101
    ar_forbrblk =[ar_seg1, ar_seg2, ar_seg3]; 
< 0.001 
     75 
 102
end 
 103 

 104 
%% Set Formal Borrowing Grid Three Segment
 105 
% An example grid with three segments, the first segement has
 106 
% fl_forbrblk_gap as gap, the second segment gap is twice, the third
 107 
% segement the gap is 3 times as large as fl_forbrblk_gap. Respect
 108 
% fl_forbrblk_brmost fl_forbrblk_brleast, which means divided into three
 109 
% parts based on them as much as possible
 110 

< 0.001 
     75 
 111
if (strcmp(st_forbrblk_type, 'testfx')) 
 112 
    fl_most_least_gap = (fl_forbrblk_brmost - fl_forbrblk_brleast);
 113 
    fl_most_least_seg3_interval = fl_most_least_gap/3;
 114 
    
 115 
    ar_seg1 = fl_forbrblk_brleast:fl_forbrblk_gap:fl_most_least_seg3_interval;
 116 
    ar_seg2 = max(ar_seg1):(fl_forbrblk_gap*2):fl_most_least_seg3_interval*2;
 117 
    ar_seg3 = max(ar_seg2):(fl_forbrblk_gap*3):fl_forbrblk_brmost;
 118 
    
 119 
    ar_forbrblk =[-3 -6];
 120 
end
 121 

 122 

 123 
%% Sort Borrowing Blocks
 124 

 125 
% add zero because formal borrowing = 0 should be an option
< 0.001 
     75 
 126
ar_forbrblk = [-0 ar_forbrblk]; 
  0.012 
     75 
 127
ar_forbrblk = sort(unique([ar_forbrblk])); 
 128 

 129 
%% Generate Corresponding Interest Rates Arrays
< 0.001 
     75 
 130
ar_forbrblk_r = fl_r_fbr + zeros(size(ar_forbrblk)); 
 131 

< 0.001 
     75 
 132
if (bl_display_forbrblock) 
 133 
    disp('ar_forbrblk');
 134 
    disp(ar_forbrblk);
 135 
    disp('ar_forbrblk_r');
 136 
    disp(ar_forbrblk_r);
 137 
end
 138 

< 0.001 
     75 
 139
end 

Other subfunctions in this file are not included in this listing.