Contents
- Testing function optikl
- Parameter Setting
- A and Z array setting
- Arrays of r and w
- Test how k star reacts to different rs (fixing everything else)
- Test how k star reacts to different ws (fixing everything else)
- Test how k star reacts to different phis (fixing everything else)
- Test how k star reacts to different deltas (fixing everything else)
- Test how k star reacts to different kappas (fixing everything else)
- Test how k star reacts to different alpha (and theta resp) (fixing everything else)
- Test how k starstriant react to different ws amd rs
Testing function optikl
Check if starstrained k and l as generated by optikl.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. Plug in phi = 1 for unconstrained case.
addpath(genpath('/Users/sidhantkhanna/Documents/GitHub/BKS modified/'));
Parameter Setting
it_k_n = 20000; fl_phi = 0.5; fl_alpha = 0.4; fl_theta = 0.79-fl_alpha; fl_delta = 0.06; fl_kappa = 0; fl_r = 0.04; fl_w = 1.5;
A and Z array setting
ar_a = 2; ar_z = 3; fl_ahi = ar_a; fl_zhi = ar_z; 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 star reacts to different rs (fixing everything else)
as r increases, k star should fall, and l star should also fall (check with plotstarkl.m)
ar_k_star_overr = zeros(size(ar_r)); ar_l_star_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_star, fl_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); ar_k_star_overr(it_ctr) = fl_k_star; ar_l_star_overr(it_ctr) = fl_l_star; end % display tb_opti_over_r = table(ar_r', ar_k_star_overr', ar_l_star_overr'); tb_opti_over_r.Properties.VariableNames = {'ar_r', 'kstar', 'lstar'}; disp(tb_opti_over_r) fl_r = fl_r1;
ar_r kstar lstar ________ ______ ______ 0.03 9.9793 3.0078 0.033333 9.899 2.9919 0.036667 9.8201 2.9763 0.04 9.7427 2.9609 0.043333 9.6666 2.9457 0.046667 9.5919 2.9307 0.05 9.5185 2.916 0.053333 9.4463 2.9015 0.056667 9.3754 2.8872 0.06 9.3057 2.8731
Test how k star reacts to different ws (fixing everything else)
as w increase, k star should fall, and l star should also fall
ar_k_star_overw = zeros(size(ar_w)); ar_l_star_overw = zeros(size(ar_w)); fl_w1 = fl_w; it_ctr = 0; for fl_w = ar_w it_ctr = it_ctr + 1; [fl_k_star, fl_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); ar_k_star_overw(it_ctr) = fl_k_star; ar_l_star_overw(it_ctr) = fl_l_star; end % display tb_opti_over_w = table(ar_w', ar_k_star_overw', ar_l_star_overw'); tb_opti_over_w.Properties.VariableNames = {'ar_w', 'kstar', 'lstar'}; disp(tb_opti_over_w) fl_w = fl_w1;
ar_w kstar lstar ______ ______ ______ 1.5 9.7427 2.9609 1.5714 9.445 2.6882 1.6429 9.1774 2.4526 1.7143 8.9356 2.2476 1.7857 8.7161 2.0681 1.8571 8.5159 1.91 1.9286 8.3326 1.77 2 8.164 1.6454
Test how k star reacts to different phis (fixing everything else)
as phi falls, k star should fall, and l star should also fall
if(fl_phi~=1) fl_phi1= fl_phi; ar_k_star_overw = zeros(size(ar_phi)); ar_l_star_overw = zeros(size(ar_phi)); it_ctr = 0; for fl_phi = ar_phi it_ctr = it_ctr + 1; [fl_k_star, fl_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); ar_k_star_overphi(it_ctr) = fl_k_star; ar_l_star_overphi(it_ctr) = fl_l_star; end % display tb_opti_over_phi = table(ar_phi', ar_k_star_overphi', ar_l_star_overphi'); tb_opti_over_phi.Properties.VariableNames = {'ar_phi', 'kstar', 'lstar'}; disp(tb_opti_over_phi) fl_phi =fl_phi1; end
ar_phi kstar lstar _______ ______ ______ 0 2.08 1.0757 0.11111 2.5674 1.2349 0.22222 3.4414 1.4965 0.33333 4.8902 1.8842 0.44444 7.5355 2.5019 0.55556 13.041 3.5848 0.66667 26.772 5.745 0.77778 71.172 10.908 0.88889 289.18 27.352 1 859.74 55.883
Test how k star reacts to different deltas (fixing everything else)
as delta rises, k star should fall, and l star should also fall
ar_k_star_overdelta = zeros(size(ar_delta)); ar_l_star_overdelta = zeros(size(ar_delta)); fl_delta1 = fl_delta; it_ctr = 0; for fl_delta = ar_delta it_ctr = it_ctr + 1; [fl_k_star, fl_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); ar_k_star_overdelta(it_ctr) = fl_k_star; ar_l_star_overdelta(it_ctr) = fl_l_star; end % display tb_opti_over_delta = table(ar_delta', ar_k_star_overdelta', ar_l_star_overdelta'); tb_opti_over_delta.Properties.VariableNames = {'ar_delta', 'kstar', 'lstar'}; disp(tb_opti_over_delta) fl_delta1 = fl_delta;
ar_delta kstar lstar ________ ______ ______ 0 10.686 3.1458 0.011111 10.499 3.1097 0.022222 10.318 3.0745 0.033333 10.143 3.0401 0.044444 9.9727 3.0065 0.055556 9.8075 2.9738 0.066667 9.6469 2.9418 0.077778 9.491 2.9105 0.088889 9.3394 2.8799 0.1 9.1921 2.8501
Test how k star reacts to different kappas (fixing everything else)
as kappa rises, k star should fall, and l star should also fall
ar_k_star_overkappa = zeros(size(ar_delta)); ar_l_star_overkappa = zeros(size(ar_delta)); fl_kappa1 = fl_kappa; it_ctr = 0; for fl_kappa = ar_kappa it_ctr = it_ctr + 1; [fl_k_star, fl_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); ar_k_star_overkappa(it_ctr) = fl_k_star; ar_l_star_overkappa(it_ctr) = fl_l_star; end % display tb_opti_over_kappa = table(ar_kappa', ar_k_star_overkappa', ar_l_star_overkappa'); tb_opti_over_kappa.Properties.VariableNames = {'ar_kappa', 'kstar', 'lstar'}; disp(tb_opti_over_kappa) fl_kappa = fl_kappa1;
ar_kappa kstar lstar ________ ______ ______ 0 9.1921 2.8501 0.33333 8.1925 2.6428 0.66667 7.1612 2.4196 1 6.0875 2.1752 1.3333 4.9528 1.9 1.6667 3.7172 1.574 2 2.2551 1.1342 2.3333 0 0 2.6667 0 0 3 0 0
Test how k star reacts to different alpha (and theta resp) (fixing everything else)
as delta rises, k star should fall, and l star should also fall
ar_k_star_overalpha = zeros(size(ar_alpha)); ar_l_star_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_star, fl_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); ar_k_star_overalpha(it_ctr) = fl_k_star; ar_l_star_overalpha(it_ctr) = fl_l_star; end % display tb_opti_over_alpha = table(ar_alpha', ar_k_star_overalpha', ar_l_star_overalpha'); tb_opti_over_alpha.Properties.VariableNames = {'ar_alpha', 'kstar', 'lstar'}; disp(tb_opti_over_alpha) fl_alpha = fl_alpha1;
ar_alpha kstar lstar ________ ______ ______ 0.1 6.474 5.1629 0.16667 6.7324 4.175 0.23333 7.1602 3.5903 0.3 7.7746 3.2116 0.36667 8.6355 2.951 0.43333 9.8619 2.7635 0.5 11.687 2.6224 0.56667 14.601 2.5055 0.63333 19.788 2.3767 0.7 30.782 2.1206
Test how k starstriant react to different ws amd rs
as w increase, k star should fall, and l star should also fall
mt_k_star_overw = zeros(size(ar_w)); mt_l_star_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_star, fl_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); mt_k_star_overwr(it_ctr_w, it_ctr_r) = fl_k_star; mt_l_star_overwr(it_ctr_w, it_ctr_r) = fl_l_star; end end [mt_r, mt_w] = meshgrid(ar_r, ar_w); disp('mt_k_star_overwr'); disp(mt_k_star_overwr); disp('mt_l_star_overwr'); disp(mt_l_star_overwr); % Graph figure(1) surf(mt_w, mt_r, mt_k_star_overwr); title('k star varying over r and w (fixing a and z)'); xlabel('w'); ylabel('r'); zlabel('k star'); view(125,35); if(bl_saveimg) saveas(gcf, '/Users/sidhantkhanna/Documents/GitHub/BKS modified/code/Firms/figures/optikl/kstar_rw.png') end % Graph figure(2) surf(mt_w, mt_r, mt_l_star_overwr); title(' k star varying over r and w (fixing a and z)'); xlabel('w'); ylabel('r'); zlabel('l star'); view(125,35); if(bl_saveimg) saveas(gcf, '/Users/sidhantkhanna/Documents/GitHub/BKS modified/code/Firms/figures/optikl/lstar_rw.png') end
mt_k_star_overwr Columns 1 through 7 8.6898 8.6382 8.5874 8.5373 8.4878 8.4391 8.3910 8.6580 8.6067 8.5561 8.5063 8.4571 8.4087 8.3609 8.6278 8.5768 8.5265 8.4769 8.4280 8.3798 8.3323 8.5991 8.5483 8.4983 8.4490 8.4003 8.3524 8.3051 8.5717 8.5212 8.4714 8.4223 8.3739 8.3262 8.2791 8.5455 8.4953 8.4457 8.3969 8.3487 8.3012 8.2543 8.5205 8.4705 8.4212 8.3725 8.3246 8.2773 8.2307 8.4966 8.4468 8.3976 8.3492 8.3015 8.2544 8.2080 Columns 8 through 10 8.3436 8.2969 8.2507 8.3137 8.2672 8.2214 8.2854 8.2391 8.1935 8.2584 8.2124 8.1670 8.2327 8.1869 8.1417 8.2081 8.1626 8.1176 8.1847 8.1393 8.0945 8.1622 8.1170 8.0724 mt_l_star_overwr Columns 1 through 7 0.3930 0.3920 0.3909 0.3899 0.3889 0.3880 0.3870 0.3728 0.3718 0.3709 0.3699 0.3690 0.3680 0.3671 0.3545 0.3536 0.3526 0.3517 0.3508 0.3500 0.3491 0.3378 0.3369 0.3360 0.3352 0.3343 0.3335 0.3327 0.3225 0.3217 0.3208 0.3200 0.3192 0.3184 0.3176 0.3085 0.3077 0.3069 0.3061 0.3053 0.3046 0.3038 0.2956 0.2948 0.2941 0.2933 0.2926 0.2918 0.2911 0.2836 0.2829 0.2822 0.2815 0.2808 0.2801 0.2794 Columns 8 through 10 0.3860 0.3851 0.3841 0.3662 0.3653 0.3644 0.3482 0.3474 0.3465 0.3318 0.3310 0.3302 0.3168 0.3161 0.3153 0.3031 0.3023 0.3016 0.2904 0.2897 0.2890 0.2787 0.2780 0.2773