# A heterogeneous agent new Keynesian model¶

We now apply the Reiter method to solve a heterogeneous agent new Keynesian model. This is a rather large departure from the preceding models, but this only requires small extensions of the methods.

## Model assumptions¶

Commodities. Households consume a final good that is produced out of a range of intermediate goods. The intermediate goods are produced out of labor.

Preferences. We assume the same preferences as before

$\mathbb E_0 \sum_{t=0}^\infty \beta^t \frac{ c_t^{1-\gamma}}{1-\gamma}.$

Endowments. We will endogenize the labor market transitions in the form of unemployment spells with an exogenous job-separation rate and an endogenous job-finding rate. The we’ll assume all workers have the same productivity so aggregate labor supply is $$1-u$$ where $$u$$ is the unemployment rate.

Technology. Intermediate variety $$j$$ is produced according to

$y_{j,t} = A_t N_{j,t}$

where $$A_t$$ is an aggregate productivity and $$N_{j,t}$$ is the labor employed by firm $$j$$. The final good is produced as a Dixit-Stiglitz aggregate of the intermediate inputs

$Y_t = \left( \int_0^1 y_{j,t} ^{\frac{\varepsilon-1}{\varepsilon}} dj \right)^{\frac{\varepsilon}{\varepsilon-1}},$

where $$\varepsilon$$ is the elasticity of substitution between intermediate varieties.

Market structure. The final good is produced by a perfectly competitive representative firm. The intermediate goods are produced by monopolistic competitors. The intermediate goods producers are subject to Calvo-style price adjustment frictions and revise their prices with probability $$1-\theta$$. The labor market is affected by search frictions, which we model in the style of Blanchard and Gali (2010). We use the job finding rate, $$M_t$$, as a measure of labor market tightness and firms hire workers at a cost that is increasing in labor market tightness. The cost of hiring a worker is $$\psi M_t$$. Matches dissolve at the exogenous rate $$\delta$$. We will assume the wage is an increasing function of labor market tightness $$w_t = \bar w (M_t/\bar M)^\zeta$$, where a bar denotes a steady state value and $$zeta$$ is the elasticity of wages with respect to labor market conditions.

Intermediate goods firms will make profits. We assume that these profits are shared equally among the employed workers. Households can accumulate bonds that pay nominal interest rate $$i_t$$ between periods $$t$$ and $$t+1$$. It will be useful to introduce the ex post real return on bonds $$R_t \equiv (1+i_{t-1})/pi_t$$ $$\pi_t$$ is the gross inflation rate between $$t-1$$ and $$t$$.

Government. There are three aspects of policy in this economy. First, there is social insurance: employed workers pay a proportional labor income tax with rate $$\tau$$ and unemployed workers receive an unemployment benefit in amount $$b$$. Second, the government has a constant (in real terms) stock of debt $$B$$ outstanding, which it rolls over in perpetuity. The interest on the debt is financed by the labor income tax. Finally, there is a monetary policy in the form of a rule for the nominal interest rate $$1+i_t = \bar R \pi_t^\omega \xi_t$$, where $$\xi_t$$ is a monetary policy shock that follows an AR(1) process in logs.

## Household’s problem¶

The household maximizes

$\mathbb E_0 \sum_{t=0}^\infty \beta^t \frac{ c_t^{1-\gamma}}{1-\gamma}$

subject to the budget constraint (in real terms)

\begin{aligned} a_{t} + c_t = R_{t} a_{t-1} + \mbox{earnings},\end{aligned}

where earnings are given by

\begin{split}\begin{aligned} \mbox{earnings} = \begin{cases} (1-\tau_t) \left( w_t + d_t \right) & \mbox{if employed} \\ b & \mbox{if unemployed,} \end{cases}\end{aligned}\end{split}

where $$d_t$$ is the dividend per employed worker. In addition, the household faces the borrowing constraint $$a' \geq 0$$. The transition matrix across employment states is given by

$\begin{split}\left( \begin{matrix} 1-M_t & \delta \\ M_t &1-\delta \end{matrix} \right)\end{split}$

where the first state is unemployed and the second is employed.

## Firm problems¶

The final good firm solves the usual Dixit-Stiglitz cost-minimization problem resulting in a demand for variety $$j$$ of

$y_{j,t} = \left( \frac{p_{j,t}}{ P_t} \right)^{-{\varepsilon}} Y_t$

and price index $$P_t$$ given by

$P_t^{1-{\varepsilon}} = \int_0^1 p_{j,t}^{1-{\varepsilon}} dj.$

The intermediate goods firm that updates its price at $$t$$ chooses $$p_t^*$$ to maximize

$\mathbb E_t \sum_{s=t}^\infty \theta^{s-t} R_{t,s}^{-1} \left[ \frac{p_t^*}{P_s} y_{j,s} - w_s n_{j,s} - \psi M_s h_{j,s}\right]$

where $$n_{j,t}$$ denotes employment at firm $$j$$ at date $$t$$, $$h_{j,t}$$ denotes hiring, and $$R_{t,s}^{-1}$$ denotes the real interest rate discount from period $$s$$ back to period $$t$$. The constraints on the firm’s problem are

\begin{split}\begin{aligned} y_{j,s} &= \left( \frac{p_t^*}{ P_s} \right)^{-{\varepsilon}} Y_s \\ y_{j,s} &= A_s n_{j,s} \\ n_{j,s} &= (1-\delta) n_{j,s-1} + h_{j,s}.\end{aligned}\end{split}

We can form the Lagrangian

\begin{split}\begin{aligned} \mathcal L = \mathbb E_t \sum_{s=t}^\infty \theta^{s-t} R_{t,s}^{-1} & \Big[ \frac{p_t^*}{P_s} y_{j,s} - w_s n_{j,s} - \psi M_s h_{j,s} \\ &-\lambda_{1,s} \left( y_{j,s} - \left( \frac{p_t^*}{ P_s} \right)^{-{\varepsilon}} Y_s \right) \\ &-\lambda_{2,s} \left(y_{j,s} - A_s n_{j,s} \right) \\ &-\lambda_{3,s} \left(n_{j,s} - (1-\delta) n_{j,s-1} - h_{j,s} \right) \Big].\end{aligned}\end{split}

The first-order conditions with respect to $$p_t^*$$, $$y_{j,s}$$, $$n_{j,s}$$, and $$h_{j,s}$$ are

\begin{split}\begin{aligned} \mathbb E_t \sum_{s=t}^\infty \theta^{s-t} R_{t,s}^{-1} \left[ \frac{y_{j,s}}{P_s} - \lambda_{1,s} {\varepsilon}\left( \frac{p_t^*}{ P_s} \right)^{-{\varepsilon}-1} \frac{Y_s}{P_s} \right] &= 0 \\ \frac{p_t^*}{P_s} - \lambda_{1,s} - \lambda_{2,s} &= 0 \\ -w_s + \lambda_{2,s}A_s - \lambda_{3,s} + (1-\delta) \mathbb E_s \lambda_{3,s+1} &= 0 \\ \lambda_{3,s} - \psi M_s &= 0. \end{aligned}\end{split}

$$\lambda_{2,s}$$ is marginal cost at date $$s$$. Rearranging the FOCs yields

\begin{aligned} \frac{p_t^*}{P_t} = \frac{{\varepsilon}}{{\varepsilon}-1} \frac{ \mathbb E_t \sum_{s=t}^\infty \theta^{s-t} R_{t,s}^{-1} \left[ \lambda_{2,s} \left(\frac{P_s}{P_t}\right)^{{\varepsilon}} Y_s \right] }{\mathbb E_t \sum_{s=t}^\infty \theta^{s-t} R_{t,s}^{-1} \left[ \left(\frac{P_s}{P_t}\right)^{{\varepsilon}-1} Y_s \right] }.\end{aligned}

Define

\begin{split}\begin{aligned} p_t^A & \equiv \mathbb E_t \sum_{s=t}^\infty \theta^{s-t} R_{t,s}^{-1} \left[ \frac{{\varepsilon}}{{\varepsilon}-1} \lambda_{2,s} \left(\frac{P_s}{P_t}\right)^{{\varepsilon}} Y_s \right] \\ p_t^B & \equiv \mathbb E_t \sum_{s=t}^\infty \theta^{s-t} R_{t,s}^{-1} \left[ \left(\frac{P_s}{P_t}\right)^{{\varepsilon}-1} Y_s \right].\end{aligned}\end{split}

These evolve recursively according to

\begin{split}\begin{aligned} p_t^A & = \frac{{\varepsilon}}{{\varepsilon}-1} \lambda_{2,t} Y_t + \mathbb E_t \left[ \theta R_{t+1}^{-1} \pi_{t+1}^{{\varepsilon}} p_{t+1}^A \right] \\ p_t^B &= Y_s +\mathbb E_t \left[ \theta R_{t+1}^{-1} \pi_{t+1}^{{\varepsilon}-1} p_t^B \right].\end{aligned}\end{split}

## Equilibrium conditions¶

A fraction $$1-\theta$$ of prices are update each period and let the optimal reset price be denoted $$P_t^*$$. We then have

\begin{split}\begin{aligned} P_t^{1-{\varepsilon}} &= \int_0^1 p_{j,t}^{1-{\varepsilon}} dj \\ &= \theta \int_0^1 p_{j,t-1}^{1-{\varepsilon}} dj +(1-\theta) \left( P_t^*\right)^{1-{\varepsilon}} \\ &= \theta P_{t-1}^{1-{\varepsilon}} +(1-\theta) \left( P_t^*\right)^{1-{\varepsilon}} \\ \pi_t^{1-{\varepsilon}} &= \theta +(1-\theta) \left( \frac{P_t^*}{P_t} \pi_t \right)^{1-{\varepsilon}} \\ \pi_t &= \theta^{\frac{1}{1-{\varepsilon}}} \left[1-(1-\theta) \left( \frac{P_t^*}{P_t} \right)^{1-{\varepsilon}} \right]^{-\frac{1}{1-{\varepsilon}}} \\\end{aligned}\end{split}

where $$\pi_t \equiv P_t / P_{t-1}$$.

Integrating across the demands for each variety and using the production function for intermediates we have

\begin{aligned} A_t \int_0^1 n_{j,t} dj = \int_0^1 \left( \frac{p_{j,t}}{ P_t} \right)^{-{\varepsilon}} djY_t.\end{aligned}

The integral on the right-hand side is the efficiency loss due to price dispersion and is equal to one to a first-order approximation so we will ignore it here. This leaves us with the aggregate production function

$Y_t = A_t N_t$

where $$N_t\equiv\int_0^1 n_{j,t} dj$$ is aggregate labor input. Labor market clearing requires $$N_t = 1-u_t$$.

Government budget balance (nominal then real):

\begin{split}\begin{aligned} \tau P_t (w_t+d_t) (1-u_t) + P_t B &= (1+i_{t-1}) P_{t-1} B + P_t b u_t \\ \tau (w_t+d_t) (1-u_t) + B &= R_{t} B + b u_t\end{aligned}\end{split}

The aggregate resource constraint is that the final good is used for consumption and hiring costs

$Y_t = C_t + \psi M_t H_t$

where $$H_t$$ is aggregate hiring.

The evolution of (un)employment, hiring and the job finding rate are determined as follows

\begin{split}\begin{aligned} N_t = (1-\delta) N_{t-1} + H_t \\ 1-u_t = (1-\delta) (1-u_{t-1}) + H_t \\ M_t = \frac{ H_t }{u_{t-1} + \delta N_{t-1}} \\ M_t = \frac{ 1-u_t - (1-\delta) (1-u_{t-1})}{ u_{t-1} + \delta (1-u_{t-1})}. \end{aligned}\end{split}

The aggregate output of intermediate producers net of hiring costs is paid in wages and dividends

\begin{aligned} Y_t -\psi M_t H_t = (w_t+d_t) (1-u_t). \end{aligned}

Integrating the household budget constraint

$\int g_t(a,e) d \Gamma_t(a,e) + \int c_t(a,e) d \Gamma_t(a,e) = I_{t-1} \int a d \Gamma_t(a,e) + (1-u_t) (1-\tau)(w_t + d_t) + u_t b.$

we can use the other equations of the model to rewrite this equation as bond market clearing

$\int g_t(a,e) d \Gamma_t(a,e) = B.$

By Walras’s Law we may impose either one of these equations. In some instances I have encountered existence issues imposing the aggregate resource constraint but not when imposing bond market clearing.

## Model summary¶

An equilibrium of the model requires household policy rules for savings $$g_t(a,e)$$ and a distribution of wealth $$\Gamma_t(a,e)$$ that evolve according to the household’s problem with a job finding rate given by $$M_t$$, wage $$w_t$$, tax rate $$\tau_t$$, and dividends $$d_t$$.

In addition, at each date we have a vector of “aggregate” variables $$( M_t, w_t, \tau_t, d_t, Y_t, u_t, i_t, R_t, \pi_t, p_t^A, p_t^B )$$. These variables must satisfy

\begin{split}\begin{aligned} M_t &= \frac{ 1-u_t - (1-\delta) (1-u_{t-1})}{ u_{t-1} + \delta (1-u_{t-1})} \\ w_t &= \bar w (M_t/\bar M)^\zeta \\ \tau (w_t+d_t) (1-u_t) + B &= R_{t} B + b u_t \\ Y_t -\psi M_t \left( 1-u_t - (1-\delta) (1-u_{t-1}) \right) &= (w_t+d_t) (1-u_t) \\ Y_t &= A_t (1-u_t) \\ \int g_t(a,e) d \Gamma_t(a,e) &= B \\ 1+i_t &= \bar R \pi_t^\omega \xi_t \\ R_t &= \frac{1+i_{t-1}}{\pi_t} \\ \pi_t &= \theta^{\frac{1}{1-{\varepsilon}}} \left[1-(1-\theta) \left( \frac{p_t^A}{p_t^B} \right)^{1-{\varepsilon}} \right]^{-\frac{1}{1-{\varepsilon}}} \\ p_t^A & = \frac{{\varepsilon}}{{\varepsilon}-1} \frac{w_t + \psi M_t - (1-\delta) \mathbb E_t \left[ \psi M_{t+1} \right]}{A_t} Y_t + \theta R_{t+1}^{-1} \mathbb E_t \left[ \pi_{t+1}^{{\varepsilon}} p_{t+1}^A \right] \\ p_t^B &= Y_t + \theta R_{t+1}^{-1}\mathbb E_t \left[ \pi_{t+1}^{{\varepsilon}-1} p_t^B \right].\end{aligned}\end{split}

and the exogenous processes

\begin{split}\begin{aligned} \log A_t &= \rho_A \log A_{t-1} + \epsilon_{A,t} \\ \log \xi_t &= \rho_\xi \log \xi_{t-1} + \epsilon_{\xi,t}. \end{aligned}\end{split}

## Solving the model with the Reiter method¶

We again create a large system of equations involving the household decision rules, the distribution of wealth, and aggregate variables. The equations include the Euler equation residuals, the evolution of the distribution of wealth and the equations above will be our aggregate equations in our system. Implementing this solution requires only a few modifications to our previous Reiter method code.

The transitions across employment states now depend on the endogenous job finding rate $$M_t$$ and this must be incorporated into the Euler equation and the dynamics of the distribution of wealth. It may seem natural to keep track of the distribution of wealth as the current savings and employment status. If you do that, notice that the timing of the distribution of wealth is different from the Aiyagari/Krusell-Smith model considered before. In that model, the distribution of state variables at the beginning of period $$t$$ is determined in $$t-1$$. Here, however, the distribution of assets is determined at $$t-1$$, but the distribution of households over employment status is determined at $$t$$. I find it easier to keep the timing straight if I keep track of the distribution of states at the end of the period $$t-1$$ before the employment transitions at the start of period $$t$$ have occurred.