Earlier this week I used Pandas to grab some historical data on the S&P 500 from Yahoo!Finance and generate a simple time series plot. Today, I am going to re-examine this data set in order to show the importance of scaling and adjusting for inflation when plotting economic data.

I again use the functions from the pandas.io.data to grab the data. Specifically, I use get_data_yahoo('^GSPC') to get the S&P 500 time series, and get_data_fred('CPIAUCSL')to grab the consumer price index (CPI). Here is a naive plot of historical S&P 500 returns from 1950 through 2012 (as usual, includes grey NBER recession bands).

Note that, because the CPI data are monthly frequency, I resample the daily S&P 500 data by taking monthly averages. This plot might make you conclude that there was a massive structural break/regime change around the year 2000 in whatever underlying process is generating the S&P 500. However, as the level of the S&P 500 increases, the linear scale on the vertical axis makes changes from month to month seem more dramatic. To control for this, I simply make the vertical scale logarithmic (now equal distances on the vertical axis represent equal percentage changes in the S&P 500).

Now the "obvious" structural break in the year 2000 no longer seems so obvious. Indeed there was a period of roughly 10-15 years during the late 1960's through 1970's during which the S&P 500 basically moved sideways in a similar manner to what we have experienced during the last 10+ years.

This brings us to another, more significant, problem with these graphs: neither or them adjusts for inflation! When plotting long economic time series it is always a good idea to adjust for inflation. The 1970's was a period of fairly high inflation in the U.S., thus the fact that the nominal value of the S&P 500 didn't change all that much over this period tells us that, in real terms, the value of the S&P 500 fell considerably.

Using the CPI data from FRED, it is straight-forward to convert the nominal value of the S&P 500 index to a real value for some base month/year. Below is a plot of the real S&P 500 (in Nov. 2012 Dollars), with a logarithmic scale on the vertical axis. As expected, the real S&P 500 declined significantly during the 1970's.

Code is available on GitHub. Enjoy!

## Blog Topics...

3D plotting
(1)
Academic Life
(2)
ACE
(18)
Adaptive Behavior
(2)
Agglomeration
(1)
Aggregation Problems
(1)
Asset Pricing
(1)
Asymmetric Information
(2)
Behavioral Economics
(1)
Breakfast
(4)
Business Cycles
(8)
Business Theory
(4)
China
(1)
Cities
(2)
Clustering
(1)
Collective Intelligence
(1)
Community Structure
(1)
Complex Systems
(42)
Computational Complexity
(1)
Consumption
(1)
Contracting
(1)
Credit constraints
(1)
Credit Cycles
(6)
Daydreaming
(2)
Decision Making
(1)
Deflation
(1)
Diffusion
(2)
Disequilibrium Dynamics
(6)
DSGE
(3)
Dynamic Programming
(6)
Dynamical Systems
(9)
Econometrics
(2)
Economic Growth
(5)
Economic Policy
(5)
Economic Theory
(1)
Education
(4)
Emacs
(1)
Ergodic Theory
(6)
Euro Zone
(1)
Evolutionary Biology
(1)
EVT
(1)
Externalities
(1)
Finance
(29)
Fitness
(6)
Game Theory
(3)
General Equilibrium
(8)
Geopolitics
(1)
GitHub
(1)
Graph of the Day
(11)
Greatest Hits
(1)
Healthcare Economics
(1)
Heterogenous Agent Models
(2)
Heteroskedasticity
(1)
HFT
(1)
Housing Market
(2)
Income Inequality
(2)
Inflation
(2)
Institutions
(2)
Interesting reading material
(2)
IPython
(1)
IS-LM
(1)
Jerusalem
(7)
Keynes
(1)
Kronecker Graphs
(3)
Krussel-Smith
(1)
Labor Economics
(1)
Leverage
(2)
Liquidity
(11)
Logistics
(6)
Lucas Critique
(2)
Machine Learning
(2)
Macroeconomics
(45)
Macroprudential Regulation
(1)
Mathematics
(23)
matplotlib
(10)
Mayavi
(1)
Micro-foundations
(10)
Microeconomic of Banking
(1)
Modeling
(8)
Monetary Policy
(4)
Mountaineering
(9)
MSD
(1)
My Daily Show
(3)
NASA
(1)
Networks
(46)
Non-parametric Estimation
(5)
NumPy
(2)
Old Jaffa
(9)
Online Gaming
(1)
Optimal Growth
(1)
Oxford
(4)
Pakistan
(1)
Pandas
(8)
Penn World Tables
(1)
Physics
(2)
Pigouvian taxes
(1)
Politics
(6)
Power Laws
(10)
Prediction Markets
(1)
Prices
(3)
Prisoner's Dilemma
(2)
Producer Theory
(2)
Python
(29)
Quant
(4)
Quote of the Day
(21)
Ramsey model
(1)
Rational Expectations
(1)
RBC Models
(2)
Research Agenda
(36)
Santa Fe
(6)
SciPy
(1)
Shakshuka
(1)
Shiller
(1)
Social Dynamics
(1)
St. Andrews
(1)
Statistics
(1)
Stocks
(2)
Sugarscape
(2)
Summer Plans
(2)
Systemic Risk
(13)
Teaching
(16)
Theory of the Firm
(4)
Trade
(4)
Travel
(3)
Unemployment
(9)
Value iteration
(2)
Visualizations
(1)
wbdata
(2)
Web 2.0
(1)
Yale
(1)

## No comments:

## Post a Comment