This is a static copy of a profile report

Home

OC3 (Calls: 1, Time: 1.833 s)
Generated 18-Jul-2020 08:10:34 using performance time.
function in file /Users/sidhantkhanna/Documents/GitHub/BKS modified/code/Households/OC3.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
hhsave_util_3OCfunction1
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
93
it_zgridno, it_agridno);
10.944 s51.5%
37
addpath(genpath('/Users/sidhan...
10.866 s47.3%
29
close all;
10.010 s0.5%
80
[a_m,z_m] = meshgrid(ar_a,ar_z...
10.003 s0.2%
44
fl_alpha,fl_theta,fl_delta,fl_...
10.002 s0.1%
All other lines  0.008 s0.5%
Totals  1.833 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
optiklfunction10.943 s51.5%
genpathfunction10.741 s40.5%
addpathfunction10.124 s6.8%
closefunction10.004 s0.2%
meshgridfunction10.003 s0.1%
Self time (built-ins, overhead, etc.)  0.018 s1.0%
Totals  1.833 s100% 
Code Analyzer results
Line numberMessage
33This statement (and possibly following ones) cannot be reached.
43The value assigned here to 'ar_n' appears to be unused. Consider replacing it by ~.
44Best practice is to separate output variables with commas.
63The value assigned to variable 'ar_n' might be unused.
228This statement (and possibly following ones) cannot be reached.
Coverage results
Show coverage for parent directory
Total lines in function206
Non-code lines (comments, blank lines)41
Code lines (lines that can run)165
Code lines that did run46
Code lines that did not run119
Coverage (did run/can run)27.88 %
Function listing
time 
Calls 
 line
  27 
function [mt_o, mt_coh, mt_k, mt_l]= OC3(varargin)
  28 

  0.010 
      1 
  29
close all; 
< 0.001 
      1 
  30
bl_profile = false;      % Switch off profile if running a tester/calling from another function 
< 0.001 
      1 
  31
bl_saveimg = true; 
< 0.001 
      1 
  32
if(bl_profile) 
  33 
profile off;
  34 
profile on;
< 0.001 
      1 
  35
end 
  36 

  0.866 
      1 
  37
addpath(genpath('/Users/sidhantkhanna/Documents/GitHub/BKS modified/')); 
  38 

  39 
%% Assigning Parameters
  40 

< 0.001 
      1 
  41
if ~isempty(varargin) 
  42 
    
  0.004 
      1 
  43
    [ar_a,ar_z,ar_n ... 
      1 
  44
        fl_alpha,fl_theta,fl_delta,fl_kappa,fl_r,fl_w,fl_phi,fl_ahi,fl_zhi, ... 
      1 
  45
         it_zgridno, it_agridno,it_ngridno ... 
      1 
  46
        ] = varargin{:}; 
  47 
    
< 0.001 
      1 
  48
    bl_print  = false; 
< 0.001 
      1 
  49
    bl_plot   = false; 
< 0.001 
      1 
  50
    bl_con    = false; 
  51 

  52 
    
  53 
else
  54 
    close all;
  55 
    
  56 
    fl_ahi         = 50;
  57 
    fl_zhi         = 2.2;
  58 
    it_agridno     = 50;
  59 
    it_zgridno     = 50;
  60 
    it_ngridno     = 2;
  61 
    ar_a = linspace(0,fl_ahi,it_agridno);
  62 
    ar_z = linspace(1.2,fl_zhi,it_zgridno);
  63 
    ar_n           = [0,1];
  64 
    fl_phi         = 0.5;
  65 
    fl_alpha = 0.4;
  66 
    fl_theta = 0.79-fl_alpha;
  67 
    fl_delta = 0.05;
  68 
    fl_kappa = 0;
  69 
        
  70 
    [fl_r,fl_w,fl_ahi] = ...
  71 
        deal(0.05,1.5,100);
  72 
    bl_print       = false;
  73 
    bl_plot        = true;
  74 
    bl_con         = true;
  75 
    
< 0.001 
      1 
  76
end 
  77 

< 0.001 
      1 
  78
fl_R = fl_r + fl_delta; 
  79 

  0.003 
      1 
  80
[a_m,z_m] = meshgrid(ar_a,ar_z); 
< 0.001 
      1 
  81
a_m       = a_m'; 
< 0.001 
      1 
  82
z_m       = z_m'; 
< 0.001 
      1 
  83
a_m_3OC   = repmat (a_m, [1 1 it_ngridno]); 
< 0.001 
      1 
  84
z_m_3OC   = repmat (z_m, [1 1 it_ngridno]); 
  85 

  86 
%% Making Occupational choice
  87 

  88 
%for i = 0:0.5:1            
  89 
 %   fl_phi = i;
  90 

  0.944 
      1 
  91
[k_star, l_star] = optikl(ar_a,ar_z, ... 
      1 
  92
        fl_alpha,fl_theta,fl_delta,fl_kappa,fl_r,fl_w,fl_phi,fl_ahi,fl_zhi, ... 
      1 
  93
         it_zgridno, it_agridno); 
< 0.001 
      1 
  94
k_star_3OC       = repmat (k_star, [1 1 it_ngridno]); 
< 0.001 
      1 
  95
l_star_3OC       = repmat (l_star, [1 1 it_ngridno]);  
  96 

< 0.001 
      1 
  97
 mt_wage         = fl_w.*ones(it_agridno, it_zgridno, it_ngridno); % Matrix for wages 
  0.001 
      1 
  98
 mt_profit       = z_m_3OC.*(k_star_3OC.^fl_alpha).*(l_star_3OC.^fl_theta) - fl_R.*k_star_3OC - fl_w.*l_star_3OC - ((1+fl_r)*(fl_kappa)).*ones(it_agridno, it_zgridno, it_ngridno); 
< 0.001 
      1 
  99
 mt_o            = zeros(it_agridno, it_zgridno,it_ngridno);        % Matrix for Occupational Choice, 
< 0.001 
      1 
 100
 mt_o(mt_wage<mt_profit) = 2;                      % 2 for Formal Firm owner  
< 0.001 
      1 
 101
 mt_o((mt_wage(:,:,1)>mt_profit(:,:,1))) = 1;      % 1 for Informal Firm owner , 0 for wage worker     
 102 
 
< 0.001 
      1 
 103
 mt_income       = mt_profit; 
< 0.001 
      1 
 104
 mt_income(:,:,2)= max(mt_wage(:,:,2),mt_profit(:,:,2));         % Matrix for Income 
< 0.001 
      1 
 105
 mt_coh          = mt_income + a_m_3OC.*(1+fl_r);                % Matrix for COH 
< 0.001 
      1 
 106
 mt_k            = k_star_3OC;                         
< 0.001 
      1 
 107
 mt_l            = l_star_3OC; 
< 0.001 
      1 
 108
 mt_k(mt_o==0)   = 0; 
< 0.001 
      1 
 109
 mt_l(mt_o==0)   = 0; 
 110 
 
 111 
 
< 0.001 
      1 
 112
 if(bl_print) 
 113 
    disp('Below is mt_wage')
 114 
    disp(mt_wage);
 115 
    disp('Below is mt_profit ')
 116 
    disp(mt_profit );
 117 
    disp('Below is mt_o ')
 118 
    disp(mt_o);
 119 
    disp('Below is mt_income')
 120 
    disp(mt_income);
 121 
    disp('Below is mt_coh')
 122 
    disp(mt_coh);
 123 
    disp('Below is mt_k');
 124 
    disp(mt_k);
 125 
    disp('Below is mt_l');
 126 
    disp(mt_l);
< 0.001 
      1 
 127
 end 
 128 
     
< 0.001 
      1 
 129
 if(bl_plot)     
 130 
figure(1)
 131 
colormap( [[0.6 0.45 0.2]; [ 0.5843    0.8157    0.9882]] ) % Brown = 1 (Informal firm owner) , Green = 2 (Informal firm owner), in order of increasing no. in matrix
 132 
imagesc(ar_a,ar_z,mt_o(:,:,1)');
 133 
set(gca,'YDir','normal', 'FontSize',25)
 134 
%title('OC no labor skills, Pink = SE, Yellow = Ent','FontSize',20);
 135 
xlabel('assets','FontSize', 30); 
 136 
ylabel('Entrepreneurial productivity','FontSize', 30);
 137 
if(bl_saveimg)
 138 
st_imgname = strcat('/Users/sidhantkhanna/Documents/GitHub/BKS modified/code/Households/figures/OC3/OC3_nolaskills',string(fl_phi),'.png'); 
 139 
saveas(gcf, st_imgname)
 140 
end
 141 

 142 
figure(2)
 143 
colormap( [1 0.6 1; [0.6 0.45 0.2]; [ 0.5843    0.8157    0.9882]]) % White = 0 (Worker), Brown = 1 (Informal firm owner) , Green = 2 (Informal firm owner)
 144 
imagesc(ar_a,ar_z,mt_o(:,:,2)');
 145 
set(gca,'YDir','normal', 'FontSize',25)
 146 
%title('OC with labor skills, White = worker, Yellow = Ent','FontSize',20);
 147 
xlabel('assets','FontSize', 30); 
 148 
ylabel('Entrepreneurial productivity','FontSize', 30);
 149 
if(bl_saveimg)
 150 
st_imgname = strcat('/Users/sidhantkhanna/Documents/GitHub/BKS modified/code/Households/figures/OC3/OC3_laskills',string(fl_phi),'.png'); 
 151 
saveas(gcf, st_imgname)
 152 
end
< 0.001 
      1 
 153
end 
 154 
%end
< 0.001 
      1 
 155
if (bl_con) 
 156 
    
 157 
    [k_star, l_star, mt_id] = optikl(ar_a,ar_z, ...
 158 
        fl_alpha,fl_theta,fl_delta,fl_kappa,fl_r,fl_w,fl_phi,fl_ahi,fl_zhi, ...
 159 
         it_zgridno, it_agridno);
 160 
k_star_3OC       = repmat (k_star, [1 1 it_ngridno]);
 161 
l_star_3OC       = repmat (l_star, [1 1 it_ngridno]);
 162 
mt_id            = repmat (mt_id, [1 1 it_ngridno]);
 163 
          
 164 
 mt_wage         = fl_w.*ones(it_agridno, it_zgridno, it_ngridno);
 165 
 mt_profit       = z_m_3OC.*(k_star_3OC.^fl_alpha).*(l_star_3OC.^fl_theta) - fl_R.*k_star_3OC - fl_w.*l_star_3OC - ((1+fl_r)*(fl_kappa)).*ones(it_agridno, it_zgridno, it_ngridno);
 166 
 mt_o            = zeros(it_agridno, it_zgridno,it_ngridno);
 167 
 mt_o(mt_wage<mt_profit)  = 4;                       % Matrix for Occupational Choice, 4 for unconstrained formal firm owner
 168 
 mt_o(mt_o==4 & mt_id==2) = 3;                       % 3 for constrained formal firm owner
 169 
 mt_o((mt_wage(:,:,1)> mt_profit(:,:,1))) = 2;       % Assigning 2 for unconstrained informal firm owner   
 170 
 mt_o(mt_o==2 & mt_id==2) = 1;                       % Assigning 1 for unconstrained informal firm owner, 0 for worker
 171 
 
 172 
 mt_income       = max(mt_wage,mt_profit);           % Matrix for Income
 173 
 mt_i1=mt_income(:,:,1);  
 174 
 mt_p1=mt_profit(:,:,1); 
 175 
 mt_i1(mt_wage(:,:,1)>mt_profit(:,:,1)) = mt_p1(mt_wage(:,:,1)>mt_profit(:,:,1));      % assigning income for informal firm owner
 176 
 mt_income(:,:,1)= mt_i1;       
 177 
 mt_coh          = mt_income + a_m_3OC.*(1+fl_r);    % Matrix for COH
 178 
 mt_k            = k_star_3OC;                        
 179 
 mt_l            = l_star_3OC;
 180 
 mt_k(mt_o==0)   = 0;
 181 
 mt_l(mt_o==0)   = 0;
 182 
 
 183 
 
 184 
 if(bl_print)
 185 
    disp('Below is mt_wage')
 186 
    disp(mt_wage);
 187 
    disp('Below is mt_profit ')
 188 
    disp(mt_profit );
 189 
    disp('Below is mt_o ')
 190 
    disp(mt_o);
 191 
    disp('Below is mt_income')
 192 
    disp(mt_income);
 193 
    disp('Below is mt_coh')
 194 
    disp(mt_coh);
 195 
    disp('Below is mt_k');
 196 
    disp(mt_k);
 197 
    disp('Below is mt_l');
 198 
    disp(mt_l);
 199 
 end
 200 
    
 201 
 
 202 
 if(bl_plot)    
 203 
figure(1)
 204 
colormap([[0.3 0.2 0]; [0.6 0.45 0.2];[0.2    0.5    0.9]; [0.5843    0.8157    0.9882] ])
 205 
imagesc(ar_a,ar_z,mt_o(:,:,1)');
 206 
set(gca,'YDir','normal', 'FontSize',20 )
 207 
%title('OC with no option to work','FontSize',30);
 208 
xlabel('assets','FontSize', 25); 
 209 
ylabel('Entrepreneurial productivity','FontSize', 25);
 210 
if(bl_saveimg)
 211 
saveas(gcf, '/Users/sidhantkhanna/Documents/GitHub/BKS modified/code/Households/figures/OC3/OC3_5types_0.png')
 212 
end
 213 

 214 
figure(2)
 215 
colormap( [1 0.6 1;[0.3 0.2 0]; [0.6 0.45 0.2]; [0.2    0.5    0.9]; [0.5843    0.8157    0.9882] ] )
 216 
imagesc(ar_a,ar_z,mt_o(:,:,2)');
 217 
set(gca,'YDir','normal', 'FontSize',20 )
 218 
%title('OC with option to work','FontSize',30);
 219 
xlabel('assets','FontSize', 25); 
 220 
ylabel('Entrepreneurial productivity','FontSize', 25);
 221 
if(bl_saveimg)
 222 
saveas(gcf, '/Users/sidhantkhanna/Documents/GitHub/BKS modified/code/Households/figures/OC3/OC3_5types_1.png')
 223 
end
 224 
end    
< 0.001 
      1 
 225
end  
 226 

< 0.001 
      1 
 227
if(bl_profile) 
 228 
profile off;
 229 
profile viewer;
 230 
st_file_name = '/Users/sidhantkhanna/Documents/GitHub/BKS modified/code/Profile/Households/OC3';
 231 
profsave(profile('info'), st_file_name);
< 0.001 
      1 
 232
end 

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