This is a static copy of a profile report

Home

OC3 (Calls: 1, Time: 4.135 s)
Generated 16-Jul-2020 17:08:28 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
140
saveas(gcf, st_imgname)
11.212 s29.3%
94
it_zgridno, it_agridno);
11.203 s29.1%
37
addpath(genpath('/Users/sidhan...
10.801 s19.4%
152
saveas(gcf, st_imgname)
10.595 s14.4%
133
imagesc(ar_a,ar_z,mt_o(:,:,1)'...
10.114 s2.8%
All other lines  0.210 s5.1%
Totals  4.135 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
saveasfunction21.804 s43.6%
optiklfunction11.202 s29.1%
genpathfunction10.677 s16.4%
imagescfunction20.132 s3.2%
addpathfunction10.123 s3.0%
xlabelfunction20.042 s1.0%
ylabelfunction20.015 s0.4%
string.strcatfunction20.011 s0.3%
colormapfunction20.008 s0.2%
meshgridfunction10.003 s0.1%
closefunction10.002 s0.0%
Self time (built-ins, overhead, etc.)  0.116 s2.8%
Totals  4.135 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.
232This statement (and possibly following ones) cannot be reached.
Coverage results
Show coverage for parent directory
Total lines in function210
Non-code lines (comments, blank lines)45
Code lines (lines that can run)165
Code lines that did run66
Code lines that did not run99
Coverage (did run/can run)40.00 %
Function listing
time 
Calls 
 line
  27 
function [mt_o, mt_coh, mt_k, mt_l]= OC3(varargin)
  28 

  0.002 
      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.801 
      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   = true; 
< 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 
    
  66 
    fl_alpha = 0.4;
  67 
    fl_theta = 0.79-fl_alpha;
  68 
    fl_delta = 0.05;
  69 
    fl_kappa = 0;
  70 
        
  71 
    [fl_r,fl_w,fl_ahi] = ...
  72 
        deal(0.05,1.5,100);
  73 
    bl_print       = false;
  74 
    bl_plot        = true;
  75 
    bl_con         = true;
  76 
    
< 0.001 
      1 
  77
end 
  78 

< 0.001 
      1 
  79
fl_R = fl_r + fl_delta; 
  80 

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

  87 
%% Making Occupational choice
  88 

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

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

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

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

 215 
figure(2)
 216 
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] ] )
 217 
imagesc(ar_a,ar_z,mt_o(:,:,2)');
 218 
set(gca,'YDir','normal', 'FontSize',20 )
 219 
%title('OC with option to work','FontSize',30);
 220 
xlabel('assets','FontSize', 25); 
 221 
ylabel('Entrepreneurial productivity','FontSize', 25);
 222 
if(bl_saveimg)
 223 
saveas(gcf, '/Users/sidhantkhanna/Documents/GitHub/BKS modified/code/Households/figures/OC3/OC3_5types_1.png')
 224 
end
 225 
end
 226 
    
< 0.001 
      1 
 227
end 
 228 
 
 229 
 
 230 

< 0.001 
      1 
 231
if(bl_profile) 
 232 
profile off;
 233 
profile viewer;
 234 
st_file_name = '/Users/sidhantkhanna/Documents/GitHub/BKS modified/code/Profile/Households/OC3';
 235 
profsave(profile('info'), st_file_name);
< 0.001 
      1 
 236
end 

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