Partial Equilbrium - 3OC
This function solves the 3OC model outcomes given interest rate and wages Back to full code page https://kritikhanna.github.io/BKS-modified/
Function Inputs :
Function Outputs : grid of
Contents
function [fl_y,mt_dis, mt_vf,mt_pf,mt_wage,mt_profit,mt_income,mt_coh, mt_o, mt_k, mt_l]= PE_3OC(varargin)
addpath(genpath('C:\Users\kriti\Desktop\BKS-modified')); 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/')); 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, ... fl_risk,it_zgridno, it_agridno,it_ngridno, mt_trans_z,mt_trans_n,fl_beta, fl_mu_z, fl_sig_z,fl_rho_z,fl_lambda_z,fl_tolvfi, fl_toldis ... ] = varargin{:}; bl_print = false; bl_plot = false; else fl_alo = 0; fl_ahi = 50; fl_zhi = 2.2; it_agridno = 50; it_zgridno = 7; it_ngridno = 2; % ar_a = linspace(0,fl_ahi,it_agridno); mp_grid_control = containers.Map('KeyType','char', 'ValueType','any'); mp_grid_control('grid_powerspace_power') = 2; % ar_a = ff_saveborr_grid(fl_alo, fl_ahi, it_agridno, mp_grid_control) ar_a = ff_saveborr_grid(fl_alo, fl_ahi, it_agridno, 'grid_powerspace', mp_grid_control); ar_a = ar_a'; fl_phi = 0.5; fl_risk = 1.5; fl_alpha = 0.4; fl_theta = 0.79-fl_alpha; fl_delta = 0.08; fl_kappa = 0; fl_mu_z = 0; % mean of AR(1) entrepeneurial productivity process fl_rho_z = 0.9; % persistence parameter of the AR(1) entrepreneurial productivity process fl_sig_z = 0.2; fl_lambda_z = 3; fl_beta = 0.92; [ar_z, mt_trans_z] = ffy_rouwenhorst(fl_rho_z,fl_sig_z,it_zgridno); ar_z = exp(ar_z); P1 = mt_trans_z^1000; sd = P1(1,:); el = sd*ar_z; ar_z = ar_z/el; ar_z = ar_z'; ar_n =[0,1]; % [ar_z, mt_trans_z] = mytauchen_z(fl_mu_z,fl_rho_z,fl_sig_z,it_zgridno,fl_lambda_z); mt_trans_n =[0.4,0.6;0.4,0.6]; [fl_r,fl_w] = ... deal(0.05,1); fl_tolvfi = 10^-12; fl_toldis = 10^-12; % Tolerance level for convergence stationary distribution bl_print = true; 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]); [mt_dis, mt_vf,mt_pf,mt_wage,mt_profit,mt_income,mt_coh,mt_o, mt_k, mt_l]=hhsave_dis_3OC(ar_a,ar_z,ar_n, ... fl_alpha,fl_theta,fl_delta,fl_kappa,fl_r,fl_w,fl_phi,fl_ahi,fl_zhi, ... fl_risk,it_zgridno, it_agridno,it_ngridno, mt_trans_z,mt_trans_n,fl_beta, fl_mu_z, fl_sig_z,fl_rho_z, ... fl_lambda_z, fl_tolvfi, fl_toldis ); mt_ent = zeros(it_agridno,it_zgridno,it_ngridno); mt_se = zeros(it_agridno,it_zgridno,it_ngridno); mt_worker = zeros(it_agridno,it_zgridno,it_ngridno); mt_ent(mt_o==2) = 1; mt_se (mt_o==1) = 1; mt_worker(mt_o==0) = 1;
Model Outcomes
% Total Output fl_y = sum(sum(sum(z_m_3OC.*mt_dis.*mt_k.^fl_alpha.*mt_l.^fl_theta))); % Capital and labor demanded fl_kdemand = sum(sum(sum(mt_dis.*mt_k))); fl_ldemand = sum(sum(sum(mt_dis.*mt_l))); % Capital and labor supplied fl_ksupply = sum(sum(sum(mt_dis.*mt_pf))); fl_lsupply = sum(sum(sum(mt_dis.*mt_worker))); % Percent employed in each occupations fl_percent_ent = sum(sum(sum(mt_dis.*mt_ent))); fl_percent_se = sum(sum(sum(mt_dis.*mt_se))); fl_percent_worker = sum(sum(sum(mt_dis.*mt_worker))); % Talent of entrepreneurs mt_dis_ent = mt_dis; mt_dis_ent(mt_o~=2) = 0; mt_z_m_3OC_ent = z_m_3OC; mt_z_m_3OC_ent(mt_o~=2)= 0; ar_z_m_3OC_ent = mt_z_m_3OC_ent(:); ar_dis_ent = mt_dis_ent(:); ar_dis_ent(ar_z_m_3OC_ent==0) = []; ar_z_m_3OC_ent(ar_z_m_3OC_ent==0) = []; fl_length_ent = length(ar_dis_ent); %fl_mean_tal_ent = (sum(sum(sum(z_m_3OC.*mt_dis_ent))))/(sum(sum(sum(mt_dis_ent)))); fl_mean_tal_ent = sum(ar_z_m_3OC_ent.*ar_dis_ent)/(sum(ar_dis_ent)); W = ar_dis_ent/(sum(ar_dis_ent)); X = ar_z_m_3OC_ent; Wmean = fl_mean_tal_ent; N = fl_length_ent; %fl_sd_tal_ent = sqrt((sum(W.*(X - Wmean).^2)) / ((N-1)*sum(W)/N)); fl_sd_tal_ent = std(X,W); %Talent of Informal firm owners mt_dis_se = mt_dis; mt_dis_se(mt_o~=1) = 0; mt_z_m_3OC_se = z_m_3OC; mt_z_m_3OC_se(mt_o~=1)= 0; ar_z_m_3OC_se = mt_z_m_3OC_se(:); ar_dis_se = mt_dis_se(:); ar_dis_se(ar_z_m_3OC_se==0) = []; ar_z_m_3OC_se(ar_z_m_3OC_se==0) = []; fl_length_se = length(ar_dis_se); fl_mean_tal_se = sum(ar_z_m_3OC_se.*ar_dis_se)/(sum(ar_dis_se)); W = ar_dis_se; X = ar_z_m_3OC_se; Wmean = fl_mean_tal_se; N = fl_length_se; %fl_sd_tal_se = sqrt((sum(W.*(X - Wmean).^2)) / ((N-1)*sum(W)/N)); fl_sd_tal_se = std(X,W); % Firm size distributions ar_l = mt_l(:); ar_dis = mt_dis(:); ar_dis(ar_l==0) = []; ar_l(ar_l==0) = []; fl_mean_l = sum(ar_dis.*ar_l)/(sum(ar_dis)); fl_length_l = length(ar_l); W = ar_dis; X = ar_l; Wmean = fl_mean_l; N = fl_length_l; %fl_sd_l = sqrt((sum(W.*(X - Wmean).^2)/N) / ((N-1)*sum(W)/N)); fl_sd_l = std(X,W); draw_rand_count = 100000; labor_idx_simu = randsample(1:length(ar_dis), draw_rand_count, true, ar_dis); labor_draws = ar_l (labor_idx_simu); % Asset distribution ar_a_dis =sum(mt_dis,[2,3]); if(bl_print) disp ('Degree of Contract enforcement friction is:') disp(fl_phi); disp('Output per capita is:') disp(fl_y); disp('Total capital per capita demanded is:') disp(fl_kdemand); disp('Total labor per capita demanded is:') disp(fl_ldemand); disp('Percentage entrepreneurs') disp(fl_percent_ent); disp('Percentage self-employed other than entrepreneurs') disp(fl_percent_se); disp('Percentage workers'); disp(fl_percent_worker); disp('Mean talent of Entrepreneurs'); disp(fl_mean_tal_ent); disp('Mean talent of Self Employed'); disp(fl_mean_tal_se); disp('SD talent of Entrepreneurs'); disp(fl_mean_tal_ent); disp('SD talent of Self Employed'); disp(fl_sd_tal_se); disp('Mean of Firm Size'); disp(fl_mean_l); disp('SD of Firm Size'); disp(fl_sd_l); disp('Joint distribution') disp(mt_dis); end if(bl_plot) figure(1) colormap( [1 0 1; 1 0 1; 1 1 0] ) imagesc(ar_a,ar_z,mt_o(:,:,1)'); set(gca,'YDir','normal') title('OC Policy function, l=0, Pink = SE, Yellow = Ent','FontSize',20); xlabel('assets','FontSize', 20); ylabel('Entrepreneurial productivity','FontSize', 20); figure(2) colormap( [1 1 1; 1 0 0; 1 1 0] ) imagesc(ar_a,ar_z,mt_o(:,:,2)'); set(gca,'YDir','normal') title('OC Policy function, l=1, White = worker, Yellow = Ent','FontSize',20); xlabel('assets','FontSize', 20); ylabel('Entrepreneurial productivity','FontSize', 20); figure(3) hist(labor_draws, 40) title('Low phi','FontSize', 25); xlabel('firm size','FontSize', 25); ylabel('No of firms','FontSize', 25); xt = get(gca, 'XTick'); set(gca, 'XTick', xt, 'XTickLabel', xt, 'FontSize',20); xlim([0 30]) ylim ([0 80000]) figure(4) contour(ar_z,ar_a,mt_dis(:,:,1)) figure(5) plot(ar_a_dis); end
Degree of Contract enforcement friction is: 0.5000 Output per capita is: 3.5607 Total capital per capita demanded is: 8.6609 Total labor per capita demanded is: 1.3887 Percentage entrepreneurs 0.2574 Percentage self-employed other than entrepreneurs 0.2970 Percentage workers 0.4456 Mean talent of Entrepreneurs 1.6154 Mean talent of Self Employed 0.7867 SD talent of Entrepreneurs 1.6154 SD talent of Self Employed 0.2603 Mean of Firm Size 2.5046 SD of Firm Size 4.4670 Joint distribution (:,:,1) = 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0001 0.0001 0.0000 0.0000 0.0000 0.0000 0.0000 0.0001 0.0002 0.0002 0.0000 0.0000 0.0000 0.0000 0.0002 0.0005 0.0003 0.0001 0.0000 0.0000 0.0001 0.0007 0.0014 0.0008 0.0001 0.0000 0.0000 0.0001 0.0017 0.0038 0.0018 0.0003 0.0000 0.0000 0.0002 0.0008 0.0034 0.0030 0.0009 0.0001 0.0000 0.0005 0.0036 0.0072 0.0059 0.0017 0.0002 0.0000 0.0008 0.0034 0.0070 0.0075 0.0026 0.0002 0.0000 0.0007 0.0037 0.0082 0.0110 0.0039 0.0004 0.0000 0.0004 0.0022 0.0068 0.0193 0.0170 0.0017 0.0000 0.0005 0.0042 0.0096 0.0058 0.0029 0.0004 0.0000 0.0006 0.0012 0.0025 0.0031 0.0019 0.0005 0.0000 0.0002 0.0010 0.0024 0.0033 0.0030 0.0016 0.0001 0.0002 0.0010 0.0024 0.0030 0.0019 0.0005 0.0000 0.0002 0.0010 0.0024 0.0032 0.0020 0.0005 0.0000 0.0002 0.0010 0.0025 0.0033 0.0029 0.0014 0.0001 0.0002 0.0010 0.0024 0.0031 0.0020 0.0005 0.0000 0.0002 0.0010 0.0025 0.0033 0.0021 0.0006 0.0001 0.0002 0.0010 0.0025 0.0035 0.0028 0.0013 0.0001 0.0001 0.0009 0.0025 0.0034 0.0022 0.0006 0.0000 0.0001 0.0009 0.0025 0.0036 0.0023 0.0007 0.0001 0.0001 0.0008 0.0025 0.0039 0.0030 0.0012 0.0001 0.0001 0.0007 0.0024 0.0041 0.0027 0.0007 0.0000 0.0001 0.0006 0.0021 0.0048 0.0086 0.0014 0.0001 0.0001 0.0005 0.0015 0.0022 0.0020 0.0016 0.0001 0.0001 0.0005 0.0014 0.0022 0.0019 0.0012 0.0001 0.0001 0.0004 0.0013 0.0022 0.0018 0.0013 0.0001 0.0001 0.0004 0.0012 0.0024 0.0015 0.0010 0.0001 0.0001 0.0003 0.0009 0.0012 0.0013 0.0011 0.0001 0.0001 0.0003 0.0008 0.0012 0.0012 0.0009 0.0001 0.0001 0.0003 0.0008 0.0011 0.0011 0.0009 0.0001 0.0000 0.0003 0.0009 0.0010 0.0010 0.0007 0.0001 0.0000 0.0003 0.0010 0.0010 0.0010 0.0008 0.0001 0.0000 0.0002 0.0005 0.0008 0.0009 0.0007 0.0001 0.0000 0.0002 0.0005 0.0008 0.0009 0.0007 0.0001 0.0000 0.0001 0.0004 0.0008 0.0008 0.0006 0.0001 0.0000 0.0001 0.0004 0.0007 0.0008 0.0006 0.0001 0.0000 0.0001 0.0004 0.0007 0.0008 0.0005 0.0001 0.0000 0.0001 0.0003 0.0007 0.0008 0.0005 0.0001 0.0000 0.0001 0.0003 0.0007 0.0008 0.0005 0.0001 0.0000 0.0001 0.0003 0.0007 0.0008 0.0005 0.0002 0.0000 0.0001 0.0003 0.0006 0.0008 0.0005 0.0001 0.0000 0.0000 0.0002 0.0006 0.0009 0.0008 0.0001 0.0000 0.0000 0.0002 0.0005 0.0008 0.0007 0.0001 0.0000 0.0000 0.0001 0.0005 0.0008 0.0006 0.0001 0.0000 0.0000 0.0001 0.0004 0.0008 0.0006 0.0002 0.0000 0.0000 0.0001 0.0004 0.0009 0.0005 0.0002 0.0000 0.0000 0.0000 0.0003 0.0010 0.0005 0.0001 0.0000 0.0000 0.0000 0.0001 0.0011 0.0048 0.0028 (:,:,2) = 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0001 0.0002 0.0000 0.0000 0.0000 0.0000 0.0000 0.0001 0.0003 0.0003 0.0001 0.0000 0.0000 0.0000 0.0004 0.0008 0.0005 0.0001 0.0000 0.0000 0.0001 0.0010 0.0021 0.0012 0.0002 0.0000 0.0000 0.0002 0.0026 0.0058 0.0026 0.0005 0.0000 0.0000 0.0003 0.0012 0.0051 0.0045 0.0014 0.0001 0.0000 0.0007 0.0054 0.0108 0.0088 0.0026 0.0002 0.0000 0.0011 0.0052 0.0104 0.0112 0.0039 0.0003 0.0000 0.0010 0.0055 0.0123 0.0165 0.0058 0.0006 0.0000 0.0006 0.0034 0.0102 0.0289 0.0255 0.0026 0.0001 0.0008 0.0064 0.0143 0.0087 0.0044 0.0006 0.0000 0.0009 0.0018 0.0037 0.0047 0.0029 0.0007 0.0000 0.0002 0.0014 0.0036 0.0049 0.0045 0.0023 0.0001 0.0002 0.0015 0.0036 0.0045 0.0028 0.0007 0.0000 0.0002 0.0015 0.0036 0.0047 0.0030 0.0008 0.0000 0.0002 0.0015 0.0037 0.0050 0.0043 0.0021 0.0001 0.0002 0.0015 0.0037 0.0047 0.0030 0.0008 0.0000 0.0002 0.0015 0.0037 0.0049 0.0032 0.0009 0.0001 0.0002 0.0014 0.0038 0.0052 0.0043 0.0019 0.0001 0.0002 0.0014 0.0038 0.0050 0.0033 0.0009 0.0001 0.0002 0.0014 0.0038 0.0054 0.0035 0.0010 0.0001 0.0002 0.0013 0.0038 0.0058 0.0045 0.0018 0.0001 0.0002 0.0011 0.0036 0.0062 0.0040 0.0010 0.0001 0.0001 0.0009 0.0031 0.0072 0.0129 0.0020 0.0001 0.0001 0.0008 0.0022 0.0034 0.0031 0.0024 0.0002 0.0001 0.0007 0.0021 0.0033 0.0028 0.0018 0.0002 0.0001 0.0007 0.0020 0.0033 0.0026 0.0020 0.0002 0.0001 0.0006 0.0018 0.0037 0.0023 0.0015 0.0001 0.0001 0.0005 0.0013 0.0019 0.0020 0.0017 0.0002 0.0001 0.0005 0.0013 0.0018 0.0018 0.0013 0.0001 0.0001 0.0005 0.0013 0.0017 0.0017 0.0014 0.0001 0.0001 0.0005 0.0013 0.0016 0.0015 0.0011 0.0002 0.0001 0.0004 0.0015 0.0014 0.0015 0.0012 0.0002 0.0001 0.0003 0.0007 0.0012 0.0014 0.0010 0.0002 0.0000 0.0004 0.0007 0.0012 0.0013 0.0010 0.0002 0.0000 0.0002 0.0006 0.0011 0.0013 0.0009 0.0001 0.0000 0.0002 0.0006 0.0011 0.0012 0.0009 0.0002 0.0000 0.0001 0.0005 0.0011 0.0012 0.0008 0.0001 0.0000 0.0001 0.0005 0.0010 0.0012 0.0008 0.0001 0.0000 0.0001 0.0005 0.0010 0.0012 0.0007 0.0002 0.0000 0.0001 0.0004 0.0010 0.0012 0.0008 0.0003 0.0000 0.0001 0.0004 0.0009 0.0013 0.0007 0.0002 0.0000 0.0001 0.0003 0.0009 0.0013 0.0012 0.0002 0.0000 0.0000 0.0003 0.0008 0.0013 0.0011 0.0002 0.0000 0.0000 0.0002 0.0007 0.0012 0.0009 0.0001 0.0000 0.0000 0.0002 0.0007 0.0012 0.0009 0.0002 0.0000 0.0000 0.0001 0.0006 0.0013 0.0008 0.0002 0.0000 0.0000 0.0000 0.0004 0.0015 0.0008 0.0002 0.0000 0.0000 0.0000 0.0002 0.0017 0.0071 0.0042 ans = 3.5607