Thursday, September 15, 2011

Correlations among US Stocks: Is it really time to fire your adviser?

Note: This post is NOT financial advice!  This is just a fun way to explore some of the capabilities R has for importing and manipulating data.


The Financial Times says it's time to "Fire your Adviser" because correlations among US stocks are at their highest levels since the financial crisis.  Unfortunately, they only provide data going back 3 months and it's in a boring table, rather than an awesome chart.  After reading this article, I immediately pulled out quantmod and PerfomanceAnalytics in R.  I used quantmod to download the daily data (from yahoo finance) for each index listed in the article, and then used PerformanceAnalytics to analyze and graph it. After and hour or so of fiddling around, I ended up with this chart:

Each line on this chart represents the rolling correlation between a major asset class and the S&P 500 (represented by SPY).  I used a 90-day window to calculate the correlations, so each point on each line is looking backwards at a 90-day timeframe.  As you can see, correlations have indeed gone up in the last few months, but there have been other periods in 2010 and 2011 with similarly high correlations.


This next chart looks at just the major US sectors, and takes the average of each of their correlations with SPY. This shows the overall correlation of the US stock market since 2007.  Again, things are highly correlated right now, but we've been here before.




Here is the code I used to generate these charts.  Feel free to comment on my implementation, and I'll be happy to make any improvements and update the charts.

5 comments:

  1. Another interesting metric to look at is 'cross-sectional volatility,' i.e., the instantaneous level of dispersion across a basket/index of stocks. Here is a recent paper by Menchero et. al. from Barra with some more info: http://papers.ssrn.com/sol3/papers.cfm?abstract_id=1708246

    ReplyDelete
  2. Hi Zach, thanks, very interesting. However: Normally we differentiate stock time series to remove underlying trends - shouldn't we apply this here as well? This gives a slightly different picture, doesn't it?

    ReplyDelete
  3. @unknown: In this case we're interested in the underlying trends. For example, if both XLE and SPY are trending up, the correlation between them will be high. On the other hand, if XLE is trending but SPY is not, the correlation will be low. This is useful information.

    ReplyDelete
  4. Okay, got the point! By the way: your post did save me hours of search by providing this extremely useful example. Will pass by your site often! Cheers, Stephan

    ReplyDelete
  5. @unknown: Glad to hear it! I'd love to hear from you if you gain any interesting insights.

    ReplyDelete

Sociable