Basic Heterogeneous Agents Model at Stationary Equilibrium

We can conclude that:

Given the probabilities' transition matrix, it is possible to find the stationary probabilities, that define $N_{ss}$.

$K_{ss}$ defines $r_{ss}$ $w_{ss}$ $b_{ss}$

The household problem at the steady state (no need to include $K$ or $N$) is:

$$ V(a,\epsilon) = \max_{\underline{a} \leq a' \leq y(a,\epsilon)} \left\{ u(y(a,\epsilon)-a') + \beta \; \mathbb{E}[ V(a',\epsilon')\,|\epsilon] \right\} $$

Where

$$ a'|e=(1+(1-\tau)r_{ss})a+(1-\tau)w_{ss}-c:=y(a,e)-c $$$$ a'|u=(1+(1-\tau)r_{ss})a+b_{ss}-c:=y(a,u)-c $$$$ a'\geq \underline{a} $$

Following Heer & Maussner (2009) calibration is

$ \begin{pmatrix} p_{ee} & p_{eu} \\ p_{ue} & p_{uu} \end{pmatrix}= \begin{pmatrix} 0.9565 & 0.0435 \\ 0.5 & 0.5 \end{pmatrix} $

Although, I follow Heer & Maussner example (which is based in Irmohoroglu 1989), I will depart from them in some issues.

One of those is, that I think about the borrowing limit $ a_{min} $ with more detail (it is important if we want to change some parameters).

Given prices, it could happen that a houshold asset holdings are binding $a=a_{min}^*$, and even if she doesn't consume $c=0$ she wouldn't have enough income to pay the interest of his debt (recall $a_{min}^*<0$). So it is impossible to match both restrictions at the same time in this possible case.

To solve that we should think as Aiyagari, and compute the natural borrowing limit for the given prices. What if someone is unemployed and he is in the borrowing limit? It has to be the case that $a_{min}\leq a_{min}+a_{min}r(K)(1-\tau)+b(K)$. That implies, $a_{min}\geq-b(K)/(r(K)(1-\tau)$.

Therefore, I redefine the stationary borrowing limit as $a_{min}(K)=max\big\{\frac{-b(K)}{r(K)(1-\tau)}\,,\,a_{min}^*\big\}$.

Furthermore, I will use the endogenous grid method instead of value function iteration (Bellman operator it is not proven to be a contraction, although one can use it and hope, and VFI is significally slower and less accurate). For computing the stationary distribution I will use a transition matrix based on the policy function, the stationary probabilities associated with the transition matrix are the sitribution of assets.

Also, I will not iterate over $\tau$ or $b$ I will take them as functions of $K$.

Finally, it is a requisite of the model that $\beta (1+r(1-\tau))<1$. The idiosyncractyc risk brings new reason for savings, making the interest rate smaller than in a representative agent framework. Thus $\beta (1+r(K)(1-\tau(K))\geq1$ will imply $c_{t+1}>c_t$ that means today I save tomorrow I consume more, which means $a_t\rightarrow\infty$ as $t\rightarrow\infty$. That set a lower bound $K_min\;:\;\big(1+r\big(K_{min}\big)\big(1-\tau(K_{min})\big)\big)=1$.

The basic steps in the computation of the stationary distriution $f$ consists of an outer and inner loop. In the outer loop, we compute the aggregate capital stock and, hence, the factor prices and unemployment compensation. In each iteration, we find a new value of the stationary capital stock and simply update the old value by 5%. Heer & Maussner found that for higher values of the updating parameter the algorithm may not converge.

In the inner loop, we first compute the optimal policy function of the household using value function iteration. The solution provides the optimal next-period asset a' for present-period asset a and employment status e. Next, we simulate the economy for a given initial distribution of assets. We use a very simple initial distribution. Everyone holds the same (=average) wealth. Given the optimal policy function, we can compute the next-period distribution of assets and employment status. We continue to simulate the economy over a long time horizon until it converges.

Therefore we start with a first guess for $K_0$ that could be the stationary value for the representative agent problem. Then we calculate the associeted prices.

Now that we have a first guess we can compute the policy function of the household given the prices. I will not use VFI as Heer & Maussner did, instead I will use the "Endogenous Grid Method" because it is more fast and accurate (and it is becoming the standard practice). For reference you can see Coleman 2006 and QuantEcon's EGM tutorial.

EGM works with the Euler equation instead of the value function, although both operators are isomorphic (anllytically equivalent) since the policy function is much more linear, and since this method requiers esier computations, form a computational point of view this method is faster and more accurate. As VFI this method operates backwards, say from $a'$ to $a$.

Combining the envelope condition with the FOC (Euler) when restriction is not binding we have:

$$ UMg\Big(y(a,\epsilon)-g^*(a,\epsilon)\Big)=\beta\;(1+r(1-\tau))\;\mathbb{E}\Big[\,UMg\Big(y(a',\epsilon')-g^*(a',\epsilon')\Big)\,|\epsilon\,\Big] $$

Where $a'_g$ means that $a'$ is being chosen acordingly to policy function $g^*$

The Coleman operator with endogenous grid consist is defined by:

$$ y(a,\epsilon,K)-g_{n+1}(a,\epsilon,K)=\big(UMg\big)^{-1}\Big\{\beta\;(1+r(K)(1-\tau))\;\mathbb{E}\Big[\,UMg\Big(y(a',\epsilon',K)-g_n(a',\epsilon',K)\Big)\Big)\,|\,\epsilon\,\Big]\Big\} $$

Notice that in the right side you have the present period consumption express as a function of $a'$ (and $K$ and $\epsilon$). And in the left side you have the presen period consumption express as a function of $a$ (and $K$ and $\epsilon$). There is implicitly defined a function $a'=g(a,\epsilon,K;g_n)$. A reasonable approach would it by root finding, to find the $a'$ that satisfise that equation for a set of values for $a$ and $\epsilon$. But root finding is costly.

Instead of current consumption, let the equation be about current wealth (current income plus asset holdings). Since $g(a,\epsilon,K)=K'$. one can rewrite the above equation as:

$$ y(a,\epsilon,K) = H(a',\epsilon,K;g_n) $$

Since $y$ is invertible (not a requirment) we have

$$ a= y^{-1}\big(H(a',\epsilon,K;g_n),\epsilon,K;g_n\big) $$

We can define that function as an interpolation that maps a value of $a$ for each point in the two dimension grid fo $a'$ and $\epsilon$. That interpolation is $g_{n+1}^{-1}$. Since interpolation are easly inverted one con do so, and find a new policy function without any root finding.

Remember that if restriction is binding we have $a'=\underline{a}$.

The steps of EGM for this problems are

  1. Compute next period consumption with previous iteration policy function and wealth for each $a'$ and $\epsilon'$ (matrix 2 \times N_A).
  2. Compute current period consumption (requires to apply $\mathbb{E}(|\epsilon)$, $UMg$ and $UMg^{-1}$ to the matrix).
  3. Compute current period asset. The resulting grid for $a$ (a matrix actually) is endogenous.
  4. Create an interpolation from the resulting $a$ matrix ($2\times N_A$) mapping to the originally $a'$ and $\epsilon$ matrix.

We need to come up with an intial guess for the value function. One natural guess is to use the values for the value function that are implied by a household behavior where he/she simply consums their current income forever.

Veamos unos gráficos de lo que obtuvimos. Como la grilla de activos es muy grande, hagamoslo por separado. Primero haciendo foco en los primeros valores de la grilla. Y luego para los últimos. ¿Tienen sentido los resultados obtenidos?

Se puede ver que todos los empleados ahorran un poquito. Si tienen pocos activos ahorrran un poquito más. En cambio, quienes están desempleados se endeudan. Sin embargo, cuando se acercan al límite se endeudan menos, hasta el punto en que en el límite no pueden endeudarse, sino que mantienen su posición y consumen el resto de ingresos, son los llamados agentes "Keynesianos" que luego de haber pagado los intereses e impuestos, consumen todo su ingreso.

(Some reflection for above figure)

Once we get the policy function next step is to compute the distribution that the policy function implies. For this step I follow Young 2010 and McKay's notes.

To simulate a population of households I am going to use the following approach. Its broad idea is to approximate $f(a,\epsilon)$ with a matrix or one can think as two histograms $f_\epsilon$. To do so we can use the same grid $A$ that we used in EGM. Let $N_A$ be the number of grid points in the asset grid $A$. Then $f$ is a $N_A\times2$ matrix $f$ that assigns a mass to each state, (it can thought as a function $m=f_(a,\epsilon)$).

A small challenge with this approach is that the policy rule g(a,e) will not necessarily select values on the grid. For example, if the grid is $[-2,\;-1,\;0,\;1,\;2,\;3,\;4,\;...]$ and the policy function of a household returns a value of $2.25$... Where to allocate the mass of this household? Let say that this household has mass $m$, therefore the intuitive approach is to allocate $0.75m$ to the grid point $2$ and $0.25m$ to the grid point $3$.

$$ y_n = g(x_n) $$$$ x_m > y_n > x_{m-1} $$$$ y_n = \alpha x_m + (1-\alpha) x_{m-1} $$$$ \alpha = \frac{y_n-x_{m-1}}{x_m-x_{m-1}} $$$$ g(x_n) = \alpha x_m + (1-\alpha) x_{m-1} $$

Masa $d$ en $t$ en posición $n$.

Entonces, en $t+1$:

Masa $d\,\alpha$ en la posición $m$. Y masa $d\,(1-\alpha)$ en la posición $m-1$.

One approach to compute the stationary distribution $f^*$ would be to start from an initial guess and a then apply the following algorithm.

First we apply the policy function in every state, we get a $N_a\times2$ matrix $G$. As discussed above, some values will be off-grid and we followed the mentioned decision ruled that can be thought as a function $\Omega:\mathbb{R}\rightarrow \mathbb{R}^{A_N}$, it gives a vector where positions correspondig to the two nearest grid points ($\bar{a_{index}}',\underline{a_{index}}'$) the corresponding weights ($\bar{\omega},\underline{\omega}$) and 0 in the rest of the elements.

Second, we take the current distribution $f_n$ and redistributed the current mass $f_n(a,\epsilon)$ to the $f_{n+1}$ distribution to the (four) elements represented by $(a',\epsilon')$ with weight represented by $\omega \pi_{\epsilon'|\epsilon}$.

However we can do better, than iterating. Notice that the above algorithm applies a linear transformation to every value of $f$. Therefore it is possible to think the algorithm in a matrixial fashion. In order to do it appropietly, we have to reshape $f$, that is to construct a vector $F$ that contains the two rows $f$ stacked on top of one another, this implies that $F$ has size $2N_A\times1$). Then, we can create a $2N_A\times2N_A$ transition matrix $T$, that will update the distribution $F$ to $F'$ according to the decripted rule $F′=TF$. That is using the policy function $g$ and the allocation function $\Omega$ to distribute the mass of $F$ to $F'$.

How to construct $T$? Recall that acordingly to matrix multiplication we know that $D'_i=\sum_{j=1}^{2N_A}T_{i,j}D_{j}$, that implies that $T_{i,j}$ indicates how much of the mass ubicated in $j$ should be tranferred to $i$. Acording to the above discussion for $j\leq N_A$ we have $T_{i,j}=\pi_T(i|e)\Omega(G_j)_i$, where $\pi_T$ is the conditional probability considering $i\leq N_A$ as $e$ or $u$ otherwise.

Thus we can construct $T$, which is a trnasition matrix. Moreover it is a transition matrix of a Markov chain, since it works with discrete distributions, then we can compute the stationary distribution $F^*$, given by the Eigen-vector of $T$ associated with the unit Eigen-value normalized to sum to one.

I used a very simimlar implementation of Julien Pascal's code and I found his code very useful.

La fila $i$ me dice quiénes, y en qué proporción tendrán una posición $i$ de activo en el siguiente período.

Hay cuatro cuadrantes:

En la mitad occidental la intensidad del norte es mayor a la del sur porque la probabilidad de perder el empleo es baja En la mitad oriental la intensidad son las mismas porque la probabilidad de encontrar trabajo es 0.5

(Mostrar una versión con una matriz de 20x20 que se nota mejor la dinámica)

Once we have the stationary distribution we should check if the guessed valued for $K_0$ corresponds with the resulting value for $K_0'$ acording to the distribution.

El capital propuesto es incompatible con la distribución de la riqueza que genera. La tasa de interés no es lo suficientemente atractiva para mantenerlo. Lo esperable sería que haya menos capital agregado, y por en una tasa mayor y una mayor cantidad de capital generado por la distribución.

Para hallar el capital de equilibrio haremos una búsqueda binaria.

Finding Aggregate Capital

We do it with the Brent Method implemented by Omptim Package