Occupational Choice - Between Worker, Formal and informal firm owner

This function determines the occupational choice for all combinations of state of assets, labor opportunity and entrepreneurial productivity based on degree of imperfect enforcement of contracts

Back to full code page https://kritikhanna.github.io/BKS-modified/

Function Inputs : asset grid(1 by M), entrepreneurial productivity grid(1 by N), labor opportunity (1X2) and relevant model parameters

Function Outputs : Matrices O, COH, k and l (both M X N X P) for each combination of a, z, n O is the occupational choice function - o = 0 for worker, 1 for self employed, 2 for entrepreneur

Subs bl_con = true to see constrained and unconstrained formal / informal firm owners - here 4 - formal firm owners, 3 - formal constrained firm owners, 2 - informal unconstrained firm owners, 1 - informal constrained firm owners, 0 - worker

self - employed policy functions

Contents

function [mt_o, mt_coh, mt_k, mt_l]= OC3(varargin)
close all;
bl_profile = false;      % Switch off profile if running a tester/calling from another function
bl_saveimg = true;
if(bl_profile)
profile off;
profile on;
end

addpath(genpath('/Users/sidhantkhanna/Documents/GitHub/BKS modified/'));

Assigning Parameters

if ~isempty(varargin)

    [ar_a,ar_z,ar_n ...
        fl_alpha,fl_theta,fl_delta,fl_kappa,fl_r,fl_w,fl_phi,fl_ahi,fl_zhi, ...
         it_zgridno, it_agridno,it_ngridno ...
        ] = varargin{:};

    bl_print  = false;
    bl_plot   = false;
    bl_con    = false;


else
    close all;

    fl_ahi         = 50;
    fl_zhi         = 2.2;
    it_agridno     = 50;
    it_zgridno     = 50;
    it_ngridno     = 2;
    ar_a = linspace(0,fl_ahi,it_agridno);
    ar_z = linspace(1.2,fl_zhi,it_zgridno);
    ar_n           = [0,1];
    fl_phi         = 0.5;
    fl_alpha = 0.4;
    fl_theta = 0.79-fl_alpha;
    fl_delta = 0.05;
    fl_kappa = 0;

    [fl_r,fl_w,fl_ahi] = ...
        deal(0.05,1.5,100);
    bl_print       = false;
    bl_plot        = true;
    bl_con         = true;

end

fl_R = fl_r + fl_delta;

[a_m,z_m] = meshgrid(ar_a,ar_z);
a_m       = a_m';
z_m       = z_m';
a_m_3OC   = repmat (a_m, [1 1 it_ngridno]);
z_m_3OC   = repmat (z_m, [1 1 it_ngridno]);

Making Occupational choice

%for i = 0:0.5:1
 %   fl_phi = i;

[k_star, l_star] = optikl(ar_a,ar_z, ...
        fl_alpha,fl_theta,fl_delta,fl_kappa,fl_r,fl_w,fl_phi,fl_ahi,fl_zhi, ...
         it_zgridno, it_agridno);
k_star_3OC       = repmat (k_star, [1 1 it_ngridno]);
l_star_3OC       = repmat (l_star, [1 1 it_ngridno]);

 mt_wage         = fl_w.*ones(it_agridno, it_zgridno, it_ngridno); % Matrix for wages
 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);
 mt_o            = zeros(it_agridno, it_zgridno,it_ngridno);        % Matrix for Occupational Choice,
 mt_o(mt_wage<mt_profit) = 2;                      % 2 for Formal Firm owner
 mt_o((mt_wage(:,:,1)>mt_profit(:,:,1))) = 1;      % 1 for Informal Firm owner , 0 for wage worker

 mt_income       = mt_profit;
 mt_income(:,:,2)= max(mt_wage(:,:,2),mt_profit(:,:,2));         % Matrix for Income
 mt_coh          = mt_income + a_m_3OC.*(1+fl_r);                % Matrix for COH
 mt_k            = k_star_3OC;
 mt_l            = l_star_3OC;
 mt_k(mt_o==0)   = 0;
 mt_l(mt_o==0)   = 0;


 if(bl_print)
    disp('Below is mt_wage')
    disp(mt_wage);
    disp('Below is mt_profit ')
    disp(mt_profit );
    disp('Below is mt_o ')
    disp(mt_o);
    disp('Below is mt_income')
    disp(mt_income);
    disp('Below is mt_coh')
    disp(mt_coh);
    disp('Below is mt_k');
    disp(mt_k);
    disp('Below is mt_l');
    disp(mt_l);
 end

 if(bl_plot)
figure(1)
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
imagesc(ar_a,ar_z,mt_o(:,:,1)');
set(gca,'YDir','normal', 'FontSize',25)
%title('OC no labor skills, Pink = SE, Yellow = Ent','FontSize',20);
xlabel('assets','FontSize', 30);
ylabel('Entrepreneurial productivity','FontSize', 30);
if(bl_saveimg)
st_imgname = strcat('/Users/sidhantkhanna/Documents/GitHub/BKS modified/code/Households/figures/OC3/OC3_nolaskills',string(fl_phi),'.png');
saveas(gcf, st_imgname)
end

figure(2)
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)
imagesc(ar_a,ar_z,mt_o(:,:,2)');
set(gca,'YDir','normal', 'FontSize',25)
%title('OC with labor skills, White = worker, Yellow = Ent','FontSize',20);
xlabel('assets','FontSize', 30);
ylabel('Entrepreneurial productivity','FontSize', 30);
if(bl_saveimg)
st_imgname = strcat('/Users/sidhantkhanna/Documents/GitHub/BKS modified/code/Households/figures/OC3/OC3_laskills',string(fl_phi),'.png');
saveas(gcf, st_imgname)
end
end
%end
if (bl_con)

    [k_star, l_star, mt_id] = optikl(ar_a,ar_z, ...
        fl_alpha,fl_theta,fl_delta,fl_kappa,fl_r,fl_w,fl_phi,fl_ahi,fl_zhi, ...
         it_zgridno, it_agridno);
k_star_3OC       = repmat (k_star, [1 1 it_ngridno]);
l_star_3OC       = repmat (l_star, [1 1 it_ngridno]);
mt_id            = repmat (mt_id, [1 1 it_ngridno]);

 mt_wage         = fl_w.*ones(it_agridno, it_zgridno, it_ngridno);
 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);
 mt_o            = zeros(it_agridno, it_zgridno,it_ngridno);
 mt_o(mt_wage<mt_profit)  = 4;                       % Matrix for Occupational Choice, 4 for unconstrained formal firm owner
 mt_o(mt_o==4 & mt_id==2) = 3;                       % 3 for constrained formal firm owner
 mt_o((mt_wage(:,:,1)> mt_profit(:,:,1))) = 2;       % Assigning 2 for unconstrained informal firm owner
 mt_o(mt_o==2 & mt_id==2) = 1;                       % Assigning 1 for unconstrained informal firm owner, 0 for worker

 mt_income       = max(mt_wage,mt_profit);           % Matrix for Income
 mt_i1=mt_income(:,:,1);
 mt_p1=mt_profit(:,:,1);
 mt_i1(mt_wage(:,:,1)>mt_profit(:,:,1)) = mt_p1(mt_wage(:,:,1)>mt_profit(:,:,1));      % assigning income for informal firm owner
 mt_income(:,:,1)= mt_i1;
 mt_coh          = mt_income + a_m_3OC.*(1+fl_r);    % Matrix for COH
 mt_k            = k_star_3OC;
 mt_l            = l_star_3OC;
 mt_k(mt_o==0)   = 0;
 mt_l(mt_o==0)   = 0;


 if(bl_print)
    disp('Below is mt_wage')
    disp(mt_wage);
    disp('Below is mt_profit ')
    disp(mt_profit );
    disp('Below is mt_o ')
    disp(mt_o);
    disp('Below is mt_income')
    disp(mt_income);
    disp('Below is mt_coh')
    disp(mt_coh);
    disp('Below is mt_k');
    disp(mt_k);
    disp('Below is mt_l');
    disp(mt_l);
 end


 if(bl_plot)
figure(1)
colormap([[0.3 0.2 0]; [0.6 0.45 0.2];[0.2    0.5    0.9]; [0.5843    0.8157    0.9882] ])
imagesc(ar_a,ar_z,mt_o(:,:,1)');
set(gca,'YDir','normal', 'FontSize',20 )
%title('OC with no option to work','FontSize',30);
xlabel('assets','FontSize', 25);
ylabel('Entrepreneurial productivity','FontSize', 25);
if(bl_saveimg)
saveas(gcf, '/Users/sidhantkhanna/Documents/GitHub/BKS modified/code/Households/figures/OC3/OC3_5types_0.png')
end

figure(2)
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] ] )
imagesc(ar_a,ar_z,mt_o(:,:,2)');
set(gca,'YDir','normal', 'FontSize',20 )
%title('OC with option to work','FontSize',30);
xlabel('assets','FontSize', 25);
ylabel('Entrepreneurial productivity','FontSize', 25);
if(bl_saveimg)
saveas(gcf, '/Users/sidhantkhanna/Documents/GitHub/BKS modified/code/Households/figures/OC3/OC3_5types_1.png')
end
end
end

if(bl_profile)
profile off;
profile viewer;
st_file_name = '/Users/sidhantkhanna/Documents/GitHub/BKS modified/code/Profile/Households/OC3';
profsave(profile('info'), st_file_name);
end