Occupational Choice - Between regular worker, casual worker, Entrepreneur and Involuntary - 2 shocks of self employment

This function determines the occupational choice for all combinations of state of assets, labor productivity 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 productivity (1XP) 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

Contents

function [mt_o, mt_coh, mt_k, mt_l]= OC4(varargin)
close all;
bl_profile = false;      % Switch off profile if running a tester/calling from another function
bl_saveimg = false;
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;


else
    close all;

    fl_ahi         = 5;
    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,fl_zhi,it_zgridno);
    fl_zlim       = 1.4;
    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;

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]);
z_m_cut   = fl_zlim.*ones(it_agridno, it_zgridno, it_ngridno);

Making Occupational choice

[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);
 mt_wage2        = zeros(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) = 3;                      % 3 for Voluntary entrepreneur
 mt_wage2        = 0.25.*mt_wage;
 mt_income       = zeros(it_agridno, it_zgridno, it_ngridno);
 i=1;
 mt_o1=mt_o(:,:,i);
 mt_o1((mt_wage(:,:,i)>mt_profit(:,:,i)) & (mt_profit(:,:,i)>mt_wage2(:,:,i))) = 2;        % Assigning 2 for Involuntary entrepreneurs
 mt_o1((mt_wage(:,:,i)>mt_profit(:,:,i)) & (mt_profit(:,:,i)<mt_wage2(:,:,i))) = 1;        % Assigning 1 for Casual Worker
 mt_o(:,:,i)=mt_o1;
 mt_income(:,:,i) = mt_profit(:,:,i);         % Matrix for Income
 mt_i1 = mt_income(:,:,i);
 mt_p2 = mt_wage2(:,:,i);
 mt_i1(mt_profit(:,:,i)<mt_wage2(:,:,i)) = mt_p2(mt_profit(:,:,i)<mt_wage2(:,:,i));
 mt_income(:,:,i)=mt_i1;

 i=2;
 mt_income(:,:,i) = max(mt_wage(:,:,i),mt_profit(:,:,i));         % Matrix for Income
 mt_o1=mt_o(:,:,i);
 mt_o1((mt_wage(:,:,i)>mt_profit(:,:,i)) & (z_m_3OC(:,:,i)>z_m_cut(:,:,i))) = 4;        % Assigning 4 for Regular workers
 mt_o1((mt_wage(:,:,i)>mt_profit(:,:,i)) & (z_m_3OC(:,:,i)<z_m_cut(:,:,i))&(mt_profit(:,:,i)<mt_wage2(:,:,i))) = 1;        % Assigning 1 for Casual Worker
 mt_o1((mt_wage(:,:,i)>mt_profit(:,:,i)) & (z_m_3OC(:,:,i)<z_m_cut(:,:,i))&(mt_profit(:,:,i)>mt_wage2(:,:,i))) = 2;        % Assigning 2 for Self-Employed
 mt_o(:,:,i)=mt_o1;
 mt_income(:,:,i)       = max(mt_wage(:,:,i),mt_profit(:,:,i));         % Matrix for Income
 mt_i1 = mt_income(:,:,i);
 mt_p1 = mt_profit(:,:,i);
 mt_p2 = mt_wage2(:,:,i);
 mt_i1((mt_wage(:,:,i)>mt_profit(:,:,i)) & (mt_profit(:,:,i)>mt_wage2(:,:,i))) = mt_p1((mt_wage(:,:,i)>mt_profit(:,:,i)) & (mt_profit(:,:,i)>mt_wage2(:,:,i)));      % assigning income for self- employed
 mt_i1((mt_wage(:,:,i)>mt_profit(:,:,i)) & (mt_profit(:,:,i)<mt_wage2(:,:,i))) = mt_p2((mt_wage(:,:,i)>mt_profit(:,:,i)) & (mt_profit(:,:,i)<mt_wage2(:,:,i)));
 mt_income(:,:,i)=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==4 | mt_o==1)   = 0;
 mt_l(mt_o==4 | mt_o==1)   = 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( [1 0 1; 1 1 1; 1 1 0] )
imagesc(ar_a,ar_z,mt_o(:,:,1)');
set(gca,'YDir','normal')
title('l =0, Pink = CW, White = IE, Yellow = VE','FontSize',20);
xlabel('assets','FontSize', 20);
ylabel('Entrepreneurial productivity','FontSize', 20);
if(bl_saveimg)
saveas(gcf, '/Users/sidhantkhanna/Documents/GitHub/BKS modified/code/Households/figures/OC3/OC3_nolaskills.png')
end

figure(2)
colormap( [1 0 1; 1 1 1; 1 1 0; 0 1 1] )
imagesc(ar_a,ar_z,mt_o(:,:,2)');
set(gca,'YDir','normal')
title('l=1, Pink = CW, White = IE, Yellow = VE, Blue = RW','FontSize',20);
xlabel('assets','FontSize', 20);
ylabel('Entrepreneurial productivity','FontSize', 20);
if(bl_saveimg)
saveas(gcf, '/Users/sidhantkhanna/Documents/GitHub/BKS modified/code/Households/figures/OC3/OC3_laskills.png')
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