Contents

Testing function con_kl

Check if constrained k and l as generated by con_kl.m move in the right direction with changing parameters phi, R, w and delta. Calls con_kl for a single combination of a and z

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

Parameter Setting

it_k_n   = 20000;
fl_phi   = 0.5;
fl_r     = 0.04;
fl_w     = 1.5;

fl_alpha = 0.4;
fl_theta = 0.79-fl_alpha;
fl_delta = 0.06;
fl_kappa = 1;

A and Z array setting

fl_a       = 2;
fl_z       = 3;
fl_ahi     = 1;
fl_zhi     = 1;
it_zgridno = 1;
it_agridno = 1;

Arrays of r and w

ar_r       = linspace(0.03, 0.06, 10);
ar_w       = linspace(1.5, 2, 8);
ar_phi     = linspace(0, 1, 10);
ar_delta   = linspace(0, 0.1, 10);
ar_alpha   = linspace(0.1, 0.7, 10);
ar_kappa   = linspace(0, 3, 10);

Test how k constraint reacts to different rs (fixing everything else)

as r increases, k con should fall, and l con should also fall (check with plotconkl.m)

ar_k_con_overr = zeros(size(ar_r));
ar_l_con_overr = zeros(size(ar_r));
bl_saveimg = true;
fl_r1=fl_r;
it_ctr = 0;
for fl_r = ar_r
    it_ctr = it_ctr + 1;

    [fl_k_con, fl_l_con] = con_kl(fl_a,fl_z,fl_a,fl_z, ...
        fl_ahi,fl_zhi, fl_phi,fl_theta,fl_alpha,fl_w,fl_r,fl_delta,...
        fl_kappa,it_agridno,it_zgridno);

    ar_k_con_overr(it_ctr) = fl_k_con;
    ar_l_con_overr(it_ctr) = fl_l_con;
end

% display
tb_opti_over_r = table(ar_r', ar_k_con_overr', ar_l_con_overr');
tb_opti_over_r.Properties.VariableNames = {'ar_r', 'kcon', 'lcon'};
disp(tb_opti_over_r)

fl_r=fl_r1;
      ar_r       kcon      lcon 
    ________    ______    ______

        0.03    6.6837    2.3126
    0.033333    6.6198    2.2981
    0.036667    6.5572    2.2838
        0.04    6.4958    2.2698
    0.043333    6.4355    2.2559
    0.046667    6.3765    2.2423
        0.05    6.3185    2.2289
    0.053333    6.2616    2.2158
    0.056667    6.2057    2.2028
        0.06    6.1509      2.19

Test how k constraint reacts to different ws (fixing everything else)

as w increase, k con should fall, and l con should also fall

ar_k_con_overw = zeros(size(ar_w));
ar_l_con_overw = zeros(size(ar_w));
fl_w1=fl_w;

it_ctr = 0;
for fl_w = ar_w
    it_ctr = it_ctr + 1;

    [fl_k_con, fl_l_con] = con_kl(fl_a,fl_z,fl_a,fl_z, ...
        fl_ahi,fl_zhi, fl_phi,fl_theta,fl_alpha,fl_w,fl_r,fl_delta,...
        fl_kappa,it_agridno,it_zgridno);

    ar_k_con_overw(it_ctr) = fl_k_con;
    ar_l_con_overw(it_ctr) = fl_l_con;
end

% display
tb_opti_over_w = table(ar_w', ar_k_con_overw', ar_l_con_overw');
tb_opti_over_w.Properties.VariableNames = {'ar_w', 'kcon', 'lcon'};
disp(tb_opti_over_w)

fl_w=fl_w1;
     ar_w      kcon      lcon 
    ______    ______    ______

       1.5    6.4958    2.2698
    1.5714    6.2419    2.0488
    1.6429    6.0152    1.8592
    1.7143    5.8117    1.6952
    1.7857    5.6281    1.5524
    1.8571    5.4615    1.4274
    1.9286    5.3099    1.3172
         2    5.1712    1.2196

Test how k constraint reacts to different phis (fixing everything else)

as phi falls, k con should fall, and l con should also fall

ar_k_con_overw = zeros(size(ar_phi));
ar_l_con_overw = zeros(size(ar_phi));

fl_phi1=fl_phi;

it_ctr = 0;
for fl_phi = ar_phi
    it_ctr = it_ctr + 1;

    [fl_k_con, fl_l_con] = con_kl(fl_a,fl_z,fl_a,fl_z, ...
        fl_ahi,fl_zhi, fl_phi,fl_theta,fl_alpha,fl_w,fl_r,fl_delta,...
        fl_kappa,it_agridno,it_zgridno);

    ar_k_con_overphi(it_ctr) = fl_k_con;
    ar_l_con_overphi(it_ctr) = fl_l_con;
end

% display
tb_opti_over_phi = table(ar_phi', ar_k_con_overphi', ar_l_con_overphi');
tb_opti_over_phi.Properties.VariableNames = {'ar_phi', 'kcon', 'lcon'};
disp(tb_opti_over_phi)

fl_phi=fl_phi1;
    ar_phi      kcon      lcon  
    _______    ______    _______

          0      1.04    0.68277
    0.11111    1.3358    0.80457
    0.22222    1.8836     1.0079
    0.33333    2.8565     1.3244
    0.44444    4.7837     1.8572
    0.55556    9.1737     2.8463
    0.66667    21.132     4.9195
    0.77778    62.612     10.029
    0.88889    275.13     26.473
          1    2959.1     125.68

Test how k constraint reacts to different deltas (fixing everything else)

as delta rises, k con should fall, and l con should also fall

ar_k_con_overdelta = zeros(size(ar_delta));
ar_l_con_overdelta = zeros(size(ar_delta));

fl_delta1=fl_delta;

it_ctr = 0;
for fl_delta = ar_delta
    it_ctr = it_ctr + 1;

    [fl_k_con, fl_l_con] = con_kl(fl_a,fl_z,fl_a,fl_z, ...
        fl_ahi,fl_zhi, fl_phi,fl_theta,fl_alpha,fl_w,fl_r,fl_delta,...
        fl_kappa,it_agridno,it_zgridno);

    ar_k_con_overdelta(it_ctr) = fl_k_con;
    ar_l_con_overdelta(it_ctr) = fl_l_con;
end

% display
tb_opti_over_delta = table(ar_delta', ar_k_con_overdelta', ar_l_con_overdelta');
tb_opti_over_delta.Properties.VariableNames = {'ar_delta', 'kcon', 'lcon'};
disp(tb_opti_over_delta)

fl_delta=fl_delta1;
    ar_delta     kcon      lcon 
    ________    ______    ______

           0    7.2018    2.4286
    0.011111    7.0616    2.3975
    0.022222    6.9259    2.3672
    0.033333    6.7945    2.3377
    0.044444    6.6673    2.3089
    0.055556     6.544    2.2808
    0.066667    6.4246    2.2534
    0.077778    6.3088    2.2267
    0.088889    6.1965    2.2006
         0.1    6.0875    2.1752

Test how k constraint reacts to different kappas (fixing everything else)

as kappa rises, k con should fall, and l con should also fall

fl_kappa1=fl_kappa;

ar_k_con_overkappa = zeros(size(ar_kappa));
ar_l_con_overkappa = zeros(size(ar_kappa));


it_ctr = 0;
for fl_kappa = ar_kappa
    it_ctr = it_ctr + 1;

    [fl_k_con, fl_l_con] = con_kl(fl_a,fl_z,fl_a,fl_z, ...
        fl_ahi,fl_zhi, fl_phi,fl_theta,fl_alpha,fl_w,fl_r,fl_delta,...
        fl_kappa,it_agridno,it_zgridno);

    ar_k_con_overkappa(it_ctr) = fl_k_con;
    ar_l_con_overkappa(it_ctr) = fl_l_con;
end

% display
tb_opti_over_kappa = table(ar_kappa', ar_k_con_overkappa', ar_l_con_overkappa');
tb_opti_over_kappa.Properties.VariableNames = {'ar_kappa', 'kcon', 'lcon'};
disp(tb_opti_over_kappa)

fl_kappa=fl_kappa1;
    ar_kappa     kcon      lcon 
    ________    ______    ______

          0     9.7427    2.9609
    0.33333     8.6975    2.7485
    0.66667      7.619      2.52
          1     6.4958    2.2698
     1.3333     5.3085    1.9884
     1.6667     4.0162     1.656
          2     2.4927    1.2112
     2.3333          0         0
     2.6667          0         0
          3          0         0

Test how k constraint reacts to different alpha (and theta resp) (fixing everything else)

as alpha rises, k con should rise, and l con should also rise

ar_k_con_overalpha = zeros(size(ar_alpha));
ar_l_con_overalpha = zeros(size(ar_alpha));

fl_alpha1=fl_alpha;

it_ctr = 0;
for fl_alpha = ar_alpha
    fl_theta = 0.79-fl_alpha;
    it_ctr = it_ctr + 1;

    [fl_k_con, fl_l_con] = con_kl(fl_a,fl_z,fl_a,fl_z, ...
        fl_ahi,fl_zhi, fl_phi,fl_theta,fl_alpha,fl_w,fl_r,fl_delta,...
        fl_kappa,it_agridno,it_zgridno);

    ar_k_con_overalpha(it_ctr) = fl_k_con;
    ar_l_con_overalpha(it_ctr) = fl_l_con;
end

% display
tb_opti_over_alpha = table(ar_alpha', ar_k_con_overalpha', ar_l_con_overalpha');
tb_opti_over_alpha.Properties.VariableNames = {'ar_alpha', 'kcon', 'lcon'};
disp(tb_opti_over_alpha)

fl_alpha=fl_alpha1;
    ar_alpha     kcon      lcon 
    ________    ______    ______

        0.1      4.548    4.6071
    0.16667       4.64     3.541
    0.23333      4.909    2.9434
        0.3     5.3578      2.58
    0.36667     6.0373    2.3504
    0.43333     7.0624    2.2069
        0.5     8.6708    2.1252
    0.56667     11.387    2.0898
    0.63333     16.532    2.0765
        0.7     28.196    1.9822

Test how k constriant react to different ws amd rs

as w increase, k con should fall, and l con should also fall

mt_k_con_overw = zeros(size(ar_w));
mt_l_con_overw = zeros(size(ar_w));

it_ctr_w = 0;
for fl_w = ar_w
    it_ctr_w = it_ctr_w + 1;

    it_ctr_r = 0;
    for fl_r = ar_r
        it_ctr_r = it_ctr_r + 1;

        [fl_k_con, fl_l_con] = con_kl(fl_a,fl_z,fl_a,fl_z, ...
        fl_ahi,fl_zhi, fl_phi,fl_theta,fl_alpha,fl_w,fl_r,fl_delta,...
        fl_kappa,it_agridno,it_zgridno);

        mt_k_con_overwr(it_ctr_w, it_ctr_r) = fl_k_con;
        mt_l_con_overwr(it_ctr_w, it_ctr_r) = fl_l_con;

    end
end

[mt_r, mt_w] = meshgrid(ar_r, ar_w);


disp('mt_k_con_overwr');
disp(mt_k_con_overwr);
disp('mt_l_con_overwr');
disp(mt_l_con_overwr);


% Graph
figure(1)
surf(mt_w, mt_r, mt_k_con_overwr);
title('Constraint k varying over r and w (fixing a and z)');
xlabel('w');
ylabel('r');
zlabel('k con');
view(125,35);
if(bl_saveimg)
saveas(gcf, '/Users/sidhantkhanna/Documents/GitHub/BKS modified/code/Firms/figures/con_kl/Kconst_rw.png')
end

% Graph
figure(2)
surf(mt_w, mt_r, mt_l_con_overwr);
title('Constraint k varying over r and w (fixing a and z)');
xlabel('w');
ylabel('r');
zlabel('l con');
view(125,35);
if(bl_saveimg)
saveas(gcf, '/Users/sidhantkhanna/Documents/GitHub/BKS modified/code/Firms/figures/con_kl/Lconst_rw.png')
end
mt_k_con_overwr
  Columns 1 through 7

    6.5340    6.4862    6.4392    6.3929    6.3472    6.3023    6.2580
    6.5026    6.4551    6.4084    6.3623    6.3170    6.2724    6.2284
    6.4727    6.4256    6.3791    6.3334    6.2883    6.2440    6.2002
    6.4444    6.3975    6.3513    6.3059    6.2611    6.2170    6.1735
    6.4174    6.3708    6.3248    6.2796    6.2351    6.1912    6.1480
    6.3916    6.3452    6.2996    6.2546    6.2103    6.1667    6.1237
    6.3669    6.3208    6.2754    6.2307    6.1866    6.1432    6.1005
    6.3433    6.2974    6.2522    6.2077    6.1639    6.1207    6.0782

  Columns 8 through 10

    6.2144    6.1714    6.1291
    6.1850    6.1423    6.1002
    6.1572    6.1147    6.0729
    6.1307    6.0885    6.0469
    6.1055    6.0635    6.0222
    6.0814    6.0397    5.9986
    6.0584    6.0169    5.9760
    6.0363    5.9950    5.9543

mt_l_con_overwr
  Columns 1 through 7

    0.3467    0.3456    0.3445    0.3434    0.3423    0.3412    0.3402
    0.3287    0.3277    0.3266    0.3256    0.3246    0.3235    0.3225
    0.3124    0.3114    0.3104    0.3094    0.3085    0.3075    0.3066
    0.2976    0.2966    0.2957    0.2947    0.2938    0.2929    0.2920
    0.2840    0.2831    0.2822    0.2813    0.2804    0.2795    0.2787
    0.2715    0.2707    0.2698    0.2689    0.2681    0.2673    0.2665
    0.2600    0.2592    0.2584    0.2576    0.2568    0.2560    0.2552
    0.2495    0.2487    0.2479    0.2471    0.2463    0.2456    0.2448

  Columns 8 through 10

    0.3391    0.3381    0.3371
    0.3216    0.3206    0.3196
    0.3056    0.3047    0.3038
    0.2911    0.2902    0.2893
    0.2778    0.2770    0.2762
    0.2656    0.2648    0.2641
    0.2544    0.2537    0.2529
    0.2441    0.2433    0.2426