# All That Glitters

[This article was first published on

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

“The law itself follows Gold” **Joe's Data Diner**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

*Sextus Propertius*.

But what about stocks, bonds and real estate? Do they follow Gold too? Using the correlation data from my previous post, The Financial Crisis on Tape Part I, this question is easy to investigate. Indeed, it’s possible to see the correlations in last week’s graph:

where GLD is a Gold tracking fund. Fortunately, the excellent ggplot2 package means that in two slightly chunky lines we can create a bespoke heat-map to answer this question and we don’t have to strain our eyes finding them in the graph above!

SPY: S&P 500

QQQ: Nasdaq 100

EEM: Emerging Markets

IWM: Russel 2000

EFA: EAFE (Europe, Australasia and Far East)

TLT: 20 Year Treasury

IYR: U.S. Real Estate

Here are the two lines used to create it (using data obtained in The Financial Crisis on Tape Part I):

In quieter times it seems that Gold is reasonably un-correlated to the other sectors, but in times of stress, strong correlations appear as expected. The really interesting point is the strong negative correlation seen in Q3 2008. Let’s take a look at the price time series of the S&P, Nasdaq and Gold during ’07-’08:

In terms of the units, these are the prices of representative funds not the assets themselves (see the links to Yahoo Finance which I’ve provided above). As the prices are similar and fit nicely I’ve not used any scaling. The negative correlation is probably related to Gold’s safe haven status. As stocks started dropping, a strong bid for Gold supported its price. This can result in a negative correlation. The graph was created using the code below.

To

**leave a comment**for the author, please follow the link and comment on their blog:**Joe's Data Diner**.R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.