This is a static copy of a profile report

Home

Function details for hhsave_dis_2OCThis is a static copy of a profile report

Home

hhsave_dis_2OC (Calls: 1, Time: 4.129 s)
Generated 02-May-2020 21:54:23 using performance time.
function in file /Users/sidhantkhanna/Documents/GitHub/BKS modified/code/Households/hhsave_dis_2OC.m
Copy to new window for comparing multiple runs

Parents (calling functions)
No parent
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
77
fl_risk,it_zgridno, it_agridno...
13.287 s79.6%
26
addpath(genpath('/Users/sidhan...
10.453 s11.0%
92
f=find((ar_a==mt_pf(i,j)));   ...
1580100.102 s2.5%
94
P(f,g,it_s+1)= P(f,g,it_s+1)+ ...
9480600.092 s2.2%
95
end
9480600.054 s1.3%
All other lines  0.141 s3.4%
Totals  4.129 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
hhsave_VFI_2OCfunction13.287 s79.6%
genpathfunction10.322 s7.8%
addpathfunction10.131 s3.2%
closefunction10.013 s0.3%
mytauchen_zfunction10.007 s0.2%
linspacefunction10.002 s0.0%
Self time (built-ins, overhead, etc.)  0.368 s8.9%
Totals  4.129 s100% 
Code Analyzer results
Line numberMessage
20The value assigned to variable 'bl_saveimg' might be unused.
32The value assigned here to 'fl_sigma' appears to be unused. Consider replacing it by ~.
36The value assigned to variable 'bl_plot' might be unused.
68The value assigned to variable 'fl_R' might be unused.
75The value assigned here to 'mt_vf' appears to be unused. Consider replacing it by ~.
75The value assigned here to 'mt_oploc' appears to be unused. Consider replacing it by ~.
91FOR might not be aligned with its matching END (line 96).
93FOR might not be aligned with its matching END (line 95).
98The variable 'fl_sum1' appears to change size on every loop iteration. Consider preallocating for speed.
104The value assigned to variable 'fl_Ea' might be unused.
Coverage results
Show coverage for parent directory
Total lines in function106
Non-code lines (comments, blank lines)28
Code lines (lines that can run)78
Code lines that did run61
Code lines that did not run17
Coverage (did run/can run)78.21 %
Function listing
time 
Calls 
 line
  15 
function [mt_dis, mt_o, mt_k, mt_l]= hhsave_dis_2OC(varargin)
  16 
addpath(genpath('/Users/sidhantkhanna/Desktop/Research/Matlab Code/My codes'));
  17 

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

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

< 0.001 
      1 
  28
if ~isempty(varargin) 
  29 
    
  30 
    [ar_a,ar_z, ...
  31 
        fl_alpha,fl_theta,fl_delta,fl_kappa,fl_r,fl_w,fl_phi,fl_ahi,fl_zhi, ...
  32 
         fl_risk,it_zgridno, it_agridno,mt_trans_z,fl_beta, fl_mu, fl_sigma,fl_rho, fl_tolvfi, fl_toldis ...
  33 
        ] = varargin{:};
  34 
    
  35 
    bl_print  = true;
  36 
    bl_plot   = false;
  37 

  38 
    
< 0.001 
      1 
  39
else 
  0.013 
      1 
  40
    close all; 
  41 
    
< 0.001 
      1 
  42
    fl_ahi         = 50; 
< 0.001 
      1 
  43
    fl_zhi         = 2.2; 
< 0.001 
      1 
  44
    it_agridno     = 5; 
< 0.001 
      1 
  45
    it_zgridno     = 6; 
  0.002 
      1 
  46
    ar_a           = linspace(0,fl_ahi,it_agridno); 
< 0.001 
      1 
  47
    fl_phi         = 0.5; 
< 0.001 
      1 
  48
    fl_risk        = 1; 
< 0.001 
      1 
  49
    fl_alpha       = 0.4; 
< 0.001 
      1 
  50
    fl_theta       = 0.79-fl_alpha; 
< 0.001 
      1 
  51
    fl_delta       = 0.05; 
< 0.001 
      1 
  52
    fl_kappa       = 0; 
< 0.001 
      1 
  53
    fl_mu          = 0;                   % mean of AR(1) entrepeneurial productivity process 
< 0.001 
      1 
  54
    fl_rho         = 0.9;                 % persistence parameter of the AR(1) entrepreneurial productivity process 
< 0.001 
      1 
  55
    fl_sig         = 0.2;      
< 0.001 
      1 
  56
    fl_lambda      = 3;       
< 0.001 
      1 
  57
    fl_beta        = 0.96;  
  0.008 
      1 
  58
    [ar_z, mt_trans_z] = mytauchen_z(fl_mu,fl_rho,fl_sig,it_zgridno,fl_lambda);     
< 0.001 
      1 
  59
    ar_z           = exp(ar_z); 
< 0.001 
      1 
  60
    fl_r           = 0.02; 
< 0.001 
      1 
  61
    fl_w           = 1.5; 
< 0.001 
      1 
  62
    fl_tolvfi    = 10^-12; 
< 0.001 
      1 
  63
    fl_toldis    = 10^-12;              % Tolerance level for convergence stationary distribution 
< 0.001 
      1 
  64
    bl_print       = true; 
  65 
    
< 0.001 
      1 
  66
end 
  67 

< 0.001 
      1 
  68
fl_R  = fl_r + fl_delta; 
  69 

  70 

  71 

  72 

  73 
% Calling VFI
  74 

  3.287 
      1 
  75
[mt_vf, mt_pf, mt_oploc, mt_o, mt_k, mt_l]=hhsave_VFI_2OC(ar_a,ar_z, ... 
      1 
  76
        fl_alpha,fl_theta,fl_delta,fl_kappa,fl_r,fl_w,fl_phi,fl_ahi,fl_zhi, ... 
      1 
  77
         fl_risk,it_zgridno, it_agridno,mt_trans_z,fl_beta, fl_mu, fl_sig,fl_rho, fl_tolvfi); 
  78 

  79 
%% Evaluating Stationary Distribution
  80 

< 0.001 
      1 
  81
it_s=1;     % Counting iteration for Convergence to Stationary Distribution 
< 0.001 
      1 
  82
fl_sum1(1)=0; % Variable to check if all elements of Stationary distribution Sum to 1 
< 0.001 
      1 
  83
fl_crit1=1; 
  84 

< 0.001 
      1 
  85
P(:,:,it_s+1)=zeros(it_agridno,it_zgridno); 
< 0.001 
      1 
  86
P(:,:,1)=ones(it_agridno,it_zgridno).*(1/(it_agridno*it_zgridno));  
  87 

< 0.001 
      1 
  88
while(fl_crit1>fl_toldis) 
  0.015 
   5267 
  89
    P(:,:,it_s+1)=zeros(it_agridno,it_zgridno); 
< 0.001 
   5267 
  90
    for i= 1:it_agridno 
  0.002 
  26335 
  91
        for j= 1:it_zgridno 
  0.102 
 158010 
  92
            f=find((ar_a==mt_pf(i,j)));                    
  0.011 
 158010 
  93
                    for g=1:it_zgridno 
  0.092 
 948060 
  94
                    P(f,g,it_s+1)= P(f,g,it_s+1)+ mt_trans_z(j,g)*P(i,j,it_s); %evaluates Probability in a particular row and column in the next period 
  0.054 
 948060 
  95
                end 
  0.009 
 158010 
  96
            end 
  0.002 
  26335 
  97
    end 
  0.014 
   5267 
  98
    fl_sum1(it_s+1)=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 
  99 
    % we observe that the vector sum1 has value 1 in all the cells on running the code
  0.014 
   5267 
 100
    mt_diff1=(P(:,:,it_s+1)- P(:,:,it_s)); 
  0.031 
   5267 
 101
fl_crit1=norm(mt_diff1); 
< 0.001 
   5267 
 102
it_s=it_s+1; 
< 0.001 
   5267 
 103
end  
< 0.001 
      1 
 104
fl_Ea=sum(sum(P(:,:,it_s),2).*ar_a'); 
< 0.001 
      1 
 105
mt_dis=P(:,:,it_s); 
 106 

 107 
%% Printing outputs 
 108 

< 0.001 
      1 
 109
if(bl_print) 
< 0.001 
      1 
 110
    disp('Below is the Stationary Distribution'); 
< 0.001 
      1 
 111
    disp((mt_dis)); 
 112 
    
< 0.001 
      1 
 113
 end 
 114 

< 0.001 
      1 
 115
if(bl_profile) 
  0.016 
      1 
 116
profile off; 
 117 
profile viewer;
 118 
st_file_name = '/Users/sidhantkhanna/Documents/GitHub/BKS modified/code/Profile/Households/hhsave_dis_2OC';
 119 
profsave(profile('info'), st_file_name);
 120 
end

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