Undergraduate Computational Macro
A classic benchmark which preserves this self-consistency is the rational expectations equilibrium (REE)
As with rational expectations, agents do not know the future exactly, but forecast given the information they have and to have no systematic biases
Since the good is undifferentiated, and if we assume that prices are determined by the aggregate supply and demand, we can summarize demand as an inverse-demand function
\[ p(Y) \equiv a_0 - a_1 \sum_{n=1}^N y_n = a_0 - a_1 Y \]
Taking prices \(p(Y)\) and the perceived output of the other firms (\(Y\)) as given the firm solves
\[ \max_{y} \left\{ p(Y) y - c(y) \right\} \]
Take the problem with the cost and prices
\[ \max_{y} \left\{ (a_0 - a_1 Y) y - c_1 y - \frac{N}{2}c_2 y^2 \right\} \]
Take the FOC with respect to the \(y\). Don’t touch the \(Y\)! They take it as given
\[ a_0 - a_1 Y - c_1 - c_2 N y = 0 \]
Finally, to impose the REE we have that \(Y = N y\) so that
\[ a_0 - a_1 Y - c_1 - c_2 Y = 0 \]
The MPE/Nash equivalent in this case would be if the firm considers that its own output will affect the price
In particular, firm \(n\) forecasts \(y_j\) for all \(j \neq n\) and then solves
\[ \max_{y_n} \left\{ p\left(\sum_{j\neq n}y_j + y_n \right)y_n - c(y_n) \right\} \]
With large \(N\), \(\partial_{y_n} p(Y) \approx 0\) and an REE is a good approximation
The agents have a deterministic perceived law of motion for \(Y_t\)
Given the known initial condition \(Y_0\), define this as
\[ Y_{t+1} = H(Y_t) \]
This belief \(H(\cdot)\) is an equilibrium object we will solve for
Take \(H(\cdot)\) as given and generate \(Y_t\) from \(H(\cdot)\) and \(Y_0\)
Firm period profits net adjustment costs are \(p(Y_t) y_t - c(y_{t+1}, y_t)\)
The firm takes prices, \(y_0, Y_0\) and given, and solves \[ \max_{\{y_{t+1}\}_{t=0}^{\infty}} \left\{\sum_{t=0}^{\infty}\left(p(Y_t) y_t - c(y_{t+1}, y_t)\right)\right\} \]
Jumping to a Bellman Equation with value function: \(v(y,Y)\)
The state: \(y\) for the firm, and \(Y\) for the aggregate. Take \(H(\cdot)\) as given
\[ \begin{aligned} v(y,Y) &= \max_{y'} \left\{ p(Y) y - c(y', y) + \beta v(y', H(Y))\right\}\\ &= \max_{y'} \left\{ a_0 y - a_1 y Y - \frac{ \gamma (y' - y)^2}{2} + \beta v(y', H(Y))\right\} \end{aligned} \]
Note that \(v(y,Y)\) and \(h(y,Y)\) would depend on the \(H(Y)\)
Take the FONC, then \[ -\gamma (y' - y) + \beta v_y(y',H(Y)) =0 \]
Substituting this equation gives \[ -\gamma (y_{t+1} - y_t) + \beta [a_0 - a_1 Y_{t+1} + \gamma (y_{t+2} - y_{t+1} )] =0 \]
Choose a functional form for the LOM. In this case, we will guess that \[ Y_{t+1} = H(Y_t) = \kappa_0 + \kappa_1 Y_t \]
Then, for some \(\kappa_0\) and \(\kappa_1\) guess, we solve the firm’s problem taking the \(H(Y_t)\) as given
Use the \(N=1\) example, and set \(Y_t = y_t\) and find the implied \(\kappa_0\) and \(\kappa_1\)
\[ \begin{aligned} Y_{t+1} &= H(Y_t) = \kappa_0 + \kappa_1 Y_t\\ N y_{t+1} &= N h(y_t, Y_t) = N h_0 + N h_1 y_t + N h_2 Y_t \end{aligned} \]
Applying the simple \(N=1\) case we have \(y_t = Y_t\) which means that
\[ \kappa_0 + \kappa_1 Y_t = h_0 + h_1 Y_t + h_2 Y_t \]
Iterate until \(\kappa_0 \approx h_0\) and \(\kappa_1 \approx h_1 + h_2\)
If the perceived law of motion is \(Y_{t+1} = H(Y_t) = \kappa_0 + \kappa_1 Y_t\) this fits the LSS
Let \(x_t \equiv \begin{bmatrix} y_t & Y_t & 1\end{bmatrix}^{\top}\)
Let \(u_t \equiv y_{t+1} - y_t\), i.e. scalarchange in output
\[ \underbrace{\begin{bmatrix} y_{t+1} \\ Y_{t+1} \\ 1\end{bmatrix}}_{\equiv x_{t+1}} = \underbrace{\begin{bmatrix} 1 & 0 & 0 \\ 0 & \kappa_1 & \kappa_0 \\ 0 & 0 & 1 \end{bmatrix}}_{\equiv A} \underbrace{\begin{bmatrix} y_t \\ Y_t \\ 1\end{bmatrix}}_{\equiv x_t} + \underbrace{\begin{bmatrix} 1 \\ 0 \\ 0 \end{bmatrix}}_{\equiv B} u_t \]
Payoffs in our model are \[ p(Y_t) y_t - c(y_{t+1}, y_t) = a_0 y_t - a_1 y_t Y_t - \frac{ \gamma (y_{t+1} - y_t)^2}{2} \]
Mapping to the LQ setup
\[ = \underbrace{\begin{bmatrix} y_t & Y_t & 1\end{bmatrix}}_{\equiv x_t^{\top}} \underbrace{\begin{bmatrix} 0 & a_1/2 & -a_0/2 \\ a_1/2 & 0 & 0 \\ -a_0/2 & 0 & 0 \end{bmatrix}}_{\equiv R} \underbrace{\begin{bmatrix} y_t \\ Y_t \\ 1\end{bmatrix}}_{\equiv x_t} + u_t^{\top} \underbrace{\begin{bmatrix} \gamma / 2\end{bmatrix}}_{\equiv Q} u_t \]
LQ optimal control gives an optimal \(u_t = - F x_t\)
For our \(u_t\) and \(x_t\),
\[ \begin{aligned} u_t &= y_{t+1} - y_t = - F_1 y_t - F_2 Y_t - F_3\\ y_{t+1} &= (1-F_1) y_t - F_2 Y_t - F_3\\ \end{aligned} \]
Let \(y_t = Y_t\) to apply REE condition for \(N=1\) \[ Y_{t+1} = - F_3 + (1-F_1 - F_2) Y_t \equiv \hat{\kappa}_0 + \hat{\kappa}_1 Y_t \]
Compare to the assumed \(H\) LOM to solve
\[ Y_{t+1} = H(Y_t) = \kappa_0 + \kappa_1 Y_t \]
function solve_firm_problem(kappa, mod)
kappa_0, kappa_1 = kappa # beliefs for H(Y_t)
(; a_0, a_1, gamma, beta) = mod
A = [1 0 0
0 kappa_1 kappa_0
0 0 1]
B = [1.0, 0.0, 0.0]
R = [0 a_1/2 -a_0/2
a_1/2 0 0
-a_0/2 0 0]
Q = gamma/2
lq = QuantEcon.LQ(Q, R, A, B; bet = beta) # Package solves for u_t = -F x_t
P, F, d = stationary_values(lq)
kappa_0_hat = -F[3]
kappa_1_hat = 1 - F[1] - F[2]
return [kappa_0_hat, kappa_1_hat] # implied h(Y_t, Y_t)
end
function solve_REE(mod; kappa_iv = [95.5, 0.95], Y_ss_iv = [1500.0])
sol = fixedpoint(kappa -> solve_firm_problem(kappa, mod), kappa_iv)
kappa_0, kappa_1 = sol.zero
H(Y) = [kappa_0 + kappa_1 * Y[1]] # vectorized
Y_ss = fixedpoint(Y -> H(Y), Y_ss_iv).zero # steady state of H(Y)
return (;kappa_0, kappa_1, H, Y_ss)
end
firm_dynamics_model(;a_0 = 100, a_1 = 0.05, beta = 0.95, gamma = 10.0) = (;a_0, a_1, beta, gamma)
kappa_iv = [95.5, 0.95] # H() belief initial condition
mod = firm_dynamics_model() # default values
kappa_hat = solve_firm_problem(kappa_iv, mod)
(;kappa_0, kappa_1, H, Y_ss) = solve_REE(mod; kappa_iv)
@show solve_firm_problem([kappa_0, kappa_1], mod) - [kappa_0, kappa_1];
solve_firm_problem([kappa_0, kappa_1], mod) - [kappa_0, kappa_1] = [1.7195134205394424e-12, 1.1102230246251565e-15]
function iterate_map(f, x0, T)
x = zeros(length(x0), T + 1)
x[:, 1] = x0
for t in 2:(T + 1)
x[:, t] = f(x[:, t - 1])
end
return x
end
(;H, Y_ss) = solve_REE(mod)
Y_0 = [1500.0]
T = 50
Y_path = iterate_map(H, Y_0, T) # H
plot(Y_path'; label = L"Y_t", xlabel = L"t",
size = (600, 400), legend = :bottomright)
hline!([Y_ss[1]]; label = L"Y^*",
linestyle=:dash)
(;H, Y_ss) = solve_REE(mod)
Y_0 = [1500.0]
T = 200
Y_path = iterate_map(H, Y_0, T)
plot(Y_path'; label = L"Y_t(\gamma = 10.0)",
xlabel = L"t", size = (600, 400),
legend = :bottomright)
mod = firm_dynamics_model(;gamma = 20.0)
(;H, Y_ss) = solve_REE(mod)
Y_path = iterate_map(H, Y_0, T)
plot!(Y_path'; label = L"Y_t(\gamma = 20.0)")
hline!([Y_ss[1]]; label = L"Y^*",
linestyle=:dash)