In [ ]:
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
%matplotlib inline

Class 9: The Solow growth model

The Solow growth model is at the core of modern theories of growth and business cycles. The Solow model is a model of exogenous growth: long-run growth arises in the model as a consequence of exogenous growth in the labor supply and total factor productivity. The Solow model, like many other macroeconomic models, is a time series model.

The Solow model without exogenous growth

For the moment, let's disregard population and total factor productivity growth and assume that equilibrium in a closed economy is described by the following four equations:

\begin{align} Y_t & = A K_t^{\alpha} \tag{1}\\ C_t & = (1-s)Y_t \tag{2}\\ Y_t & = C_t + I_t \tag{3}\\ K_{t+1} & = I_t + ( 1- \delta)K_t \tag{4}\\ \end{align}

Equation (1) is the production function. Equation (2) is the consumption function where $s$ denotes the exogenously given saving rate. Equation (3) is the aggregate market clearing condition. Finally, Equation (4) is the capital evolution equation specifying that capital in yeat $t+1$ is the sum of newly created capital $I_t$ and the capital stock from year $t$ that has not depreciated $(1-\delta)K_t$.

Combine Equations (1) through (4) to eliminate $C_t$, $I_t$, and $Y_t$ and obtain a single-variable recurrence relation for $K_{t+1}$: \begin{align} K_{t+1} & = sAK_t^{\alpha} + ( 1- \delta)K_t \tag{5} \end{align}

Given an initial value for capital $K_0 >0$, iterate on Equation (5) to compute the value of the capital stock at some future date $T$. Furthermore, the values of consumption, output, and investment at date $T$ can also be computed using Equations (1) through (3).

Simulation

Simulate the Solow growth model for $t=0\ldots 100$. For the simulation, assume the following values of the parameters:

\begin{align} A & = 10\\ \alpha & = 0.35\\ s & = 0.15\\ \delta & = 0.1 \end{align}

Furthermore, suppose that the initial value of capital is:

\begin{align} K_0 & = 20 \end{align}

In [ ]:
# Initialize parameters for the simulation (A, s, T, delta, alpha, K0)


# Initialize a variable called capital as a (T+1)x1 array of zeros and set first value to K0


# Compute all capital values by iterating over t from 0 through T
    

# Print the value of capital at dates 0 and T

In [ ]:
# Store the simulated capital data in a pandas DataFrame called data


# Print the first five rows of the DataFrame

In [ ]:
# Create columns in the DataFrame to store computed values of the other endogenous variables


# Print the first row of the DataFrame

In [ ]:
# Print the last row of the DataFrame

In [ ]:
# Create a 2x2 grid of plots of capital, output, consumption, and investment
fig = plt.figure(figsize=(12,8))
ax = fig.add_subplot(2,2,1)
ax.plot(data['capital'],lw=3)
ax.grid()
ax.set_title('Capital')

The Solow model with exogenous population growth

Now, let's suppose that production is a function of the supply of labor $L_t$:

\begin{align} Y_t & = AK_t^{\alpha} L_t^{1-\alpha}\tag{6} \end{align}

The supply of labor grows at an exogenously determined rate $n$ and so it's value is determined recursively by a first-order difference equation:

\begin{align} L_{t+1} & = (1+n) L_t \tag{7} \end{align}

The rest of the economy is characterized by the same equations as before:

\begin{align} C_t & = (1-s)Y_t \tag{8}\\ Y_t & = C_t + I_t \tag{9}\\ K_{t+1} & = I_t + ( 1- \delta)K_t \tag{10}\\ \end{align}

Combine Equations (6), (8), (9), and (10) to eliminate $C_t$, $I_t$, and $Y_t$ and obtain a recurrence relation specifying $K_{t+1}$ as a funtion of $K_t$ and $L_t$: \begin{align} K_{t+1} & = sAK_t^{\alpha}L_t^{1-\alpha} + ( 1- \delta)K_t \tag{11} \end{align}

Given an initial values for capital and labor, Equations (7) and (11) can be iterated on to compute the values of the capital stock and labor supply at some future date $T$. Furthermore, the values of consumption, output, and investment at date $T$ can also be computed using Equations (6), (8), (9), and (10).

Simulation

Simulate the Solow growth model with exogenous labor growth for $t=0\ldots 100$. For the simulation, assume the following values of the parameters:

\begin{align} A & = 10\\ \alpha & = 0.35\\ s & = 0.15\\ \delta & = 0.1\\ n & = 0.01 \end{align}

Furthermore, suppose that the initial values of capital and labor are:

\begin{align} K_0 & = 20\\ L_0 & = 1 \end{align}

In [ ]:
# Initialize parameters for the simulation (A, s, T, delta, alpha, n, K0, L0)



# Initialize a variable called labor as a (T+1)x1 array of zeros and set first value to L0


# Compute all labor  values by iterating over t from 0 through T
    
    
# Plot the simulated labor series

In [ ]:
# Initialize a variable called capital as a (T+1)x1 array of zeros and set first value to K0


# Compute all capital values by iterating over t from 0 through T

    

# Plot the simulated capital series

In [ ]:
# Store the simulated capital data in a pandas DataFrame called data_labor


# Print the first five rows of the data_labor

In [ ]:
# Create columns in the DataFrame to store computed values of the other endogenous variables

# Print the first five rows of data_labor

In [ ]:
# Create columns in the DataFrame to store capital per worker, output per worker, consumption per worker, and investment per worker


# Print the first five rows of data_labor

In [ ]:
# Create a 2x2 grid of plots of capital, output, consumption, and investment

In [ ]:
# Create a 2x2 grid of plots of capital per worker, outputper worker, consumption per worker, and investment per worker

An alternative approach

Suppose that we wanted to simulate the Solow model with different parameter values so that we could compare the simulations. Since we'd be doing the same basic steps multiple times using different numbers, it would make sense to define a function so that we could avoid repetition.

The code below defines a function called solow_example() that simulates the Solow model with exogenous labor growth. solow_example() takes as arguments the parameters of the Solow model $A$, $\alpha$, $\delta$, $s$, and $n$; the initial values $K_0$ and $L_0$; and the number of simulation periods $T$. solow_example() returns a Pandas DataFrame with computed values for aggregate and per worker quantities.


In [ ]:
def solow_example(A,alpha,delta,s,n,K0,L0,T):
    '''Returns DataFrame with simulated values for a Solow model with labor growth and constant TFP'''
    
    # Initialize a variable called capital as a (T+1)x1 array of zeros and set first value to k0
    capital = np.zeros(T+1)
    capital[0] = K0
    
    # Initialize a variable called labor as a (T+1)x1 array of zeros and set first value to l0
    labor = np.zeros(T+1)
    labor[0] = L0


    # Compute all capital and labor values by iterating over t from 0 through T
    for t in np.arange(T):
        labor[t+1] = (1+n)*labor[t]
        capital[t+1] = s*A*capital[t]**alpha*labor[t]**(1-alpha) + (1-delta)*capital[t]
    
    # Store the simulated capital df in a pandas DataFrame called data
    df = pd.DataFrame({'capital':capital,'labor':labor})
    
    # Create columns in the DataFrame to store computed values of the other endogenous variables
    df['output'] = df['capital']**alpha*df['labor']**(1-alpha)
    df['consumption'] = (1-s)*df['output']
    df['investment'] = df['output'] - df['consumption']
    
    # Create columns in the DataFrame to store capital per worker, output per worker, consumption per worker, and investment per worker
    df['capital_pw'] = df['capital']/df['labor']
    df['output_pw'] = df['output']/df['labor']
    df['consumption_pw'] = df['consumption']/df['labor']
    df['investment_pw'] = df['investment']/df['labor']
    
    return df

With solow_example() defined, we can redo the previous exercise quickly:


In [ ]:
# Create the DataFrame with simulated values
df = solow_example(A=10,alpha=0.35,delta=0.1,s=0.15,n=0.01,K0=20,L0=1,T=100)

# Create a 2x2 grid of plots of the capital per worker, outputper worker, consumption per worker, and investment per worker
fig = plt.figure(figsize=(12,8))
ax = fig.add_subplot(2,2,1)
ax.plot(df['capital_pw'],lw=3)
ax.grid()
ax.set_title('Capital per worker')

ax = fig.add_subplot(2,2,2)
ax.plot(df['output_pw'],lw=3)
ax.grid()
ax.set_title('Output per worker')

ax = fig.add_subplot(2,2,3)
ax.plot(df['consumption_pw'],lw=3)
ax.grid()
ax.set_title('Consumption per worker')

ax = fig.add_subplot(2,2,4)
ax.plot(df['investment_pw'],lw=3)
ax.grid()
ax.set_title('Investment per worker')

solow_example() can be used to perform multiple simulations. For example, suppose we want to see the effect of having two different initial values of capital: $k_0 = 20$ and $k_0'=10$.


In [ ]:
df1 = solow_example(A=10,alpha=0.35,delta=0.1,s=0.15,n=0.01,K0=20,L0=1,T=100)
df2 = solow_example(A=10,alpha=0.35,delta=0.1,s=0.15,n=0.01,K0=10,L0=1,T=100)

In [ ]:
# Create a 2x2 grid of plots of the capital per worker, outputper worker, consumption per worker, and investment per worker
fig = plt.figure(figsize=(12,8))
ax = fig.add_subplot(2,2,1)
ax.plot(df1['capital_pw'],lw=3)
ax.plot(df2['capital_pw'],lw=3)
ax.grid()
ax.set_title('Capital per worker')

ax = fig.add_subplot(2,2,2)
ax.plot(df1['output_pw'],lw=3)
ax.plot(df2['output_pw'],lw=3)
ax.grid()
ax.set_title('Output per worker')

ax = fig.add_subplot(2,2,3)
ax.plot(df1['consumption_pw'],lw=3)
ax.plot(df2['consumption_pw'],lw=3)
ax.grid()
ax.set_title('Consumption per worker')

ax = fig.add_subplot(2,2,4)
ax.plot(df1['investment_pw'],lw=3,label='$k_0=20$')
ax.plot(df2['investment_pw'],lw=3,label='$k_0=10$')
ax.grid()
ax.set_title('Investment per worker')
ax.legend(loc='lower right')