# import libraries...
import pandas as pd
import numpy as np
import math
import time
import copy
import itertools
from itertools import chain, combinations
from linearmodels.iv import IV2SLS
import matplotlib.pyplot as plt
import scipy.stats as scipystats
import seaborn as sns
from sklearn.cross_validation import train_test_split
import statsmodels.api as sm
import statsmodels.formula.api as smf
from statsmodels.graphics.regressionplots import *
from statsmodels.iolib.summary2 import summary_col
import statsmodels.stats as stats
import statsmodels.stats.stattools as stools
%matplotlib inline
plt.style.use('seaborn')
/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. "This module will be removed in 0.20.", DeprecationWarning) /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. from pandas.core import datetools
long_run_population_df = pd.read_csv(
'https://delong.typepad.com/world-population-and-income-delong.csv'
)
long_run_population_df['year_index'] = long_run_population_df['Year']
long_run_population_df.set_index('year_index', inplace=True)
long_run_population_dict = {
'df': long_run_population_df,
'csv_url': 'https://delong.typepad.com/world-population-and-income-delong.csv',
'title': 'Long Run Population Estimates',
'source_url': 'https://www.icloud.com/numbers/04PaQHeujdlFIL3wn56PDM1bA',
'note': ' '
}
# print(long_run_population_df)
# long_run_population_df.head()
Year Human Population (Millions) Human Population Growth Rate \ year_index -73000 -73000 0.01 NaN -63000 -63000 0.10 0.000230 -53000 -53000 0.13 0.000030 -43000 -43000 0.18 0.000030 -33000 -33000 0.39 0.000075 -23000 -23000 0.82 0.000075 -13000 -13000 1.73 0.000075 -8000 -8000 2.50 0.000074 -7000 -7000 4.18 0.000515 -6000 -6000 7.00 0.000515 -5000 -5000 9.02 0.000254 -4000 -4000 11.63 0.000254 -3000 -3000 15.00 0.000254 -2000 -2000 27.00 0.000588 -1750 -1750 32.01 0.000681 -1500 -1500 37.95 0.000681 -1250 -1250 45.00 0.000681 -1000 -1000 50.00 0.000421 -900 -900 57.43 0.001386 -800 -800 65.97 0.001386 -700 -700 75.78 0.001386 -600 -600 87.04 0.001386 -500 -500 100.00 0.001387 -400 -400 114.48 0.001352 -300 -300 131.05 0.001352 -200 -200 150.00 0.001351 -100 -100 159.67 0.000625 0 0 170.00 0.000627 100 100 179.72 0.000556 200 200 190.00 0.000556 ... ... ... ... 1000 1000 265.00 0.000991 1100 1100 320.00 0.001886 1200 1200 360.00 0.001178 1300 1300 360.00 0.000000 1350 1350 320.00 -0.002356 1400 1400 350.00 0.001792 1450 1450 380.00 0.001645 1500 1500 425.00 0.002238 1550 1550 400.00 -0.001212 1600 1600 545.00 0.006186 1650 1650 545.00 0.000000 1700 1700 610.00 0.002253 1725 1725 660.00 0.003151 1750 1750 720.00 0.003480 1775 1775 800.00 0.004214 1800 1800 900.00 0.004711 1825 1825 1025.00 0.005202 1850 1850 1200.00 0.006305 1875 1875 1300.00 0.003202 1900 1900 1625.00 0.008926 1920 1920 1810.00 0.005391 1940 1940 2210.00 0.009983 1950 1950 2520.00 0.013127 1960 1960 3020.00 0.018100 1970 1970 3700.00 0.020308 1980 1980 4450.00 0.018457 1990 1990 5300.00 0.017480 2000 2000 6200.00 0.015684 2010 2010 7000.00 0.012136 2020 2020 7700.00 0.009531 Population Interpolated? Average Real Income Per Capita \ year_index -73000 0 NaN -63000 0 1200.0 -53000 1 1200.0 -43000 1 1200.0 -33000 1 1200.0 -23000 1 1200.0 -13000 1 1200.0 -8000 0 1400.0 -7000 1 1200.0 -6000 0 900.0 -5000 1 900.0 -4000 1 900.0 -3000 0 900.0 -2000 0 900.0 -1750 1 900.0 -1500 1 900.0 -1250 0 900.0 -1000 0 900.0 -900 1 900.0 -800 1 900.0 -700 1 900.0 -600 1 900.0 -500 0 900.0 -400 1 900.0 -300 1 900.0 -200 0 900.0 -100 1 900.0 0 0 900.0 100 1 900.0 200 0 900.0 ... ... ... 1000 0 900.0 1100 0 900.0 1200 0 900.0 1300 0 900.0 1350 0 900.0 1400 0 900.0 1450 0 900.0 1500 0 900.0 1550 0 900.0 1600 0 900.0 1650 0 925.0 1700 0 954.0 1725 0 969.0 1750 0 985.0 1775 0 1000.0 1800 0 1068.0 1825 0 1140.0 1850 0 1218.0 1875 0 1300.0 1900 0 1902.0 1920 0 2578.0 1940 0 3494.0 1950 0 4068.0 1960 0 4737.0 1970 0 5515.0 1980 0 6421.0 1990 0 7476.0 2000 0 8705.0 2010 0 10135.0 2020 0 11800.0 Real Income Growth Rate Income Interpolated? year_index -73000 NaN 0 -63000 0.000000 1 -53000 0.000000 1 -43000 0.000000 1 -33000 0.000000 1 -23000 0.000000 1 -13000 0.000000 0 -8000 0.000031 0 -7000 -0.000154 0 -6000 -0.000288 0 -5000 0.000000 1 -4000 0.000000 1 -3000 0.000000 1 -2000 0.000000 1 -1750 0.000000 1 -1500 0.000000 1 -1250 0.000000 1 -1000 0.000000 1 -900 0.000000 1 -800 0.000000 1 -700 0.000000 1 -600 0.000000 1 -500 0.000000 1 -400 0.000000 1 -300 0.000000 1 -200 0.000000 1 -100 0.000000 1 0 0.000000 1 100 0.000000 1 200 0.000000 1 ... ... ... 1000 0.000000 1 1100 0.000000 1 1200 0.000000 1 1300 0.000000 1 1350 0.000000 1 1400 0.000000 1 1450 0.000000 1 1500 0.000000 1 1550 0.000000 1 1600 0.000000 0 1650 0.000548 1 1700 0.000624 1 1725 0.000624 1 1750 0.000624 1 1775 0.000624 0 1800 0.002624 1 1825 0.002624 1 1850 0.002624 1 1875 0.002624 0 1900 0.015212 1 1920 0.015212 1 1940 0.015212 1 1950 0.015212 1 1960 0.015212 1 1970 0.015212 1 1980 0.015212 1 1990 0.015212 1 2000 0.015212 1 2010 0.015212 1 2020 0.015212 0 [67 rows x 7 columns]