time | Calls | line |
---|
| | 16 | function [mt_util,mt_coh, mt_k, mt_l, mt_o]=hhsave_util_3OC(varargin)
|
| | 17 |
|
0.002 | 1 | 18 | close all;
|
< 0.001 | 1 | 19 | bl_profile = false; % Switch off profile if running a tester/calling from another function
|
< 0.001 | 1 | 20 | if(bl_profile)
|
| | 21 | profile off;
|
| | 22 | profile on;
|
< 0.001 | 1 | 23 | end
|
| | 24 |
|
0.420 | 1 | 25 | addpath(genpath('/Users/sidhantkhanna/Documents/GitHub/BKS modified/'));
|
| | 26 |
|
| | 27 | %% Assigning parameters
|
| | 28 |
|
< 0.001 | 1 | 29 | if ~isempty(varargin)
|
| | 30 |
|
0.004 | 1 | 31 | [ar_a,ar_z,ar_n, ...
|
| 1 | 32 | fl_alpha,fl_theta,fl_delta,fl_kappa,fl_r,fl_w,fl_phi,fl_ahi,fl_zhi, ...
|
| 1 | 33 | fl_risk,it_zgridno, it_agridno,it_ngridno ...
|
| 1 | 34 | ] = varargin{:};
|
| | 35 |
|
< 0.001 | 1 | 36 | bl_print = false;
|
| | 37 |
|
| | 38 |
|
| | 39 | else
|
| | 40 | close all;
|
| | 41 |
|
| | 42 | fl_ahi = 5;
|
| | 43 | fl_zhi = 2.2;
|
| | 44 | it_agridno = 4;
|
| | 45 | it_zgridno = 5;
|
| | 46 | it_ngridno = 2;
|
| | 47 | ar_a = linspace(0,fl_ahi,it_agridno);
|
| | 48 | ar_z = linspace(1,fl_zhi,it_zgridno);
|
| | 49 | fl_phi = 0;
|
| | 50 | fl_risk = 1;
|
| | 51 | ar_n = [0,1];
|
| | 52 | fl_alpha = 0.4;
|
| | 53 | fl_theta = 0.79-fl_alpha;
|
| | 54 | fl_delta = 0.05;
|
| | 55 | fl_kappa = 0;
|
| | 56 |
|
| | 57 | [fl_r,fl_w] = ...
|
| | 58 | deal(0.05,1.5);
|
| | 59 | bl_print = true;
|
| | 60 |
|
< 0.001 | 1 | 61 | end
|
| | 62 |
|
< 0.001 | 1 | 63 | fl_R = fl_r + fl_delta;
|
| | 64 |
|
| | 65 | %% Calling OC3
|
| | 66 |
|
1.836 | 1 | 67 | [mt_o, mt_coh, mt_k, mt_l] = OC3(ar_a,ar_z,ar_n, ...
|
| 1 | 68 | fl_alpha,fl_theta,fl_delta,fl_kappa,fl_r,fl_w,fl_phi,fl_ahi,fl_zhi, ...
|
| 1 | 69 | it_zgridno, it_agridno, it_ngridno);
|
| | 70 |
|
| | 71 | %% Computing consumption
|
| | 72 |
|
< 0.001 | 1 | 73 | mt4_coh= repmat (mt_coh, [1 1 1 it_agridno]);
|
| | 74 | %Projecting COH matrix to a 4th dimension of size of asset grid which will be used for evaluating optimal future assets
|
| | 75 |
|
0.001 | 1 | 76 | mt_futassets=ones(it_agridno, it_zgridno, it_ngridno, it_agridno).*ar_a';
|
| | 77 | % 4d asset matrix to subtract future assets from COH to compute consumption
|
| | 78 |
|
0.001 | 1 | 79 | mt_futassets=permute(mt_futassets,[4 2 3 1]);
|
| | 80 |
|
< 0.001 | 1 | 81 | mt_con = mt4_coh-mt_futassets; % Consumption Matrix for each a, z, future a
|
| | 82 |
|
0.002 | 1 | 83 | neg = find(mt_con<0);
|
< 0.001 | 1 | 84 | zero = find(mt_con==0);
|
| | 85 |
|
| | 86 |
|
| | 87 | %mt_con(neg) = NaN;
|
| | 88 |
|
< 0.001 | 1 | 89 | if(fl_risk==1)
|
| | 90 | mt_util=log(mt_con);
|
< 0.001 | 1 | 91 | else
|
0.010 | 1 | 92 | mt_util= (mt_con.^(1-fl_risk) -1)/(1-fl_risk); % Utility Part of value function
|
< 0.001 | 1 | 93 | end
|
0.001 | 1 | 94 | mt_util(neg) = -10^20;
|
< 0.001 | 1 | 95 | mt_util(zero) = -100;
|
| | 96 |
|
| | 97 |
|
| | 98 | %% Printing outputs
|
| | 99 |
|
< 0.001 | 1 | 100 | if(bl_print)
|
| | 101 | disp('Below is the COH matrix for for all combinations of a, z, n and future a');
|
| | 102 | disp(mt4_coh);
|
| | 103 | disp('Below is the future assets matrix for each combination of a, z, n and future a');
|
| | 104 | disp(mt_futassets);
|
| | 105 | disp('Below is the consumption matrix for for all combinations of a, z, n and future a');
|
| | 106 | disp(mt_con);
|
| | 107 | disp('Below is the utility matrix for for all combinations of a, z, n and future a');
|
| | 108 | disp(mt_util);
|
< 0.001 | 1 | 109 | end
|
| | 110 |
|
< 0.001 | 1 | 111 | if(bl_profile)
|
| | 112 | profile off;
|
| | 113 | profile viewer;
|
| | 114 | st_file_name = '/Users/sidhantkhanna/Documents/GitHub/BKS modified/code/Profile/Households/hhsave_util_2OC';
|
| | 115 | profsave(profile('info'), st_file_name);
|
< 0.001 | 1 | 116 | end
|