time | Calls | line |
---|
| | 32 | function [ar_n, mt_Pi] = mytauchen_n(varargin)
|
| | 33 |
|
| | 34 | %% Function default parameters setting
|
| | 35 | close all;
|
| | 36 | profile off;
|
| | 37 | profile on;
|
| | 38 |
|
< 0.001 | 1 | 39 | if ~isempty(varargin)
|
| | 40 |
|
| | 41 | [fl_mu_n, fl_rho_n, fl_sig_n, it_ngridno, fl_lambda_n] = varargin{:}
|
| | 42 | bl_display_param = false;
|
| | 43 |
|
< 0.001 | 1 | 44 | else
|
< 0.001 | 1 | 45 | fl_mu_n = 0;
|
< 0.001 | 1 | 46 | fl_rho_n = 0.1;
|
< 0.001 | 1 | 47 | fl_sig_n = 0.2;
|
< 0.001 | 1 | 48 | it_ngridno = 2;
|
< 0.001 | 1 | 49 | fl_lambda_n = 3;
|
< 0.001 | 1 | 50 | bl_display_param = true;
|
| | 51 |
|
< 0.001 | 1 | 52 | end
|
| | 53 |
|
< 0.001 | 1 | 54 | ar_n = zeros(it_ngridno,1);
|
< 0.001 | 1 | 55 | mt_Pi = zeros(it_ngridno,it_ngridno);
|
< 0.001 | 1 | 56 | ar_n(1) = fl_mu_n/(1-fl_rho_n) - fl_lambda_n*sqrt(fl_sig_n^2/(1-fl_rho_n^2));
|
< 0.001 | 1 | 57 | ar_n(it_ngridno) = fl_mu_n/(1-fl_rho_n) + fl_lambda_n*sqrt(fl_sig_n^2/(1-fl_rho_n^2));
|
< 0.001 | 1 | 58 | step = (ar_n(it_ngridno)-ar_n(1))/(it_ngridno-1);
|
| | 59 |
|
| | 60 | %% Constructing Labor productivity array
|
| | 61 |
|
< 0.001 | 1 | 62 | for i=2:(it_ngridno-1)
|
| | 63 | ar_n(i) = ar_n(i-1) + step;
|
| | 64 | end
|
| | 65 |
|
| | 66 | %% Constructing Labor productivity transition matrix
|
| | 67 |
|
< 0.001 | 1 | 68 | for j = 1:it_ngridno
|
< 0.001 | 2 | 69 | for k = 1:it_ngridno
|
< 0.001 | 4 | 70 | if k == 1
|
< 0.001 | 2 | 71 | mt_Pi(j,k) = cdf_normal((ar_n(1) - fl_mu_n - fl_rho_n*ar_n(j) + step/2) / fl_sig_n);
|
< 0.001 | 2 | 72 | elseif k == it_ngridno
|
< 0.001 | 2 | 73 | mt_Pi(j,k) = 1 - cdf_normal((ar_n(it_ngridno) - fl_mu_n - fl_rho_n*ar_n(j) - step/2) / fl_sig_n);
|
| | 74 | else
|
| | 75 | mt_Pi(j,k) = cdf_normal((ar_n(k) - fl_mu_n - fl_rho_n*ar_n(j) + step/2) / fl_sig_n) - ...
|
| | 76 | cdf_normal((ar_n(k) - fl_mu_n - fl_rho_n*ar_n(j) - step/2) / fl_sig_n);
|
< 0.001 | 2 | 77 | end
|
< 0.001 | 4 | 78 | end
|
< 0.001 | 2 | 79 | end
|
| | 80 |
|
| | 81 | %% Displaying labor productivity array and transition matrix
|
| | 82 |
|
| | 83 |
|
< 0.001 | 1 | 84 | if (bl_display_param == true)
|
< 0.001 | 1 | 85 | fprintf (2, 'Labor Productivity array \n');
|
< 0.001 | 1 | 86 | disp ('--------------------------');
|
< 0.001 | 1 | 87 | disp (ar_n');
|
< 0.001 | 1 | 88 | fprintf (2, 'Transition Matrix \n');
|
< 0.001 | 1 | 89 | disp ('------------------');
|
< 0.001 | 1 | 90 | disp (mt_Pi);
|
< 0.001 | 1 | 91 | end
|
0.014 | 1 | 92 | profile off;
|
| | 93 | profile viewer;
|
| | 94 | st_file_name = ['/Users/sidhantkhanna/Documents/GitHub/BKS modified/code/Profile/mytauchen_l_profile'];
|
| | 95 | profsave(profile('info'), st_file_name);
|
Other subfunctions in this file are not included in this listing.