I coded up an example based on an Aiyagari model with an awesome state for the labor efficiency shock. This is in turn inspired by:
Appendix E.3 of Fatih Guvenen, Gueorgui Kambourov, Burhan Kuruscu, Sergio Ocampo, Daphne Chen, Use It or Lose It: Efficiency and Redistributional Effects of Wealth Taxation, The Quarterly Journal of Economics, Volume 138, Issue 2, May 2023, Pages 835–894, Use It or Lose It: Efficiency and Redistributional Effects of Wealth Taxation* | The Quarterly Journal of Economics | Oxford Academic
The purpose of this example was to solve a model with stochastic ageing with the toolkit. The model has a decision variable d
, labor supply, and the state variables are:
a
: assets, endogenous
e
: labor efficiency, exogenous
age
={young,retired}, exogenous
The default/standard way of doing this is to set up the exogenous state z
as the combo of (e,age)
as follows:
n_z = [n_e,n_age];
z_grid = [e_grid;age_grid];
pi_z = [(1-Params.prob_ret)*pi_e, Params.prob_ret*eye(n_e);
Params.prob_death*ones(n_e,1)*G_e', (1-Params.prob_death)*eye(n_e)];
where pi_e
is a [n_e*n_e]
transition matrix and pi_z
is a [2*n_e,2*n_e]
transition matrix.
This approach however is “dumb” because it wastes grid points: if age=retired
, there is no need to keep track of labor productivity e
.
Another approach (thanks for the suggestion @robertdkirkby!) is to use correlated shocks and set up the z variable as:
n_z = [n_e+1,1];
z_grid = [e_grid,age_grid(1)*ones(n_e,1)
0, age_grid(2)];
pi_z = [(1-Params.prob_ret)*pi_e, Params.prob_ret*ones(n_e,1);
Params.prob_death*G_e', (1-Params.prob_death)];
Note that I put a 0 for e when age=2 but I could have written any value, since it is not used. Now z_grid
is a matrix of size [n_e+1,2]
and pi_z is a matrix of size [n_e+1,n_e+1]
I compared these two methods and, as expected, the code with correlated shock is faster. However there are small differences in the results. I tracked down the source of the discrepancy to the distribution (the policy functions are identical)
Compare method 1 to method 2
||Policy_a_m1-Policy_a_m2||
0
||StationaryDist_m1-StationaryDist_m2||
0.00307548793025022
My codes are available here: GitHub - aledinola/Awesome-state-Aiyagari