Heterogeneous Agent Model 2

Individuals variables are in lowercase (when it's needed I will add to the notation the subindex $j$ for firms' variables and $i$ for households' variables).

Firms

There is a continuum of firms aligned in a torus made of the interval $[0\, , \, 1]$. Each firm production function is: $$ y(z,k,l)=z(\theta) k^\alpha l^{1-\alpha} $$

Every period each firm is subject to an idiosyncratic discrete shock (not correlated with the past shock). The firms $j$ total factor productivity $z_j$ is represented by: $$ z_j(\epsilon_t^j)=Z \epsilon_t^j $$

From the firm's perspective, the idiosyncratic shock is a random variable $\theta_t^j$ that has a value $\theta_h \in (1,1/p)$ with probability $p$ and a value $\theta_l = (1- \theta_h p)/(1-p) $ with probability $(1-p)$.

Wages are settled before production which implies that every firm pays the same wage $w$. Therefore $w=E[PMgL_j(k_j,l_j)]$ (normalizing output's price to one). Since every employed households offer inelastically one unit of labor each we have: $W_t=(1-\alpha)z_t(k_t/L_t)^\alpha$

Arbitrary condition impose expected retribution to capital to be the same for every firm, which means that every firm will received the same amount of capital. However, actual retribution to capital will be known after production (after the investment decision was done), that means actual retribution to capital is a random variable. The total return paid by firm $j$ is $R_j(\theta_t^j)=y_j(\theta_t^j)-w$, simplifying the notation that is: $R_j(\theta_t^j)=Z (\theta_t + \alpha -1) K^\alpha$. Then the return per unit of capital ($R_j=1+r_j$) is:

\begin{equation*} R_j(\theta)=Z (\theta + \alpha -1) (K/L)^{\alpha-1} \end{equation*}

Let's define $\bar{R}\equiv \alpha Z K^{\alpha-1} $. And add the restriction $\theta_l > 1 - \alpha$

Limited diversification

Firms finance their capital input by selling equity. However equity cannot be fully diversified, that is I introduce a friction in the financial market that limits diversification. Savers cannot buy as many types of equity as they want, they can only buy an asset made of equals amount of equities from $d$ types of firms. From a broad point of view we can think of $\theta_t$ as uniformed random variable in the interval $[0,1]$ that produces a shock of length $p$. Recall, firms are located in a torus, say a circumference, therefore the circumference is divided in two segments: one with $\theta_h$ and one with $\theta_l$. In this example I will restrict $d=2$ to make it easier, that is the asset is compound by equities from two random points of the circumference.

Then, there are three states for the return of the $d$-equities compound asset $a$, $R(\theta_t)$, as:

\begin{split} R_{l}=Z (\theta_l + \alpha -1) (K/L)^{\alpha-1} \;\;\;\;\text{with probability}\; (1-p)^2 \\ R_{m}=Z ((\theta_l+\theta_h)/2 + \alpha -1) (K/L)^{\alpha-1} \;\;\;\;\text{with probability}\; 2 p(1-p) \\ R_{h}=Z (\theta_h + \alpha -1) (K/L)^{\alpha-1} \;\;\;\;\text{with probability} \; p^2 \end{split}

Why the torus? Let suppose someone buys a large quantity of one asset, say $a>2K$, where $K$ is the aggregate capital, if this financing money went to just two firms, they would have a higher asset stock than most firms. However, if the excess capital is destined to their closed neighbors the asymmetry of capital inputs is avoided, while it is ensured that there is no extra diversification since closed neighbor firms are closed enough that the remains in the same part of the circumference.

Also, notice that decreasing marginal productivity induce capital allocation to spread out across firms. Simply put, savers won't buy an asset made from firms which their equities are yielding a lower rate of return than others, that is won't buy assets of firms that already received $K$, if there is a firm with less than average amount of capital yet (basic equilibrium concept).

Households

There is a continuum of households aligned in the interval $[0\; , \; 1]$. Households are subject to an idiosyncratic employment shock, that follows a two state markov process $\epsilon_t\in\{e,u\}$ (employed, unemployed). Households supply labor inelastically (household $i$ supplies $\epsilon_t^i$ at period $t$, e.g.)

Therefore, aggregate stationary employment is determined by the probabilities of the markov process: $$N_{ss}=\Pr(\epsilon'=e|u)\,/\,\big[Pr(\epsilon'=u|e)+Pr(\epsilon'=e|u)\big]$$

Household also like to consume and to save. Consumptions preferences are defined by the instantaneous utility function: $u(c)=1-1/c$, and the intertemporal discount factor $\beta$. Savings is done by purchasing the partially diversified portfolios defined above.

If a household is employed, she receives a wage $w$, if she is not, she receives an employment compensation from the government $s$. Also she has to pay income taxes (except for the employment compensation $s$) . Therefore, at time $t$ they face the following restrictions:

$$ c_t+a_t \leq \epsilon_t w (1-\tau) + (1-\epsilon_t)b + a_{t-1}R(\theta _t)(1-\tau) $$$$ a_t \geq 0 $$

Euler equation is:

$$ UMg[c_t(\epsilon_t,\theta_t)]=\beta (1-\tau) E\{R(\theta_{t+1})UMg[c_{t+1}(\epsilon_{t+1},\theta_{t+1})]\} $$

Government

Finally, the government simple redistributes incomes by taxing revenues from labor and capital and paying employment compensations. I maintains a 0 deficit policy which implies:

\begin{equation*} \tau\int_0^1 \Big[\, R(\theta_t^i)a^i_t + w_t \epsilon_t^i \,\Big] \text{d}i = b_t (1-N_{ss}) \end{equation*}$$ \tau y(Z_t,K_t,N_{ss}) = b_t (1-N_{ss}) $$

What if someone is unemployed and she is in the borrowing limit? Her income would be $a_{min}+a_{min}r(K,\theta)(1-\tau)+s(K)$. Since $c\geq 0$ we can conclude that $a_{min}+a_{min}r(K,\theta)(1-\tau)+s(K) \geq a'$.

And since, $a'\geq a_{min}$ we have $a_{min}+a_{min}r(K,\theta)(1-\tau)+s(K) \geq a_{min}$ for all $\theta$. That implies, $a_{min}\geq-s(K)/\big(r(K,\theta)(1-\tau)\big)$.

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

The basic steps in the computation of the stationary distribution 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 the inner loop, we use the prices to compute the optimal policy function of the household using EGM. Then we compute the transition probability matrix having asset $a'$ at state $(\epsilon',\theta')$ at next period given that current period is $a$ $\epsilon, \theta$. Finally we find the stationary distribution for $a$ and the aggregate capital.

Therefore we start with a first guess for $K_0$. This could be the stationary value for the representative agent problem, for example.

EGM works with the Euler equation instead of the value function, and as VFI this method operates backwards, from $a'$ to $a$. Combining the envelope condition with the FOC (Euler) and rearranging, we have:

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

Since $y$ is invertible (not an actual requirement) we have:

$$ a= g_{n+1}^{-1}\big(a',\epsilon,\theta, 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 for $a'$, $\epsilon$ and $\theta$. That interpolation is $g_{n+1}^{-1}$. Since interpolation are easily inverted one can do so, and find a new policy function without any root finding.

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 $6 \times N_A$).
  2. Compute current period consumption (requires to apply $\mathbb{E}(|\epsilon,\theta)$, $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 ($6\times N_A$) mapping to the originally $a'$ matrix.

Nota:

¿Qué hacer si el consumo del próximo período dada la función de política $g_n$ es negativo para algún estado $(a,\epsilon,\theta)$ ?

Aunque para algunas funciones de utilidad marginal esto se puede computar, para otras no. Opté por imponer $c'>0$.

Esto no debería ser necesario, porque esos casos no deberían formar parte de la solución del problema de maximización, es decir la restricción $c_t\geq0$ no debería ser vinculante. El problema es que al poner una función de política cualquiera para empezar no siempre funciona.

Hay que testear que la función de política final (luego de las iteraciones) cumpla con $c'>0$ sin necesidad de imponerselo luego.

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.

Following Young 2010 I approximate $f(a|\epsilon)$ as 2 histograms grouped in a vector of dimension $2N_A\times1$, where $N_A$ is the number of grid points in the asset grid $A$.

It is not necessary to condition in $\theta$ since it is not correlated with the past, then $f(a|\epsilon,\theta)=f(a|\epsilon)Pr(\theta)$. This reduce the dimensionality of $d$ and the transition matrix.

Given the discretized distribution $d$ of size $2N_a\times 1$ and a policy function $g$ we can construct a transition matrix $T$ such that $d'=Td$. Where $T_{i,j}$ indicates how much of the mass located at $j$ should be transferred to $i$.

First, we apply the policy function for every $\theta$ to position $j$, where $j\in\{1,2,...2A_N\}$, that is $j$ represents a pair $(a,\epsilon)$. We use a policy correspondence $g(a,\epsilon)$ instead of the policy function $g(a,\epsilon,\theta)$.

Elements of $g(a,\epsilon)$ will not be necessarily 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$. Then the second step is to build a correspondence $\Omega$ that takes $a$-values off grid and returns weights for each position on the grid. Specifically, let $\Omega:\mathbb{R}\rightarrow \mathbb{R}^{A_N}$, be a correspondence that gives a vector of 0s, except for the elements located at the position of the two nearest grid points (positions $i$ and $i+1$ such that $a_i<a'<a{i+1}) where assigns weights $\omegai = |a{i+1}-a'|/(a_{i+1}-ai)$ and $\omega{i+1}=|ai-a'|/(a{i+1}-a_i)$.

Third, we construct $T$ according to $T_{i,j} = \Omega(g(a_j))_i $Pr(\theta')\pi(\epsilon'|\epsilon)$ $ indicates how much of the mass located at $j$ should be transferred to $i$.using the known probabilities we compute the probability $Pr(\theta')\pi(\epsilon'|\epsilon)$

Given a discretized distribution $d$ of size $6N_a\times 1$ and a policy function $g$ we can construct a transition matrix $T$ such that $d'=Td$. Where $T_{i,j}$ indicates how much of the mass located at $j$ should be transferred to $i$.

First we apply the policy function in every state, we get a vector $G$ of dimension $6N_a\times 1$

Second, since some values of $a'=g(a,\theta,\epsilon)$ will be off-grid, say $a_i<a'<a_{i+1}$, we construct a correspondence $\Omega$ that works as a decision rule for allocating $a'$ to the grid. Specifically, let $\Omega:\mathbb{R}\rightarrow \mathbb{R}^{A_N}$, be a correspondence that gives a vector of 0s, except for the elements located at the position of the two nearest grid points (positions $i$ and $i+1$ such that $a_i<a'<a{i+1}) where assigns weights $\omegai = |a{i+1}-a'|/(a_{i+1}-ai)$ and $\omega{i+1}=|ai-a'|/(a{i+1}-a_i)$.

Third we construct $T$ according to $T_{i,j} = \Omega(g(a_j))_i $Pr(\theta')\pi(\epsilon'|\epsilon)$ $ indicates how much of the mass located at $j$ should be transferred to $i$.using the known probabilities we compute the probability $Pr(\theta')\pi(\epsilon'|\epsilon)$

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

Then, we can create a $6N_A\times6N_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}^{3N_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.

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.

Claramente, el capital propuesto es incompatible con la distribución de la riqueza que genera.

Finding Aggregate Capital

We do it with the Brent Method implemented by Omptim Package