We explore two kinds of economic indicators:
Business cycle indicators. Here we look at a number of different measures of current economic activity. We do this for the US, but similar methods are used in other countries. We use monthly indicators, which give us a picture of the current state of the economy, and generally do it more quickly than waiting for quarterly data on aggregate GDP.
Country indicators. Here the goal is to assess the economic and business climate in a country for a specific business opportunity. Should we locate a business analytics startup in Barcelona, Paris, or Stockholm? Should we open a new factory in China, Thailand, or Vietnam? Should we expand a meat production and retail operation beyond Zambia to other countries in southern Africa?
This IPython notebook was created by Dave Backus for the NYU Stern course Data Bootcamp.
In [3]:
# import packages
import pandas as pd # data management
import matplotlib.pyplot as plt # graphics
import numpy as np # numerical calculations
# IPython command, puts plots in notebook
%matplotlib inline
# check Python version
import datetime as dt
import sys
print('Today is', dt.date.today())
print('What version of Python are we running? \n', sys.version, sep='')
We assess the state of the US economy with a collection of monthly indicators that (mostly) move up and down with the economy. We get the data from FRED, the St Louis Fed's popular data collection. There are lots of indicators to choose from, but we use
For each indicator the first term is the FRED code, the second a description. You can find more about this kind of thing in our Global Economy book, chapter 11. Also in bank reports, which review this kind of information constantly.
In [5]:
# get data from FRED
import pandas as pd
import pandas.io.data as web # web interface with FRED
import datetime as dt # handles dates
# get data
indicators = ['INDPRO', 'PAYEMS', 'AWHMAN', 'PERMIT', 'NAPM', 'RSXFS']
start_date = dt.datetime(1970, 1, 1)
inds = web.DataReader(indicators, "fred", start_date)
end = inds.index[-1]
# yoy growth rates
g = inds.pct_change(periods=12).dropna()
# standardize
gs = (g - g.mean()) / g.std()
# correlations
gs.corr()
Out[5]:
In [6]:
# plot
fig, ax = plt.subplots()
gs.plot(ax=ax)
ax.set_title('Economic indicators', fontsize=14, loc='left')
ax.set_ylabel('Standard deviations from mean')
ax.set_xlabel('')
ax.hlines(y=0, xmin=start_date, xmax=end, linestyles='dashed')
#ax.legend().set_visible(False)
ax.legend(loc='upper left', fontsize=10, handlelength=2, labelspacing=0.15)
Out[6]:
In [7]:
# focus on recent past
recent_date = dt.datetime(2005, 1, 1)
grecent= gs[gs.index>=recent_date]
fig, ax = plt.subplots()
grecent.plot(ax=ax)
ax.set_title('Zoom in on recent past', fontsize=14, loc='left')
ax.set_ylabel('Standard deviations from mean')
ax.set_xlabel('')
ax.hlines(y=0, xmin=recent_date, xmax=end, linestyles='dashed')
ax.legend(loc='upper left', fontsize=10, handlelength=2, labelspacing=0.15)
Out[7]:
Question. How do things look now?
Keep in mind that zero is average, which has been pretty good on the whole. Anything between -1 and +1 is ok: it's within one standard deviation of the average.
In [9]:
fig, ax = plt.subplots()
heatmap = ax.pcolor(gs.T, cmap=plt.cm.Blues)
ax.invert_yaxis()
ax.xaxis.tick_top()
#ax.set_yticks(range(5)+0.5)
ax.set_xticklabels(gs.index, minor=False)
ax.set_yticklabels(gs.columns, minor=False)
Out[9]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
Zambeef is a successful meat distributor located in Zambia. Their leadership wonders whether their operation can be expanded to include neighboring Botswana and Tanzania. We collect a number of economic and institutional indicators to assess the business climates in the three countries and ask:
We start by looking through the World Bank's enormous collection of country indicators and using Pandas' World Bank API to access the numbers.
In [20]:
from pandas.io import wb # World Bank api
# read data from World Bank
iso = ['ZMB', 'BWA', 'TZA'] # country list (ISO codes)
var = ['NY.GDP.PCAP.PP.KD', # GDP per person
'SP.POP.TOTL', # population
'IC.BUS.EASE.XQ', # ease of doing business (rank of 189)
'IS.ROD.PAVE.ZS', # paved roads (percent of total)
'SE.ADT.LITR.ZS'] # adult literacy (15 and up)
year = 2014
df = wb.download(indicator=var, country=iso, start=2005, end=2014)
df
Out[20]:
Can we extract the most recent obs for each variable and country?
In [ ]:
In [ ]: