Testing function hhsave_VFI_3OC
Check if VF/PF generated by hhsave_VFI_2OC change correctly with changing parameters phi, R, w, delta, alpha, theta, risk.
addpath(genpath('/Users/sidhantkhanna/Documents/GitHub/BKS modified/')); fl_ahi = 50; fl_zhi = 2.2; it_agridno = 200; it_zgridno = 7; it_ngridno = 2; fl_alo = 0; mp_grid_control = containers.Map('KeyType','char', 'ValueType','any'); mp_grid_control('grid_powerspace_power') = 1; ar_a = ff_saveborr_grid(fl_alo, fl_ahi, it_agridno, 'grid_powerspace',mp_grid_control); ar_a = ar_a'; fl_phi = 1; fl_risk = 3; fl_alpha = 0.4; fl_theta = 0.79-fl_alpha; fl_delta = 0.05; 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.1; 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'; fl_chi = 0.25; mt_trans_n = [fl_chi,1-fl_chi;fl_chi,1-fl_chi]; ar_n = [0,1]; [fl_r,fl_w] = ... deal(0.04,1.5); fl_tolvfi = 10^-12; bl_print = true; bl_plot = true; ar_z = ar_z'; fl_R = fl_r + fl_delta; % Changing with phi n=1; for chi = 0.25:0.5:0.75 fl_chi = chi; mt_trans_n = [fl_chi,1-fl_chi;fl_chi,1-fl_chi]; disp (strcat('phi =', num2str(fl_phi))); [mt_vf, mt_pf, mt_oploc,mt_coh, mt_o, mt_k, mt_l] = hhsave_VFI_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); mt_savefraccoh = mt_pf./mt_coh; mt_con = mt_coh - mt_pf; figure(n); for i = 1: it_zgridno a(i) = plot((mt_vf(:,i,1)), '.'); b{i} = sprintf(['Z shock =', num2str(ar_z(i))]); hold on end clr = jet(numel(a)); for m = 1:numel(a) set(a(m),'Color',clr(m,:)) end legend(b,'Location','South') xlabel('Present Assets','FontSize', 20) ; ylabel('Value', 'FontSize', 20); ylim([-100 10]) %title('OC with option to work','FontSize',30); xt = get(gca, 'XTick'); set(gca, 'XTick', xt, 'XTickLabel', xt*fl_ahi/it_agridno,'FontSize',20); snapnow; st_file_name = sprintf([ '/Users/sidhantkhanna/Documents/GitHub/BKS modified/code/Households/figures/tester_hhsave_VFI_3OC/VF_0_chi', num2str(fl_phi),'.png']); saveas(gcf,st_file_name ); figure(n+1) %chart = plot(mt_vf); for i = 1: it_zgridno a(i) = plot((mt_vf(:,i,2)),'.'); b{i} = sprintf(['Z shock =', num2str(ar_z(i))]); hold on end clr = jet(numel(a)); for m = 1:numel(a) set(a(m),'Color',clr(m,:)) end legend(b,'Location','South') %clr = jet(numel(chart)); %for m = 1:numel(chart) % set(chart(m),'Color',clr(m,:)) %end xlabel('Present Assets','FontSize', 20) ; ylabel('Value', 'FontSize', 20); xt = get(gca, 'XTick'); set(gca, 'XTick', xt, 'XTickLabel', xt*fl_ahi/it_agridno,'FontSize',20); ylim([-100 10]) snapnow; st_file_name = sprintf([ '/Users/sidhantkhanna/Documents/GitHub/BKS modified/code/Households/figures/tester_hhsave_VFI_3OC/VF_1_chi', num2str(fl_phi),'.png']); saveas(gcf,st_file_name ); figure(n+2) for i = 1: it_zgridno a(i) = plot(mt_savefraccoh(:,i,1),'-o'); b{i} = sprintf(['Z shock =', num2str(ar_z(i))]); hold on end clr = jet(numel(a)); for m = 1:numel(a) set(a(m),'Color',clr(m,:)) end legend(b,'Location','South') xlabel('Present Assets','FontSize', 20) ; ylabel('SavingsfracCOH','FontSize', 20); ylim([0 1]) xt = get(gca, 'XTick'); set(gca, 'XTick', xt, 'XTickLabel', xt*fl_ahi/it_agridno,'FontSize',20); snapnow; st_file_name = sprintf([ '/Users/sidhantkhanna/Documents/GitHub/BKS modified/code/Households/figures/tester_hhsave_VFI_3OC/SC_0_chi', num2str(fl_phi),'.png']); saveas(gcf,st_file_name ); figure(n+3) for i = 1: it_zgridno a(i) = plot(mt_savefraccoh(:,i,2),'-o'); b{i} = sprintf(['Z shock =', num2str(ar_z(i))]); hold on end clr = jet(numel(a)); for m = 1:numel(a) set(a(m),'Color',clr(m,:)) end legend(b,'Location','South') xlabel('Present Assets') ; ylabel('SavingsfracCOH'); ylim([0 1]) xt = get(gca, 'XTick'); set(gca, 'XTick', xt, 'XTickLabel', xt*fl_ahi/it_agridno,'FontSize',20); snapnow; st_file_name = sprintf([ '/Users/sidhantkhanna/Documents/GitHub/BKS modified/code/Households/figures/tester_hhsave_VFI_3OC/SC_1_chi', num2str(fl_phi),'.png']); saveas(gcf,st_file_name ); n=n+4; end
phi =1
phi =1