This is a static copy of a profile report

Home

hhsave_dis_3OC (Calls: 1, Time: 5.204 s)
Generated 18-Jul-2020 08:10:33 using performance time.
function in file /Users/sidhantkhanna/Documents/GitHub/BKS modified/code/Households/hhsave_dis_3OC.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
PE_3OCfunction1
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
97
fl_lambda_z, fl_tolvfi ...
13.038 s58.4%
119
P(f,g,h,it_s+1)= P(f,g,h,it_s+...
47824000.492 s9.5%
26
addpath(genpath('/Users/sidhan...
10.473 s9.1%
116
f=find((ar_a==mt_pf(i,j,c))); 
3416000.434 s8.3%
120
end
47824000.324 s6.2%
All other lines  0.442 s8.5%
Totals  5.204 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
hhsave_VFI_3OCfunction13.037 s58.4%
genpathfunction10.272 s5.2%
addpathfunction10.200 s3.9%
Self time (built-ins, overhead, etc.)  1.694 s32.5%
Totals  5.204 s100% 
Code Analyzer results
Line numberMessage
20The value assigned to variable 'bl_saveimg' might be unused.
37The value assigned to variable 'bl_plot' might be unused.
85The value assigned to variable 'fl_R' might be unused.
88The value assigned to variable 'it_s' might be unused.
90The value assigned to variable 'fl_crit1' might be unused.
94The value assigned here to 'mt_vf' appears to be unused. Consider replacing it by ~.
94The value assigned here to 'mt_oploc' appears to be unused. Consider replacing it by ~.
94The value assigned here to 'mt_coh' appears to be unused. Consider replacing it by ~.
117FOR might not be aligned with its matching END (line 121).
118FOR might not be aligned with its matching END (line 120).
125The variable 'fl_sum1' appears to change size on every loop iteration. Consider preallocating for speed.
132The value assigned to variable 'fl_Ea' might be unused.
142The variable 'st_a' appears to change size on every loop iteration. Consider preallocating for speed.
Coverage results
Show coverage for parent directory
Total lines in function146
Non-code lines (comments, blank lines)35
Code lines (lines that can run)111
Code lines that did run50
Code lines that did not run61
Coverage (did run/can run)45.05 %
Function listing
time 
Calls 
 line
  15 
function [mt_dis, mt_o, mt_k, mt_l]= hhsave_dis_3OC(varargin)
  16 
addpath(genpath('/Users/sidhantkhanna/Documents/GitHub/BKS modified/'));
  17 

  18 
close all;
  19 
bl_profile = true;      % Switch off profile if running a tester/calling from another function
  20 
bl_saveimg = false;
  21 
if(bl_profile)
  22 
profile off;
  23 
profile on;
< 0.001 
      1 
  24
end 
  25 

  0.473 
      1 
  26
addpath(genpath('/Users/sidhantkhanna/Documents/GitHub/BKS modified/')); 
  27 

< 0.001 
      1 
  28
if ~isempty(varargin) 
  29 
    
< 0.001 
      1 
  30
    [ar_a,ar_z,ar_n, ... 
      1 
  31
        fl_alpha,fl_theta,fl_delta,fl_kappa,fl_r,fl_w,fl_phi,fl_ahi,fl_zhi, ... 
      1 
  32
         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,... 
      1 
  33
         fl_lambda_z, fl_tolvfi,  fl_toldis ... 
      1 
  34
        ] = varargin{:}; 
  35 
    
< 0.001 
      1 
  36
    bl_print  = false; 
< 0.001 
      1 
  37
    bl_plot   = false; 
  38 

  39 
    
  40 
else
  41 
    fl_alo         = 0;
  42 
    fl_ahi         = 10;
  43 
    fl_zhi         = 2;
  44 
    it_agridno     = 100;
  45 
    it_zgridno     = 7;
  46 
    it_ngridno     = 2;
  47 
   %ar_a           = linspace(0,fl_ahi,it_agridno);
  48 
    mp_grid_control = containers.Map('KeyType','char', 'ValueType','any');
  49 
    mp_grid_control('grid_powerspace_power') = 2;
  50 
 %  ar_a            = ff_saveborr_grid(fl_alo, fl_ahi, it_agridno,  mp_grid_control)
  51 
    ar_a           = ff_saveborr_grid(fl_alo, fl_ahi, it_agridno, 'grid_powerspace', mp_grid_control);
  52 
    ar_a           = ar_a';
  53 
    
  54 
    fl_phi         = 0.2;
  55 
    fl_risk        = 1.5;
  56 
    fl_alpha       = 0.4;
  57 
    fl_theta       = 0.79-fl_alpha;
  58 
    fl_delta       = 0.05;
  59 
    fl_kappa       = 0;
  60 
    fl_mu_z        = 0;                   % mean of AR(1) entrepeneurial productivity process
  61 
    fl_rho_z       = 0.9;                 % persistence parameter of the AR(1) entrepreneurial productivity process
  62 
    fl_sig_z       = 0.2; 
  63 
    fl_lambda_z    = 3; 
  64 
    fl_beta        = 0.92; 
  65 
   %[ar_z, mt_trans_z] = mytauchen_z(fl_mu_z,fl_rho_z,fl_sig_z,it_zgridno,fl_lambda_z); 
  66 
   % ar_z           = exp(ar_z)';
  67 
    [ar_z, mt_trans_z] = ffy_rouwenhorst(fl_rho_z,fl_sig_z,it_zgridno);    
  68 
    ar_z           = exp(ar_z);
  69 
    P1=mt_trans_z^1000;
  70 
    sd=P1(1,:);
  71 
    el=sd*ar_z;
  72 
    ar_z =ar_z/el;
  73 
    ar_z         = ar_z';   
  74 
    mt_trans_n =[0.7,0.3;0.7,0.3];
  75 
    ar_n =[0,1];
  76 
  
  77 
    [fl_r,fl_w] = ...
  78 
        deal(0.02,2);
  79 
    fl_tolvfi    = 10^-12;
  80 
    bl_print       = true;
  81 
    fl_toldis    = 10^-12;              % Tolerance level for convergence stationary distribution
  82 
    
< 0.001 
      1 
  83
end 
  84 

< 0.001 
      1 
  85
fl_R  = fl_r + fl_delta; 
  86 

  87 

< 0.001 
      1 
  88
it_s=1;     % Counting iteration for Convergence to Stationary Distribution 
< 0.001 
      1 
  89
fl_sum1(1)=0; % Variable to check if all elements of Stationary distribution Sum to 1 
< 0.001 
      1 
  90
fl_crit1=1; 
  91 

  92 
% Calling VFI
  93 

  3.038 
      1 
  94
[mt_vf, mt_pf, mt_oploc,mt_coh, mt_o, mt_k, mt_l]=hhsave_VFI_3OC(ar_a,ar_z,ar_n, ... 
      1 
  95
        fl_alpha,fl_theta,fl_delta,fl_kappa,fl_r,fl_w,fl_phi,fl_ahi,fl_zhi, ... 
      1 
  96
         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, ... 
      1 
  97
     fl_lambda_z, fl_tolvfi ... 
  98 
        );
  99 
    
 100 
    
 101 

 102 
%% Evaluating Stationary Distribution
 103 

< 0.001 
      1 
 104
it_s=1;     % Counting iteration for Convergence to Stationary Distribution 
< 0.001 
      1 
 105
fl_sum1(1)=0; % Variable to check if all elements of Stationary distribution Sum to 1 
< 0.001 
      1 
 106
fl_crit1=1; 
 107 

< 0.001 
      1 
 108
P(:,:,:,(it_s+1))=zeros(it_agridno,it_zgridno,it_ngridno); 
< 0.001 
      1 
 109
P(:,:,:,1)=ones(it_agridno,it_zgridno,it_ngridno).*(1/(it_agridno*it_zgridno*it_ngridno));  
 110 

< 0.001 
      1 
 111
while(fl_crit1>fl_toldis) 
  0.009 
    244 
 112
    P(:,:,:,it_s+1)=zeros(it_agridno,it_zgridno,it_ngridno); 
< 0.001 
    244 
 113
    for i= 1:it_agridno 
  0.002 
  24400 
 114
        for j= 1:it_zgridno 
  0.010 
 170800 
 115
            for c= 1:it_ngridno 
  0.434 
 341600 
 116
            f=find((ar_a==mt_pf(i,j,c)));  
  0.021 
 341600 
 117
                    for g=1:it_zgridno 
  0.195 
2391200 
 118
                        for h = 1: it_ngridno 
  0.492 
4782400 
 119
                    P(f,g,h,it_s+1)= P(f,g,h,it_s+1)+ mt_trans_z(j,g)*mt_trans_n(c,h)*P(i,j,c,it_s); %evaluates Probability in a particular row and column in the next period 
  0.324 
4782400 
 120
                end 
  0.149 
2391200 
 121
            end 
  0.021 
 341600 
 122
            end 
  0.013 
 170800 
 123
        end 
  0.002 
  24400 
 124
    end 
  0.008 
    244 
 125
    fl_sum1(it_s+1)=sum(sum(sum(P(:,:,:,it_s+1)))); % sum of all elements of the matrix P(:,:,s) in a particular iteration, which must be equal to 1 for all s 
 126 
    % we observe that the vector sum1 has value 1 in all the cells on running the code
  0.004 
    244 
 127
    mt_diff1=(P(:,:,:,it_s+1)- P(:,:,:,it_s)); 
< 0.001 
    244 
 128
    mt_diff1 = mt_diff1(:); 
< 0.001 
    244 
 129
fl_crit1=norm(mt_diff1); 
< 0.001 
    244 
 130
it_s=it_s+1; 
< 0.001 
    244 
 131
end  
< 0.001 
      1 
 132
fl_Ea=sum(sum(P(:,:,:,it_s),2).*ar_a'); 
< 0.001 
      1 
 133
mt_dis=P(:,:,:,it_s); 
 134 

 135 
%% Printing outputs 
 136 

< 0.001 
      1 
 137
if(bl_print) 
 138 
    disp('Below is the Stationary Distribution');
 139 
    disp((mt_dis));
 140 
     st_ar_a = strsplit(num2str(ar_a));
 141 
    for i=1:it_agridno
 142 
        st_a(i) =strcat('a=', st_ar_a(i));
 143 
    end
 144 
    disp('Table for Stationary Distribution at l=0');
 145 
    tb_dis = array2table(mt_dis(:,:,1),'VariableNames',{'z1','z2','z3','z4','z5','z6','z7'});
 146 
    tb_dis.Properties.RowNames = st_a;
 147 
    disp(tb_dis); 
 148 
    disp('Table for Stationary Distribution at l=1');
 149 
    tb_dis = array2table(mt_dis(:,:,1),'VariableNames',{'z1','z2','z3','z4','z5','z6','z7'});
 150 
    tb_dis.Properties.RowNames = st_a;
 151 
    disp(tb_dis);
 152 
    
< 0.001 
      1 
 153
 end 
 154 

< 0.001 
      1 
 155
if(bl_profile) 
  0.004 
      1 
 156
profile off; 
 157 
profile viewer;
 158 
st_file_name = '/Users/sidhantkhanna/Documents/GitHub/BKS modified/code/Profile/Households/hhsave_dis_3OC';
 159 
profsave(profile('info'), st_file_name);
 160 
end

Other subfunctions in this file are not included in this listing.