{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "#### Long-Run World Population Estimates\n", "\n", "### Python Programming and Data Setup" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/Users/delong/anaconda3/lib/python3.6/site-packages/sklearn/cross_validation.py:44: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the refactored classes and functions are moved. Also note that the interface of the new CV iterators are different from that of this module. This module will be removed in 0.20.\n", " \"This module will be removed in 0.20.\", DeprecationWarning)\n", "/Users/delong/anaconda3/lib/python3.6/site-packages/statsmodels/compat/pandas.py:56: FutureWarning: The pandas.core.datetools module is deprecated and will be removed in a future version. Please use the pandas.tseries module instead.\n", " from pandas.core import datetools\n" ] } ], "source": [ "# import libraries...\n", "\n", "import pandas as pd\n", "import numpy as np\n", "import math\n", "import time\n", "\n", "import copy\n", "import itertools\n", "from itertools import chain, combinations\n", "from linearmodels.iv import IV2SLS\n", "import matplotlib.pyplot as plt\n", "import scipy.stats as scipystats\n", "import seaborn as sns\n", "from sklearn.cross_validation import train_test_split\n", "import statsmodels.api as sm\n", "import statsmodels.formula.api as smf\n", "from statsmodels.graphics.regressionplots import *\n", "from statsmodels.iolib.summary2 import summary_col\n", "import statsmodels.stats as stats \n", "import statsmodels.stats.stattools as stools\n", "\n", "%matplotlib inline\n", "\n", "plt.style.use('seaborn')" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " Year Human Population (Millions) Human Population Growth Rate \\\n", "year_index \n", "-73000 -73000 0.01 NaN \n", "-63000 -63000 0.10 0.000230 \n", "-53000 -53000 0.13 0.000030 \n", "-43000 -43000 0.18 0.000030 \n", "-33000 -33000 0.39 0.000075 \n", "-23000 -23000 0.82 0.000075 \n", "-13000 -13000 1.73 0.000075 \n", "-8000 -8000 2.50 0.000074 \n", "-7000 -7000 4.18 0.000515 \n", "-6000 -6000 7.00 0.000515 \n", "-5000 -5000 9.02 0.000254 \n", "-4000 -4000 11.63 0.000254 \n", "-3000 -3000 15.00 0.000254 \n", "-2000 -2000 27.00 0.000588 \n", "-1750 -1750 32.01 0.000681 \n", "-1500 -1500 37.95 0.000681 \n", "-1250 -1250 45.00 0.000681 \n", "-1000 -1000 50.00 0.000421 \n", "-900 -900 57.43 0.001386 \n", "-800 -800 65.97 0.001386 \n", "-700 -700 75.78 0.001386 \n", "-600 -600 87.04 0.001386 \n", "-500 -500 100.00 0.001387 \n", "-400 -400 114.48 0.001352 \n", "-300 -300 131.05 0.001352 \n", "-200 -200 150.00 0.001351 \n", "-100 -100 159.67 0.000625 \n", " 0 0 170.00 0.000627 \n", " 100 100 179.72 0.000556 \n", " 200 200 190.00 0.000556 \n", "... ... ... ... \n", " 1000 1000 265.00 0.000991 \n", " 1100 1100 320.00 0.001886 \n", " 1200 1200 360.00 0.001178 \n", " 1300 1300 360.00 0.000000 \n", " 1350 1350 320.00 -0.002356 \n", " 1400 1400 350.00 0.001792 \n", " 1450 1450 380.00 0.001645 \n", " 1500 1500 425.00 0.002238 \n", " 1550 1550 400.00 -0.001212 \n", " 1600 1600 545.00 0.006186 \n", " 1650 1650 545.00 0.000000 \n", " 1700 1700 610.00 0.002253 \n", " 1725 1725 660.00 0.003151 \n", " 1750 1750 720.00 0.003480 \n", " 1775 1775 800.00 0.004214 \n", " 1800 1800 900.00 0.004711 \n", " 1825 1825 1025.00 0.005202 \n", " 1850 1850 1200.00 0.006305 \n", " 1875 1875 1300.00 0.003202 \n", " 1900 1900 1625.00 0.008926 \n", " 1920 1920 1810.00 0.005391 \n", " 1940 1940 2210.00 0.009983 \n", " 1950 1950 2520.00 0.013127 \n", " 1960 1960 3020.00 0.018100 \n", " 1970 1970 3700.00 0.020308 \n", " 1980 1980 4450.00 0.018457 \n", " 1990 1990 5300.00 0.017480 \n", " 2000 2000 6200.00 0.015684 \n", " 2010 2010 7000.00 0.012136 \n", " 2020 2020 7700.00 0.009531 \n", "\n", " Population Interpolated? Average Real Income Per Capita \\\n", "year_index \n", "-73000 0 NaN \n", "-63000 0 1200.0 \n", "-53000 1 1200.0 \n", "-43000 1 1200.0 \n", "-33000 1 1200.0 \n", "-23000 1 1200.0 \n", "-13000 1 1200.0 \n", "-8000 0 1400.0 \n", "-7000 1 1200.0 \n", "-6000 0 900.0 \n", "-5000 1 900.0 \n", "-4000 1 900.0 \n", "-3000 0 900.0 \n", "-2000 0 900.0 \n", "-1750 1 900.0 \n", "-1500 1 900.0 \n", "-1250 0 900.0 \n", "-1000 0 900.0 \n", "-900 1 900.0 \n", "-800 1 900.0 \n", "-700 1 900.0 \n", "-600 1 900.0 \n", "-500 0 900.0 \n", "-400 1 900.0 \n", "-300 1 900.0 \n", "-200 0 900.0 \n", "-100 1 900.0 \n", " 0 0 900.0 \n", " 100 1 900.0 \n", " 200 0 900.0 \n", "... ... ... \n", " 1000 0 900.0 \n", " 1100 0 900.0 \n", " 1200 0 900.0 \n", " 1300 0 900.0 \n", " 1350 0 900.0 \n", " 1400 0 900.0 \n", " 1450 0 900.0 \n", " 1500 0 900.0 \n", " 1550 0 900.0 \n", " 1600 0 900.0 \n", " 1650 0 925.0 \n", " 1700 0 954.0 \n", " 1725 0 969.0 \n", " 1750 0 985.0 \n", " 1775 0 1000.0 \n", " 1800 0 1068.0 \n", " 1825 0 1140.0 \n", " 1850 0 1218.0 \n", " 1875 0 1300.0 \n", " 1900 0 1902.0 \n", " 1920 0 2578.0 \n", " 1940 0 3494.0 \n", " 1950 0 4068.0 \n", " 1960 0 4737.0 \n", " 1970 0 5515.0 \n", " 1980 0 6421.0 \n", " 1990 0 7476.0 \n", " 2000 0 8705.0 \n", " 2010 0 10135.0 \n", " 2020 0 11800.0 \n", "\n", " Real Income Growth Rate Income Interpolated? \n", "year_index \n", "-73000 NaN 0 \n", "-63000 0.000000 1 \n", "-53000 0.000000 1 \n", "-43000 0.000000 1 \n", "-33000 0.000000 1 \n", "-23000 0.000000 1 \n", "-13000 0.000000 0 \n", "-8000 0.000031 0 \n", "-7000 -0.000154 0 \n", "-6000 -0.000288 0 \n", "-5000 0.000000 1 \n", "-4000 0.000000 1 \n", "-3000 0.000000 1 \n", "-2000 0.000000 1 \n", "-1750 0.000000 1 \n", "-1500 0.000000 1 \n", "-1250 0.000000 1 \n", "-1000 0.000000 1 \n", "-900 0.000000 1 \n", "-800 0.000000 1 \n", "-700 0.000000 1 \n", "-600 0.000000 1 \n", "-500 0.000000 1 \n", "-400 0.000000 1 \n", "-300 0.000000 1 \n", "-200 0.000000 1 \n", "-100 0.000000 1 \n", " 0 0.000000 1 \n", " 100 0.000000 1 \n", " 200 0.000000 1 \n", "... ... ... \n", " 1000 0.000000 1 \n", " 1100 0.000000 1 \n", " 1200 0.000000 1 \n", " 1300 0.000000 1 \n", " 1350 0.000000 1 \n", " 1400 0.000000 1 \n", " 1450 0.000000 1 \n", " 1500 0.000000 1 \n", " 1550 0.000000 1 \n", " 1600 0.000000 0 \n", " 1650 0.000548 1 \n", " 1700 0.000624 1 \n", " 1725 0.000624 1 \n", " 1750 0.000624 1 \n", " 1775 0.000624 0 \n", " 1800 0.002624 1 \n", " 1825 0.002624 1 \n", " 1850 0.002624 1 \n", " 1875 0.002624 0 \n", " 1900 0.015212 1 \n", " 1920 0.015212 1 \n", " 1940 0.015212 1 \n", " 1950 0.015212 1 \n", " 1960 0.015212 1 \n", " 1970 0.015212 1 \n", " 1980 0.015212 1 \n", " 1990 0.015212 1 \n", " 2000 0.015212 1 \n", " 2010 0.015212 1 \n", " 2020 0.015212 0 \n", "\n", "[67 rows x 7 columns]\n" ] } ], "source": [ "long_run_population_df = pd.read_csv(\n", " 'https://delong.typepad.com/world-population-and-income-delong.csv'\n", ")\n", "\n", "long_run_population_df['year_index'] = long_run_population_df['Year']\n", "long_run_population_df.set_index('year_index', inplace=True)\n", "\n", "long_run_population_dict = {\n", " 'df': long_run_population_df, \n", " 'csv_url': 'https://delong.typepad.com/world-population-and-income-delong.csv', \n", " 'title': 'Long Run Population Estimates', \n", " 'source_url': 'https://www.icloud.com/numbers/04PaQHeujdlFIL3wn56PDM1bA', \n", " 'note': ' '\n", " }\n", "\n", "# print(long_run_population_df)\n", "# long_run_population_df.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " \n", "\n", "# Long-Run World Population Estimates\n", "\n", " \n", "\n", "----\n", "\n", " " ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.5" } }, "nbformat": 4, "nbformat_minor": 4 }