Lake Model Solutions

Excercise 1

We begin by initializing the variables and import the necessary modules


In [7]:
%matplotlib inline

import numpy as np
import matplotlib.pyplot as plt
from quantecon.models import LakeModel

alpha = 0.012
lamb = 0.2486
b = 0.001808
d = 0.0008333
g = b-d
N0 = 100.
e0 = 0.92
u0 = 1-e0
T = 50

Now construct the class containing the initial conditions of the problem


In [8]:
LM0 = LakeModel(lamb,alpha,b,d)
x0 = LM0.find_steady_state()# initial conditions

print("Initial Steady State: %s" % x0)


Initial Steady State: [ 0.94737184  0.05262816]

New legislation changes $\lambda$ to $0.2$


In [9]:
LM1 = LakeModel(0.2,alpha,b,d)

In [10]:
xbar = LM1.find_steady_state() # new steady state
X_path = np.vstack(LM1.simulate_stock_path(x0*N0,T)) # simulate stocks
x_path = np.vstack(LM1.simulate_rate_path(x0,T)) # simulate rates
print("New Steady State: %s" % xbar)


New Steady State: [ 0.93540871  0.06459129]

Now plot stocks


In [11]:
plt.figure(figsize=[10,9])
plt.subplot(3,1,1)
plt.plot(X_path[:,0])
plt.title(r'Employment')
plt.subplot(3,1,2)
plt.plot(X_path[:,1])
plt.title(r'Unemployment')
plt.subplot(3,1,3)
plt.plot(X_path.sum(1))
plt.title(r'Labor Force')


Out[11]:
<matplotlib.text.Text at 0x7f444c3ec048>

And how the rates evolve:


In [12]:
plt.figure(figsize=[10,6])
plt.subplot(2,1,1)
plt.plot(x_path[:,0])
plt.hlines(xbar[0],0,T,'r','--')
plt.title(r'Employment Rate')
plt.subplot(2,1,2)
plt.plot(x_path[:,1])
plt.hlines(xbar[1],0,T,'r','--')
plt.title(r'Unemployment Rate')


Out[12]:
<matplotlib.text.Text at 0x7f444c3503c8>

We see that it takes 20 periods for the economy to converge to it's new steady state levels

Exercise 2

This next exercise has the economy expriencing a boom in entrances to the labor market and then later returning to the original levels. For 20 periods the economy has a new entry rate into the labor market


In [13]:
bhat = 0.003
T_hat = 20
LM1 = LakeModel(lamb,alpha,bhat,d)

We simulate for 20 periods at the new parameters


In [14]:
X_path1 = np.vstack(LM1.simulate_stock_path(x0*N0,T_hat)) # simulate stocks
x_path1 = np.vstack(LM1.simulate_rate_path(x0,T_hat)) # simulate rates

Now using the state after 20 periods for the new initial conditions we simulate for the additional 30 periods


In [15]:
X_path2 = np.vstack(LM0.simulate_stock_path(X_path1[-1,:2],T-T_hat+1)) # simulate stocks
x_path2 = np.vstack(LM0.simulate_rate_path(x_path1[-1,:2],T-T_hat+1)) # simulate rates

Finally we combine these two paths and plot


In [16]:
x_path = np.vstack([x_path1,x_path2[1:]]) # note [1:] to avoid doubling period 20
X_path = np.vstack([X_path1,X_path2[1:]]) # note [1:] to avoid doubling period 20

In [17]:
plt.figure(figsize=[10,9])
plt.subplot(3,1,1)
plt.plot(X_path[:,0])
plt.title(r'Employment')
plt.subplot(3,1,2)
plt.plot(X_path[:,1])
plt.title(r'Unemployment')
plt.subplot(3,1,3)
plt.plot(X_path.sum(1))
plt.title(r'Labor Force')


Out[17]:
<matplotlib.text.Text at 0x7f444c1d00b8>

And the rates:


In [18]:
plt.figure(figsize=[10,6])
plt.subplot(2,1,1)
plt.plot(x_path[:,0])
plt.hlines(x0[0],0,T,'r','--')
plt.title(r'Employment Rate')
plt.subplot(2,1,2)
plt.plot(x_path[:,1])
plt.hlines(x0[1],0,T,'r','--')
plt.title(r'Unemployment Rate')


Out[18]:
<matplotlib.text.Text at 0x7f444c0bdc88>

In [ ]: