{ "metadata": { "name": "" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "
\n", "\n", "# *Numerical Methods for Economists: Lab Assignment The Solow (1956) Model*\n", "\n", "In this lab assignment you will analyze a version of the Solow model with a [constant elasticity of substituion (CES)](http://en.wikipedia.org/wiki/Constant_elasticity_of_substitution) production function and attempt to \"explain\" observed patterns in capital's share in the U.S. between 1950-2011.\n", "\n", "A CES production function looks as follows...\n", "\n", "\\begin{equation}\n", " Y(t) = \\bigg[\\alpha K(t)^{\\rho} + (1-\\alpha) (A(t)L(t))^{\\rho}\\bigg]^{\\frac{1}{\\rho}} \\tag{1.2}\n", "\\end{equation}\n", "\n", "where $0 < \\alpha < 1$ and $-\\infty < \\rho < 1$. The parameter $\\rho = \\frac{\\sigma - 1}{\\sigma}$ where $\\sigma$ is the elasticity of substitution between factors of production. The CES production technology is popular because it nests several interesing special cases. In particular, if factors of production are perfect substitutes (i.e., $\\sigma = +\\infty \\implies \\rho = 1$), then output is just a linear combination of the inputs.\n", "\n", "\\begin{equation}\n", " \\lim_{\\rho \\rightarrow 1} Y(t) = \\alpha K(t) + (1-\\alpha)A(t)L(t) \\tag{1.3}\n", "\\end{equation}\n", " \n", "On the other hand, if factors of production are perfect complements (i.e., $\\sigma = 0 \\implies \\rho = -\\infty$), then we recover the [Leontief production function](http://en.wikipedia.org/wiki/Leontief_production_function).\n", " \n", "\\begin{equation}\n", " \\lim_{\\rho \\rightarrow -\\infty} Y(t) = \\min\\left\\{\\alpha K(t), (1-\\alpha) A(t)L(t)\\right\\} \\tag{1.4}\n", "\\end{equation}\n", "\n", "Finally, if the elasticity of substitution is unitary (i.e., $\\sigma=1 \\implies \\rho=0$), then output is [Cobb-Douglas](http://en.wikipedia.org/wiki/Cobb%E2%80%93Douglas_production_function).\n", "\n", "\\begin{equation}\n", " \\lim_{\\rho \\rightarrow 0} Y(t) = K(t)^{\\alpha}(A(t)L(t))^{1-\\alpha} \\tag{1.5}\n", "\\end{equation}" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import numpy as np\n", "import pandas as pd\n", "from scipy import integrate, linalg, optimize\n", "import matplotlib as mpl\n", "import matplotlib.pyplot as plt\n", "\n", "# for the first few labs we will be working with models of growth\n", "import growth\n", "import pwt" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### (5 points) Part a) \n", "\n", "Show that the CES production function as defined by equation 1.2 exhibits constant returns to scale." ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### (10 points) Part b)\n", "Derive the intensive forms for both the general CES production function as defined by equation 1.2 and for its Cobb-Douglas special case defined by equation 1.5. Show that both of these intensive production functions are concave." ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### (5 points) Part c)\n", "\n", "Using your results from part b, complete the Python function below which defines output (per person/effective person) in terms of capital (per person/effective person) and model parameters." ] }, { "cell_type": "code", "collapsed": false, "input": [ "def ces_output(t, k, params):\n", " \"\"\"\n", " Intensive form for a CES production \n", " function.\n", "\n", " Arguments:\n", "\n", " t: (array-like) Time.\n", " k: (array-like) Capital (per person/effective person).\n", " params: (dict) Dictionary of parameter values.\n", " \n", " Returns:\n", "\n", " y: (array-like) Output (per person/ effective person)\n", "\n", " \"\"\"\n", " # extract params\n", " alpha = params['alpha']\n", " sigma = params['sigma']\n", " rho = # INSERT CODE HERE DEFINING RHO IN TERMS OF SIGMA!\n", " \n", " # nest Cobb-Douglas technology as special case\n", " if rho == 0:\n", " y = # INSERT CODE HERE!\n", " else:\n", " y = # INSERT CODE HERE!\n", " \n", " return y" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### (5 points) Part d)\n", "\n", "Using your results from part b, complete the Python function below which defines the marginal product of capital (per person/effective person) in terms of capital (per person/effective person) and model parameters." ] }, { "cell_type": "code", "collapsed": false, "input": [ "def marginal_product_capital(t, k, params):\n", " \"\"\"\n", " Marginal product of capital with CES production function.\n", "\n", " Arguments:\n", "\n", " t: (array-like) Time.\n", " k: (array-like) Capital (per person/effective person).\n", " params: (dict) Dictionary of parameter values.\n", " \n", " Returns:\n", "\n", " mpk: (array-like) Derivative of output with respect to capital, k.\n", "\n", " \"\"\"\n", " # extract params\n", " alpha = params['alpha']\n", " sigma = params['sigma']\n", " rho = # INSERT CODE HERE DEFINING RHO IN TERMS OF SIGMA!\n", " \n", " # nest Cobb-Douglas technology as special case\n", " if rho == 0:\n", " mpk = # INSERT CODE HERE!\n", " else:\n", " mpk = # INSERT CODE HERE!\n", " \n", " return mpk" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### (5 points) Part e)\n", "\n", "Derive the equation of motion for capital per effective worker when the general CES production function defined by equation 1.2 and for the Cobb-Douglas special case defined by equation 1.5." ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### (5 points) Part f)\n", "\n", "Using your results from parts d) and e) and the Python function defining the equation of motion for capital (per person/effective person) complete the Python function which defines the Jacobian for the Solow model." ] }, { "cell_type": "code", "collapsed": false, "input": [ "def equation_of_motion_capital(t, k, params):\n", " \"\"\"\n", " Equation of motion for capital (per person/effective person).\n", "\n", " Arguments:\n", "\n", " t: (array-like) Time.\n", " k: (array-like) Capital (per person/effective person).\n", " params: (dict) Dictionary of parameter values.\n", " \n", " Returns:\n", "\n", " k_dot: (array-like) Time-derivative of capital (per person/effective \n", " person).\n", "\n", " \"\"\"\n", " # extract params\n", " s = params['s']\n", " n = params['n']\n", " g = params['g']\n", " delta = params['delta']\n", " \n", " y = ces_output(t, k, params)\n", " \n", " k_dot = s * y - (n + g + delta) * k\n", " \n", " return k_dot" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "def solow_jacobian(t, k, params):\n", " \"\"\"\n", " The Jacobian of the Solow model.\n", " \n", " Arguments:\n", "\n", " t: (array-like) Time.\n", " k: (array-like) Capital (per person/effective person).\n", " params: (dict) Dictionary of parameter values.\n", " \n", " Returns:\n", "\n", " jac: (array-like) Value of the derivative of the equation of \n", " motion for capital (per worker/effective worker) with \n", " respect to k.\n", "\n", " \"\"\"\n", " # extract params\n", " s = params['s']\n", " n = params['n']\n", " g = params['g']\n", " delta = params['delta']\n", "\n", " mpk = #INSERT YOUR CODE HERE\n", " \n", " k_dot = s * mpk - (n + g + delta)\n", " \n", " return k_dot" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### (5 points) Part g)\n", "\n", "In the cell below, create a Python dictionary called `default_params` using the following values: $\\alpha$ = 0.33, $\\delta$ = 0.04, $\\sigma$ = 1.0, $g$ = 0.02, $n$ = 0.01, $s$ = 0.15, $L(0)$=1.0, $A(0)$=1.0." ] }, { "cell_type": "code", "collapsed": false, "input": [ "# INSERT CODE HERE!" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### (5 points) Part h)\n", "In the cell below, create instance of the `SolowModel` class called `model` using the results from parts c), d), f) and g)." ] }, { "cell_type": "code", "collapsed": false, "input": [ "# INSERT CODE HERE!" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### (10 points) Part i)\n", "\n", "Derive an analytic expression for the steady state value of capital (per person/effective person) using your result from part e) and use your result to complete the Python function in the cell below defining the analytic steady state value for $k$ as a function of model parameters." ] }, { "cell_type": "code", "collapsed": false, "input": [ "def analytic_k_star(params): \n", " \"\"\"Steady-state level of capital (per person/effective person).\"\"\"\n", " # extract params\n", " s = params['s']\n", " n = params['n']\n", " g = params['g']\n", " alpha = params['alpha']\n", " delta = params['delta']\n", " sigma = params['sigma']\n", " rho = # INSERT CODE HERE DEFINING RHO IN TERMS OF SIGMA!\n", " \n", " # nest Cobb-Douglas technology as special case\n", " if rho == 0:\n", " k_star = # INSERT CODE HERE!\n", " else:\n", " k_star = # INSERT CODE HERE!\n", " \n", " return k_star" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### (5 points) Part j)\n", "\n", "Using the code from the lab session as a guide, create a Python dictionary called `solow_steady_state_funcs` containing your result from part i) and add it to the model." ] }, { "cell_type": "code", "collapsed": false, "input": [ "# INSERT YOUR CODE HERE!!" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Execute the code in the cell below to calibrate the model for the U.S. using data from the Penn World Tables." ] }, { "cell_type": "code", "collapsed": false, "input": [ "# calibrate the model!\n", "growth.calibrate_ces(model, 'USA', x0=[0.5, 0.5], bounds=None)\n", "\n", "# display the parameters...\n", "model.params" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### (5 points) Part k)\n", "\n", "Using the code examples from the lab as a guide, generate a plot of the Solow diagram demonstrating how the output, actual investment, and breakeven investment curves shift as a result of a 50% *increase* in $\\sigma$ (i.e., the elasticity of substitution between capital and effective labor). Explain why, and in which direction, each curve shifts. Discuss the impact on the steady state levels of capital, output, and consumption per effective person." ] }, { "cell_type": "code", "collapsed": false, "input": [ "# INSERT YOUR CODE HERE!" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### (5 points) Part l)\n", "\n", "Using code from the lab as a guide, generate impulse response functions (IRFs) in for the Solow model following a 50% *increase* in the elasticity of substitution between capital and effective labor, $\\sigma$. Discuss the resulting IRFS. " ] }, { "cell_type": "code", "collapsed": false, "input": [ "# INSERT YOUR CODE HERE!" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### (5 points) Part m:\n", "\n", "Using your results from part b), derive an expression for the elasticity of output per effective person with respect to capital per effective person, $\\alpha_k$, as a function of capital per effective person, $k$, and model parameters." ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### (5 points) Part n)\n", "\n", "Differentiate your result from part m) with respect to capital per effective person, $k$, and discuss under what conditions the derivative will be positive, negative, or zero." ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### (5 points) Part o)\n", "\n", "Use the fact that $\\frac{\\partial k}{\\partial s} > 0$ and the result from part n) to relate the sign of $\\frac{\\partial \\alpha_k(k)}{\\partial s}$ to the elasticity of substitution between capital and effective labor." ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### (15 points) Part p)\n", "\n", "The code in the cell below regresses $\\alpha_k(k)$ on the investment's share of GDP for the U.S., $s$ during two different time periods: 1950-1970 and 1970-2011. Can you \"explain\" these pattern using your result from part o)?" ] }, { "cell_type": "code", "collapsed": false, "input": [ "fig = plt.figure(figsize=(8,6))\n", "ax1 = fig.add_subplot(121)\n", "ax2 = fig.add_subplot(122)\n", "\n", "# capital's share for US (pre-1970)\n", "y = 1 - model.data.labsh.loc[:1970]\n", "\n", "# savings rate for US (pre-1970)\n", "x = model.data.csh_i.loc[:1970]\n", "\n", "# regress capital's share on savings rate \n", "res1 = pd.ols(y=y, x=x)\n", "\n", "ax1.scatter(x, y)\n", "ax1.set_xlabel('s', family='serif', fontsize=15)\n", "ax1.set_ylabel(r'$\\alpha_k(k)$', fontsize=15, family='serif', rotation='horizontal')\n", "ax1.set_title('U.S. pre-1970', family='serif', fontsize=15)\n", "\n", "# plot regression line pre-1970\n", "grid = np.linspace(0.15, 0.25, 100)\n", "ax1.plot(grid, res1.beta[1] + res1.beta[0] * grid, 'r')\n", "\n", "# capital's share for US (post-1970)\n", "y = 1 - model.data.labsh.loc[1970:]\n", "\n", "# savings rate for US (post-1970)\n", "x = model.data.csh_i.loc[1970:]\n", "\n", "# regress capital's share on savings rate post-1970\n", "res2 = pd.ols(y=y, x=x)\n", "\n", "ax2.scatter(x, y)\n", "ax2.set_xlabel('s', family='serif', fontsize=15)\n", "ax2.set_title('U.S. post-1970', family='serif', fontsize=15)\n", "\n", "# plot regression line post-1970\n", "grid = np.linspace(0.15, 0.25, 100)\n", "ax2.plot(grid, res2.beta[1] + res2.beta[0] * grid, 'r')\n", "\n", "fig.suptitle(\"Patterns in capital's share for the U.S?\", x=0.5, y=1.05, \n", " fontsize=20, family='serif')\n", "fig.tight_layout()\n", "plt.show()" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "# summary of the regression results for 1950-1970\n", "print res1" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "# summary of the regression results for 1970-2011\n", "print res2" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] } ], "metadata": {} } ] }