Go to the MLX, M, PDF, or HTML version of this file. Go back to fan’s MEconTools Toolbox (bookdown), Matlab Code Examples Repository (bookdown), or Math for Econ with Matlab Repository (bookdown).
Examples](https://fanwangecon.github.io/M4Econ/), or** Dynamic Asset This is the example vignette for function: ffy_tauchen from the MEconTools Package. : See also the ffy_rouwenhorst function from the MEconTools Package. This function discretize a mean zero AR1 process, uses Tauchen (1986). See AR 1 Example for some details on how the AR1 process works. And See Kopecky and Suen (2010).
Call the function with defaults. Default sd bounds arer plus and minus 4. This is used in the following examples, unless otherwise specified as the 5th parameter.
ffy_tauchen();
----------------------------------------
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
CONTAINER NAME: mp_container_map ND Array (Matrix etc)
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
i idx ndim numel rowN colN sum mean std coefvari min max
_ ___ ____ _____ ____ ____ ___ ____ _______ ________ __________ ______
ar_disc_ar1 1 1 2 5 5 1 0 0 0.79057 Inf -1 1
mt_disc_ar1_trans 2 6 2 25 5 5 5 0.2 0.27623 1.3812 7.3923e-12 0.7887
xxx TABLE:ar_disc_ar1 xxxxxxxxxxxxxxxxxx
c1
____
r1 -1
r2 -0.5
r3 0
r4 0.5
r5 1
xxx TABLE:mt_disc_ar1_trans xxxxxxxxxxxxxxxxxx
c1 c2 c3 c4 c5
__________ __________ ________ __________ __________
r1 0.22663 0.73331 0.040048 1.0689e-05 7.3923e-12
r2 0.012224 0.58648 0.39831 0.0029797 7.605e-08
r3 8.8417e-05 0.10556 0.7887 0.10556 8.8417e-05
r4 7.605e-08 0.0029797 0.39831 0.58648 0.012224
r5 7.3923e-12 1.0689e-05 0.040048 0.73331 0.22663
----------------------------------------
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
CONTAINER NAME: mp_container_map Scalars
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
i idx value
_ ___ _____
fl_ar1_persistence 1 2 0.6
fl_ar1_step 2 3 0.5
fl_shk_std 3 4 0.2
it_std_bound 4 5 4
With a grid of 10 points, the sd bounds on Tauchen and Rouwenhorst are identical. With the not extremely persistent shock process here, the Tauchen and Rouwenhorst Results are very similar.
[fl_ar1_persistence, fl_shk_std, it_disc_points, bl_verbose, it_std_bound] = ...
deal(0.60, 0.10, 10, true, 3);
ffy_tauchen(fl_ar1_persistence, fl_shk_std, it_disc_points, bl_verbose, it_std_bound);
----------------------------------------
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
CONTAINER NAME: mp_container_map ND Array (Matrix etc)
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
i idx ndim numel rowN colN sum mean std coefvari min max
_ ___ ____ _____ ____ ____ ___________ ___________ _______ ___________ __________ _______
ar_disc_ar1 1 1 2 10 10 1 -7.2164e-16 -7.2164e-17 0.2523 -3.4962e+15 -0.375 0.375
mt_disc_ar1_trans 2 6 2 100 10 10 10 0.1 0.11456 1.1456 1.1798e-08 0.32308
xxx TABLE:ar_disc_ar1 xxxxxxxxxxxxxxxxxx
c1
_________
r1 -0.375
r2 -0.29167
r3 -0.20833
r4 -0.125
r5 -0.041667
r6 0.041667
r7 0.125
r8 0.20833
r9 0.29167
r10 0.375
xxx TABLE:mt_disc_ar1_trans xxxxxxxxxxxxxxxxxx
c1 c2 c3 c4 c5 c6 c7 c8 c9 c10
__________ __________ __________ __________ ________ ________ __________ __________ __________ __________
r1 0.13933 0.26196 0.31887 0.20154 0.066066 0.011201 0.00097859 4.3874e-05 1.0053e-06 1.1798e-08
r2 0.056673 0.16995 0.30658 0.28713 0.1396 0.035167 0.0045756 0.00030628 1.0503e-05 1.8543e-07
r3 0.01861 0.087039 0.23281 0.32308 0.23281 0.087039 0.016841 0.0016806 8.6129e-05 2.2881e-06
r4 0.0048925 0.035167 0.1396 0.28713 0.30658 0.16995 0.048841 0.0072547 0.00055483 2.2197e-05
r5 0.0010235 0.011201 0.066066 0.20154 0.31887 0.26196 0.11169 0.02466 0.0028101 0.00016962
r6 0.00016962 0.0028101 0.02466 0.11169 0.26196 0.31887 0.20154 0.066066 0.011201 0.0010235
r7 2.2197e-05 0.00055483 0.0072547 0.048841 0.16995 0.30658 0.28713 0.1396 0.035167 0.0048925
r8 2.2881e-06 8.6129e-05 0.0016806 0.016841 0.087039 0.23281 0.32308 0.23281 0.087039 0.01861
r9 1.8543e-07 1.0503e-05 0.00030628 0.0045756 0.035167 0.1396 0.28713 0.30658 0.16995 0.056673
r10 1.1798e-08 1.0053e-06 4.3874e-05 0.00097859 0.011201 0.066066 0.20154 0.31887 0.26196 0.13933
----------------------------------------
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
CONTAINER NAME: mp_container_map Scalars
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
i idx value
_ ___ ________
fl_ar1_persistence 1 2 0.6
fl_ar1_step 2 3 0.083333
fl_shk_std 3 4 0.1
it_std_bound 4 5 3
[fl_ar1_persistence, fl_shk_std, it_disc_points, bl_verbose] = ...
deal(0.99, 0.01, 7, true);
ffy_tauchen(fl_ar1_persistence, fl_shk_std, it_disc_points, bl_verbose);
----------------------------------------
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
CONTAINER NAME: mp_container_map ND Array (Matrix etc)
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
i idx ndim numel rowN colN sum mean std coefvari min max
_ ___ ____ _____ ____ ____ ___ _______ _______ ________ ________ _______
ar_disc_ar1 1 1 2 7 7 1 0 0 0.15314 Inf -0.21266 0.21266
mt_disc_ar1_trans 2 6 2 49 7 7 7 0.14286 0.35338 2.4737 0 0.99961
xxx TABLE:ar_disc_ar1 xxxxxxxxxxxxxxxxxx
c1
_________
r1 -0.21266
r2 -0.14178
r3 -0.070888
r4 0
r5 0.070888
r6 0.14178
r7 0.21266
xxx TABLE:mt_disc_ar1_trans xxxxxxxxxxxxxxxxxx
c1 c2 c3 c4 c5 c6 c7
___________ ___________ ___________ __________ __________ __________ __________
r1 0.99957 0.00043152 0 0 0 0 0
r2 0.00011382 0.99955 0.0003337 0 0 0 0
r3 4.8683e-27 0.00015 0.99959 0.00025684 0 0 0
r4 1.4175e-70 1.0439e-26 0.00019675 0.99961 0.00019675 0 0
r5 1.9884e-135 4.986e-70 2.2273e-26 0.00025684 0.99959 0.00015 0
r6 1.2359e-221 1.149e-134 1.7451e-69 4.7287e-26 0.0003337 0.99955 0.00011382
r7 0 1.1738e-220 6.6059e-134 6.077e-69 9.9893e-26 0.00043152 0.99957
----------------------------------------
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
CONTAINER NAME: mp_container_map Scalars
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
i idx value
_ ___ ________
fl_ar1_persistence 1 2 0.99
fl_ar1_step 2 3 0.070888
fl_shk_std 3 4 0.01
it_std_bound 4 5 3
[fl_ar1_persistence, fl_shk_std, it_disc_points, bl_verbose] = ...
deal(0.01, 0.01, 7, true);
ffy_tauchen(fl_ar1_persistence, fl_shk_std, it_disc_points, bl_verbose);
----------------------------------------
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
CONTAINER NAME: mp_container_map ND Array (Matrix etc)
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
i idx ndim numel rowN colN sum mean std coefvari min max
_ ___ ____ _____ ____ ____ __________ __________ ________ __________ _________ ________
ar_disc_ar1 1 1 2 7 7 1 3.4694e-18 4.9564e-19 0.021604 4.3588e+16 -0.030002 0.030002
mt_disc_ar1_trans 2 6 2 49 7 7 7 0.14286 0.13667 0.95666 0.0057011 0.38294
xxx TABLE:ar_disc_ar1 xxxxxxxxxxxxxxxxxx
c1
_________
r1 -0.030002
r2 -0.020001
r3 -0.010001
r4 0
r5 0.010001
r6 0.020001
r7 0.030002
xxx TABLE:mt_disc_ar1_trans xxxxxxxxxxxxxxxxxx
c1 c2 c3 c4 c5 c6 c7
_________ ________ _______ _______ _______ ________ _________
r1 0.0067533 0.064018 0.2484 0.38278 0.23505 0.057298 0.0057011
r2 0.0065668 0.06286 0.24618 0.38287 0.23728 0.05838 0.0058656
r3 0.0063849 0.061717 0.24396 0.38292 0.2395 0.059478 0.0060344
r4 0.0062075 0.06059 0.24173 0.38294 0.24173 0.06059 0.0062075
r5 0.0060344 0.059478 0.2395 0.38292 0.24396 0.061717 0.0063849
r6 0.0058656 0.05838 0.23728 0.38287 0.24618 0.06286 0.0065668
r7 0.0057011 0.057298 0.23505 0.38278 0.2484 0.064018 0.0067533
----------------------------------------
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
CONTAINER NAME: mp_container_map Scalars
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
i idx value
_ ___ ________
fl_ar1_persistence 1 2 0.01
fl_ar1_step 2 3 0.010001
fl_shk_std 3 4 0.01
it_std_bound 4 5 3
[fl_ar1_persistence, fl_shk_std, it_disc_points, bl_verbose] = ...
deal(0.99, 0.99, 7, true);
ffy_tauchen(fl_ar1_persistence, fl_shk_std, it_disc_points, bl_verbose);
----------------------------------------
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
CONTAINER NAME: mp_container_map ND Array (Matrix etc)
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
i idx ndim numel rowN colN sum mean std coefvari min max
_ ___ ____ _____ ____ ____ ___________ ___________ _______ ___________ _______ _______
ar_disc_ar1 1 1 2 7 7 1 -7.1054e-15 -1.0151e-15 15.16 -1.4936e+16 -21.054 21.054
mt_disc_ar1_trans 2 6 2 49 7 7 7 0.14286 0.35338 2.4737 0 0.99961
xxx TABLE:ar_disc_ar1 xxxxxxxxxxxxxxxxxx
c1
___________
r1 -21.054
r2 -14.036
r3 -7.0179
r4 -1.7764e-15
r5 7.0179
r6 14.036
r7 21.054
xxx TABLE:mt_disc_ar1_trans xxxxxxxxxxxxxxxxxx
c1 c2 c3 c4 c5 c6 c7
___________ ___________ ___________ __________ __________ __________ __________
r1 0.99957 0.00043152 0 0 0 0 0
r2 0.00011382 0.99955 0.0003337 0 0 0 0
r3 4.8683e-27 0.00015 0.99959 0.00025684 0 0 0
r4 1.4175e-70 1.0439e-26 0.00019675 0.99961 0.00019675 0 0
r5 1.9884e-135 4.986e-70 2.2273e-26 0.00025684 0.99959 0.00015 0
r6 1.2359e-221 1.149e-134 1.7451e-69 4.7287e-26 0.0003337 0.99955 0.00011382
r7 0 1.1738e-220 6.6059e-134 6.077e-69 9.9893e-26 0.00043152 0.99957
----------------------------------------
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
CONTAINER NAME: mp_container_map Scalars
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
i idx value
_ ___ ______
fl_ar1_persistence 1 2 0.99
fl_ar1_step 2 3 7.0179
fl_shk_std 3 4 0.99
it_std_bound 4 5 3
[fl_ar1_persistence, fl_shk_std, it_disc_points, bl_verbose] = ...
deal(0.01, 0.01, 7, true);
ffy_tauchen(fl_ar1_persistence, fl_shk_std, it_disc_points, bl_verbose);
----------------------------------------
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
CONTAINER NAME: mp_container_map ND Array (Matrix etc)
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
i idx ndim numel rowN colN sum mean std coefvari min max
_ ___ ____ _____ ____ ____ __________ __________ ________ __________ _________ ________
ar_disc_ar1 1 1 2 7 7 1 3.4694e-18 4.9564e-19 0.021604 4.3588e+16 -0.030002 0.030002
mt_disc_ar1_trans 2 6 2 49 7 7 7 0.14286 0.13667 0.95666 0.0057011 0.38294
xxx TABLE:ar_disc_ar1 xxxxxxxxxxxxxxxxxx
c1
_________
r1 -0.030002
r2 -0.020001
r3 -0.010001
r4 0
r5 0.010001
r6 0.020001
r7 0.030002
xxx TABLE:mt_disc_ar1_trans xxxxxxxxxxxxxxxxxx
c1 c2 c3 c4 c5 c6 c7
_________ ________ _______ _______ _______ ________ _________
r1 0.0067533 0.064018 0.2484 0.38278 0.23505 0.057298 0.0057011
r2 0.0065668 0.06286 0.24618 0.38287 0.23728 0.05838 0.0058656
r3 0.0063849 0.061717 0.24396 0.38292 0.2395 0.059478 0.0060344
r4 0.0062075 0.06059 0.24173 0.38294 0.24173 0.06059 0.0062075
r5 0.0060344 0.059478 0.2395 0.38292 0.24396 0.061717 0.0063849
r6 0.0058656 0.05838 0.23728 0.38287 0.24618 0.06286 0.0065668
r7 0.0057011 0.057298 0.23505 0.38278 0.2484 0.064018 0.0067533
----------------------------------------
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
CONTAINER NAME: mp_container_map Scalars
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
i idx value
_ ___ ________
fl_ar1_persistence 1 2 0.01
fl_ar1_step 2 3 0.010001
fl_shk_std 3 4 0.01
it_std_bound 4 5 3