using Distributions, Plots, LaTeXStrings, LinearAlgebra, Statistics, Random, QuantEcon, NLsolveAssignment 5
Student Name/Number:
Instructions
- Edit the above cell to include your name and student number.
- Submit just this
ipynbto Canvas. Do not rename, it associates your student number with the submission automatically.
Question 1
Recall the Lake Model of unemployment and employment. Summarizing, while in the labor market, workers are employed or unemployed, where
- \(\lambda\), the job finding rate for currently unemployed workers and \(\alpha\) is the dismissal rate for currently employed workers
- \(b\) is the entry rate into the labor force, \(d\) is the exit rate, and \(g = b - d\). New entrance into the labor force is assumed to be unemployed.
- \(E_t\) is the total number of employed workers, \(U_t\) is the total number of unemployed workers and \(N_t = E_t + U_t\) is the total number of workers in the labor force.
- The employment and unemployment rate are \(e_t \equiv E_t / N_t\) and \(u_t \equiv U_t / N_t\) respectively.
- Define \(X_t \equiv \left(\begin{matrix}U_t\\E_t\end{matrix}\right)\) and \(x_t \equiv \left(\begin{matrix}u_t\\e_t\end{matrix}\right)\).
With this, we constructed the equation for the evolution of the state vector \(X_{t+1}\) as
\[ X_{t+1} = \underbrace{\begin{bmatrix} (1-d)(1-\lambda) + b & (1-d)\alpha + b \\ (1-d)\lambda & (1-d)(1-\alpha) \end{bmatrix}}_{\equiv A} X_t \]
And
\[ x_{t+1} = \underbrace{\frac{1}{1 + g} A}_{\equiv \hat{A}} x_t \]
Finally, the Markov chain for an agent (before exit) is
\[ P = \begin{bmatrix} 1 - \lambda & \lambda \\ \alpha & 1 - \alpha \end{bmatrix} \]
In the lectures we had code for general simulations using a model and collection of parameters
# Reusable functions, do not modify
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
function lake_model(; lambda = 0.283, alpha = 0.013, b = 0.0124, d = 0.00822)
g = b - d
A = [(1 - lambda) * (1 - d)+b (1 - d) * alpha+b
(1 - d)*lambda (1 - d)*(1 - alpha)]
P = [(1 - lambda) lambda
alpha 1 - alpha]
A_hat = A ./ (1 + g)
x_0 = ones(size(A_hat, 1)) / size(A_hat, 1)
sol = fixedpoint(x -> A_hat * x, x_0)
converged(sol) || error("Failed to converge in $(sol.iterations) iter")
x_bar =sol.zero
return (; lambda, alpha, b, d, A, A_hat, x_bar, P)
endlake_model (generic function with 1 method)
Using the above code, we can solve for the dynamics of the stocks with
lm = lake_model()
N_0 = 150
e_0 = 0.92
u_0 = 1 - e_0
T = 50
U_0 = u_0 * N_0
E_0 = e_0 * N_0
X_0 = [U_0; E_0]
X_path = iterate_map(X -> lm.A * X, X_0, T - 1)
x1 = X_path[1, :]
x2 = X_path[2, :]
plt_unemp = plot(1:T, X_path[1, :]; color = :blue,
label = L"U_t", xlabel="t", title = "Unemployment")
plt_emp = plot(1:T, X_path[2, :]; color = :blue,
label = L"E_t", xlabel="t", title = "Employment")
plot(plt_unemp, plt_emp, layout = (1, 2), size = (1200, 400))Similarly, we can plot the evolution of the employment and unemployment rates after finding the steady state:
u_bar, e_bar = lm.x_bar
x_0 = [u_0; e_0]
x_path = iterate_map(x -> lm.A_hat * x, x_0, T - 1)
plt_unemp = plot(1:T, x_path[1, :];title = "Unemployment rate",
color = :blue, label = L"u_t")
hline!(plt_unemp, [u_bar], color = :red, linestyle = :dash, label = L"\pi^{*}_U")
plt_emp = plot(1:T, x_path[2, :]; title = "Employment rate", color = :blue, label = L"e_t")
hline!(plt_emp, [e_bar], color = :red, linestyle = :dash,label = L"\pi^{*}_E")
plot(plt_unemp, plt_emp, layout = (1, 2), size = (1200, 400))Part (a)
Repeating the above code, plot the dynamics of the unemployment and employment rates for the model with b = d = 0, but keeping all of the other parameters as given.
# edit your code here
lm = lake_model()
N_0 = 150
e_0 = 0.92
u_0 = 1 - e_0
T = 50
U_0 = u_0 * N_0
E_0 = e_0 * N_0
X_0 = [U_0; E_0]
X_path = iterate_map(X -> lm.A * X, X_0, T - 1)
x1 = X_path[1, :]
x2 = X_path[2, :]
plt_unemp = plot(1:T, X_path[1, :]; color = :blue,
label = L"U_t", xlabel="t", title = "Unemployment")
plt_emp = plot(1:T, X_path[2, :]; color = :blue,
label = L"E_t", xlabel="t", title = "Employment")
plot(plt_unemp, plt_emp, layout = (1, 2), size = (1200, 400))Interpret why this is different from the previous case (talk about transition dynamics as well as the steady-states)
Answer:
(double click to edit your answer)
Part (b)
The Markov chain for an individual starting in the employment state can be simulated using the markov chain already calculated in our previous code,
lm = lake_model(;lambda = 0.283, alpha = 0.013, b = 0.0, d = 0.0)
T = 1000
mc = MarkovChain(lm.P, [0; 1]) # 0=unemployed, 1=employed
s_path = simulate(mc, T; init = 2)
u_bar, e_bar = stationary_distributions(mc)[1]
# Note mapping in MarkovChain
s_bar_e = cumsum(s_path) ./ (1:T)
s_bar_u = 1 .- s_bar_e
s_bars = [s_bar_u s_bar_e]
plot(title = "Percent of time unemployed",
1:T, s_bars[:, 1], lw = 2,
label=L"\frac{1}{t}\sum_{s=0}^t \mathbb{1}\{X_s = U\}",
legend=:topright, size=(600, 400))
hline!([u_bar], linestyle = :dash,
label = L"\pi^{*}_U")Modify this same graph, but now start the agent in unemployed state,
# edit your code here
s_path = simulate(mc, T; init = 2)
u_bar, e_bar = stationary_distributions(mc)[1]
# Note mapping in MarkovChain
s_bar_e = cumsum(s_path) ./ (1:T)
s_bar_u = 1 .- s_bar_e
s_bars = [s_bar_u s_bar_e]
plot(title = "Percent of time unemployed",
1:T, s_bars[:, 1], lw = 2,
label=L"\frac{1}{t}\sum_{s=0}^t \mathbb{1}\{X_s = U\}",
legend=:topright, size=(600, 400))
hline!([u_bar], linestyle = :dash,
label = L"\pi^{*}_U")Interpret these graphs. In particular: (1) why are the different; (2) why does it converge; and (3) why does it converge to the same point?.
Answer:
(double click to edit your answer)