A Google Data Analytics Capstone Case Study

This case study analyzes the relationship of historic returns on the commodity and producers of such commodity, gold.

DISCLAIMER: I am not a financial advisor and this is not financial advice. All information found here, including any ideas, opinions, views, predictions, forecasts, commentaries, suggestions, or stock picks, expressed or implied herein, are for informational, entertainment or educational purposes only and should not be construed as personal investment advice. While the information provided is believed to be accurate, it may include errors or inaccuracies.

To provide some context on the significance of gold:

Historically, the birth and destruction of different empires have been strongly entangled with the history of gold. The value of gold, as a good store of value and medium of exchange, has outlived the value of every one of those empires’ currencies.

“In short, history has given gold a power surpassing that of any other commodity on the planet, and that power has never really disappeared.”

Adam Hayes Why Gold Matters: Everything You Need To Know

While it is possible to own physical gold in forms of bars or jewerly, I prefer to gain exposure to gold through the stock market.For this case study, I will be using historical data from the stock tickers GLD and GDX as benchmarks of the underlying assets of gold and gold miners. The data sets fails to account for returns from dividends for GDX and may have other limitations.

SPDR’s Gold Shares ETF (GLD)

VanEck >Vectors Gold Miners ETF (GDX).

Preparing and processing the data:

Packages used

install.packages("quantmod", repos = "http://cran.rstudio.com/")
install.packages("shiny", repos = "http://cran.rstudio.com/")
library(shiny)
library(quantmod)
## Loading required package: xts
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
## Loading required package: TTR
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo

Loading the processed data of the two stock tickers from the screener Yahoo Finance

getSymbols(c("GLD", "GDX"), src='yahoo')
## 'getSymbols' currently uses auto.assign=TRUE by default, but will
## use auto.assign=FALSE in 0.5-0. You will still be able to use
## 'loadSymbols' to automatically load data. getOption("getSymbols.env")
## and getOption("getSymbols.auto.assign") will still be checked for
## alternate defaults.
## 
## This message is shown once per session and may be disabled by setting 
## options("getSymbols.warning4.0"=FALSE). See ?getSymbols for details.
## [1] "GLD" "GDX"
##            GLD.Open GLD.High GLD.Low GLD.Close GLD.Volume GLD.Adjusted
## 2007-01-03    63.58    64.02   62.00     62.28    8061900        62.28
## 2007-01-04    62.07    62.50   61.52     61.65    4858600        61.65
## 2007-01-05    60.75    60.78   59.66     60.17   12500100        60.17
## 2007-01-08    60.38    60.54   59.85     60.48    3478700        60.48
## 2007-01-09    60.14    61.09   60.06     60.85    4170400        60.85
## 2007-01-10    60.46    60.82   60.06     60.59    3766000        60.59
##            GDX.Open GDX.High GDX.Low GDX.Close GDX.Volume GDX.Adjusted
## 2007-01-03    40.19    40.22   38.11     38.43     950300     35.05513
## 2007-01-04    38.10    38.24   37.53     37.72     680300     34.40749
## 2007-01-05    36.65    37.34   36.65     37.21    1869400     33.94226
## 2007-01-08    37.30    37.41   36.77     37.30     946000     34.02436
## 2007-01-09    36.75    37.20   36.25     37.05     742800     33.79631
## 2007-01-10    36.32    36.80   36.19     36.61     622700     33.39497

Assigning the variable quarter(ticker) to the historic quartly returns of the stocks

quarterGLD <-quarterlyReturn(GLD)
quarterGDX <-quarterlyReturn(GDX)
##            quarterly.returns
## 2007-03-30        0.03397288
## 2007-06-29       -0.02236083
## 2007-09-28        0.14376856
## 2007-12-31        0.12175210
## 2008-03-31        0.09641044
## 2008-06-30        0.01095009
##            quarterly.returns
## 2007-03-30       -0.01542670
## 2007-06-29       -0.04245643
## 2007-09-28        0.19688570
## 2007-12-31        0.01058443
## 2008-03-31        0.04080294
## 2008-06-30        0.01865826