time | Calls | line |
---|
| | 32 | function [ar_z, mt_Pi] = mytauchen_z(varargin)
|
| | 33 |
|
| | 34 | %% Function default parameters setting
|
0.002 | 1 | 35 | close all;
|
< 0.001 | 1 | 36 | bl_profile = false; % Switch off profile if running a tester/calling from another function
|
< 0.001 | 1 | 37 | if(bl_profile)
|
| | 38 | profile off;
|
| | 39 | profile on;
|
| | 40 | end
|
| | 41 |
|
< 0.001 | 1 | 42 | if ~isempty(varargin)
|
| | 43 |
|
< 0.001 | 1 | 44 | [fl_mu_z, fl_rho_z, fl_sig_z, it_zgridno, fl_lambda_z] = varargin{:};
|
< 0.001 | 1 | 45 | bl_display_param = false;
|
| | 46 |
|
| | 47 | else
|
| | 48 | fl_mu_z = 0;
|
| | 49 | fl_rho_z = 0.9;
|
| | 50 | fl_sig_z = 0.2;
|
| | 51 | it_zgridno = 10;
|
| | 52 | fl_lambda_z = 3;
|
| | 53 | bl_display_param = true;
|
| | 54 |
|
< 0.001 | 1 | 55 | end
|
| | 56 |
|
< 0.001 | 1 | 57 | ar_z = zeros(it_zgridno,1);
|
< 0.001 | 1 | 58 | mt_Pi = zeros(it_zgridno,it_zgridno);
|
< 0.001 | 1 | 59 | ar_z(1) = fl_mu_z/(1-fl_rho_z) - fl_lambda_z*sqrt(fl_sig_z^2/(1-fl_rho_z^2));
|
< 0.001 | 1 | 60 | ar_z(it_zgridno) = fl_mu_z/(1-fl_rho_z) + fl_lambda_z*sqrt(fl_sig_z^2/(1-fl_rho_z^2));
|
< 0.001 | 1 | 61 | step = (ar_z(it_zgridno)-ar_z(1))/(it_zgridno-1);
|
| | 62 |
|
| | 63 | %% Constructing entrepreneurial productivity array
|
| | 64 |
|
< 0.001 | 1 | 65 | for i=2:(it_zgridno-1)
|
< 0.001 | 8 | 66 | ar_z(i) = ar_z(i-1) + step;
|
< 0.001 | 8 | 67 | end
|
| | 68 |
|
| | 69 | %% Constructing transition matrix
|
| | 70 |
|
< 0.001 | 1 | 71 | for j = 1:it_zgridno
|
< 0.001 | 10 | 72 | for k = 1:it_zgridno
|
< 0.001 | 100 | 73 | if k == 1
|
< 0.001 | 10 | 74 | mt_Pi(j,k) = cdf_normal((ar_z(1) - fl_mu_z - fl_rho_z*ar_z(j) + step/2) / fl_sig_z);
|
< 0.001 | 90 | 75 | elseif k == it_zgridno
|
< 0.001 | 10 | 76 | mt_Pi(j,k) = 1 - cdf_normal((ar_z(it_zgridno) - fl_mu_z - fl_rho_z*ar_z(j) - step/2) / fl_sig_z);
|
< 0.001 | 80 | 77 | else
|
0.001 | 80 | 78 | mt_Pi(j,k) = cdf_normal((ar_z(k) - fl_mu_z - fl_rho_z*ar_z(j) + step/2) / fl_sig_z) - ...
|
| 80 | 79 | cdf_normal((ar_z(k) - fl_mu_z - fl_rho_z*ar_z(j) - step/2) / fl_sig_z);
|
< 0.001 | 90 | 80 | end
|
< 0.001 | 100 | 81 | end
|
< 0.001 | 10 | 82 | end
|
| | 83 |
|
| | 84 | %% Displaying entreprenurial productivity array and transition matrix
|
| | 85 |
|
< 0.001 | 1 | 86 | if (bl_display_param == true)
|
| | 87 | fprintf (2, 'log entrepreneurial Productivity array \n');
|
| | 88 | disp ('----------------------------------');
|
| | 89 | disp (ar_z');
|
| | 90 | fprintf (2, 'Transition Matrix \n');
|
| | 91 | disp ('------------------');
|
| | 92 | disp (mt_Pi);
|
| | 93 | end
|
| | 94 |
|
< 0.001 | 1 | 95 | if(bl_profile)
|
| | 96 | profile off;
|
| | 97 | profile viewer;
|
| | 98 | st_file_name = ['/Users/sidhantkhanna/Documents/GitHub/BKS modified/code/Profile/mytauchen_z_profile'];
|
| | 99 | profsave(profile('info'), st_file_name);
|
| | 100 | end
|
Other subfunctions in this file are not included in this listing.