<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Homework 2 (DUE
Step1:  Question 2
For each of the following first-difference processes, compute the values of $y$ from $t=0$ through $t = 12$. For each, assume that $y_0 = 0$. 
$y_t = 1 + 0.5y_{t-1}$
$y_t = 0.5y_{t-1}$
$y_t = -1 + 0.5y_{t-1}$
Plot the the simulated values for each process on the same axes and be sure to include a legend. Set the $y$-axis limits to $[-3,3]$.
Step2:  Question 3
Download a file called Econ129_US_Production_A_Data.csv from the link "Production data for the US" under the "Data" section on the course website. The file contains annual production data for the US economy including ouput, consumption, investment, and labor hours, among others. The capital stock of the US is only given for 1948. Import the data into a Pandas DataFrame and do the following
Step3:  Question 4
Step4:  Question 5
Recall the Solow growth model with exogenous growth in labor and TFP
<ASSISTANT_TASK:>
Python Code:
# Question 1
Explanation: Homework 2 (DUE: Thursday February 16)
Instructions: Complete the instructions in this notebook. You may work together with other students in the class and you may take full advantage of any internet resources available. You must provide thorough comments in your code so that it's clear that you understand what your code is doing and so that your code is readable.
Submit the assignment by saving your notebook as an html file (File -> Download as -> HTML) and uploading it to the appropriate Dropbox folder on EEE.
Question 1
For each of the following first-difference processes, compute the values of $y$ from $t=0$ through $t = 20$. For each, assume that $y_0 = 0$, $w_1 = 1$, and $w_2 = w_3 = \cdots w_T = 0$. 
$y_t = 0.99y_{t-1} + w_t$
$y_t = y_{t-1} + w_t$
$y_t = 1.01y_{t-1} + w_t$
Plot the the simulated values for each process on the same axes and be sure to include a legend.
End of explanation
# Question 2
Explanation: Question 2
For each of the following first-difference processes, compute the values of $y$ from $t=0$ through $t = 12$. For each, assume that $y_0 = 0$. 
$y_t = 1 + 0.5y_{t-1}$
$y_t = 0.5y_{t-1}$
$y_t = -1 + 0.5y_{t-1}$
Plot the the simulated values for each process on the same axes and be sure to include a legend. Set the $y$-axis limits to $[-3,3]$.
End of explanation
# Question 3.1
# Question 3.2
# Question 3.3
Explanation: Question 3
Download a file called Econ129_US_Production_A_Data.csv from the link "Production data for the US" under the "Data" section on the course website. The file contains annual production data for the US economy including ouput, consumption, investment, and labor hours, among others. The capital stock of the US is only given for 1948. Import the data into a Pandas DataFrame and do the following:
Suppose that the depreciation rate for the US is $\delta = 0.0375$. Use the capital accumulation equation $K_{t+1} = I_t + (1-\delta)K_t$ to fill in the missing values for the capital column. Construct a plot of the computed capital stock.
Add columns to your DataFrame equal to capital per worker and output per worker by dividing the capital and output columns by the labor column. Print the first five rows of the DataFrame.
Print the average annual growth rates of capital per worker and output per worker for the US.
Recall that the average annnual growth rate of a quantity $y$ from date $0$ to date $T$ is:
\begin{align}
g & = \left(\frac{y_T}{y_0}\right)^{\frac{1}{T}}-1
\end{align}
End of explanation
# Initialize parameters for the simulation (A, s, T, delta, alpha, g, n, K0, A0, L0)
# Initialize a variable called tfp as a (T+1)x1 array of zeros and set first value to A0
# Compute all subsequent tfp values by iterating over t from 0 through T
    
    
# Plot the simulated tfp series
# Initialize a variable called labor as a (T+1)x1 array of zeros and set first value to L0
# Compute all subsequent labor values by iterating over t from 0 through T
    
    
# Plot the simulated labor series
# Initialize a variable called capital as a (T+1)x1 array of zeros and set first value to K0
# Compute all subsequent capital values by iterating over t from 0 through T
    
# Plot the simulated capital series
# Store the simulated capital, labor, and tfp data in a pandas DataFrame called data
# Print the first 5 frows of the DataFrame
# Create columns in the DataFrame to store computed values of the other endogenous variables: Y, C, and I
# Print the first five rows of the DataFrame
# 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 the DataFrame
# Create a 2x2 grid of plots of capital, output, consumption, and investment
# Create a 2x2 grid of plots of capital per worker, output per worker, consumption per worker, and investment per worker
Explanation: Question 4: The Solow model with exogenous population and TFP growth
Suppose that the aggregate production function is given by:
\begin{align}
Y_t & = A_tK_t^{\alpha} L_t^{1-\alpha}, \tag{1}
\end{align}
where $Y_t$ denotes output, $K_t$ denotes the capital stock, $L_t$ denotes the labor supply, and $A_t$ denotes total factor productivity $TFP$. $\alpha$ is a constant.
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{2}
\end{align}
Likewise, TFP grows at an exogenously determined rate $g$:
\begin{align}
A_{t+1} & = (1+g) A_t. \tag{3}
\end{align}
The rest of the economy is characterized by the same equations as before:
\begin{align}
C_t & = (1-s)Y_t \tag{4}\
Y_t & = C_t + I_t \tag{5}\
K_{t+1} & = I_t + ( 1- \delta)K_t. \tag{6}\
\end{align}
Equation (4) is the consumption function where $s$ denotes the exogenously given saving rate. Equation (5) is the aggregate market clearing condition. Finally, Equation (6) is the capital evolution equation specifying that capital in year $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) and (4) through (6) to eliminate $C_t$, $I_t$, and $Y_t$ and obtain a recurrence relation specifying $K_{t+1}$ as a funtion of $K_t$, $A_t$, and $L_t$:
\begin{align}
K_{t+1} & =  sA_tK_t^{\alpha}L_t^{1-\alpha} + ( 1- \delta)K_t \tag{7}
\end{align}
Given an initial values for capital and labor, Equations (2), (3), and (7) 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 (1), (4), (5), and (6).
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\
g & = 0.015 \
n & = 0.01
\end{align}
Furthermore, suppose that the initial values of capital and labor are:
\begin{align}
K_0 & = 2\
A_0 & = 1\
L_0 & = 1
\end{align}
End of explanation
# Question 5.1
# Question 5.2
Explanation: Question 5
Recall the Solow growth model with exogenous growth in labor and TFP:
\begin{align}
Y_t & = A_tK_t^{\alpha} L_t^{1-\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}\
L_{t+1} & = (1+n) L_t \tag{5} \
A_{t+1} & = (1+g) A_t. \tag{6}
\end{align}
Suppose that two countries called Westeros and Essos are identical except that TFP in Westeros grows faster than in Essos. Specifically:
\begin{align}
g_{Westeros} & = 0.03\
g_{Essos} & = 0.01
\end{align}
Otherwise, the parameters for each economy are the same including the initial values of capital, labor, and TFP:
\begin{align}
\alpha & = 0.35\
s & = 0.15\
\delta & = 0.1\
n & = 0.01\
K_0 & = 20\
A_0 & = 10\
L_0 & = 1
\end{align}
Do the following:
Find the date (value for $t$) at which output per worker in Westeros becomes at least twice as large as output per worker in Essos. Print the value for t and the values of ouput per worker for each country.
On a single set of axes, plot simulated values of output per worker for each country for t = $1, 2, \ldots 100$. 
Hint: Copy into this notebook the function that simulates the Solow model with exogenous labor growth from the end of the Notebook from Class 9. Modify the function to fit this problem.
End of explanation
<END_TASK>