Version: 3

Topic: Correlation between Gold and Silver Prices

Introduction:

Silver and gold are close substitutes for one another. Both have been used as currency in the pas. There is significant evidence that these metals being an attractive investment and can play a useful role in diversifying risk. There are also economic fundamentals that may act to drive the prices of silver and gold apart.

Research question:

The main objective of this project is to study the relationship and correlation between prices of silver and gold in commodity market.

Cases:

Each case represents the price of silver and gold for a day. The full dataset represents data for 48 years with approximately 12618 cases.

Data Collection:

The data is collected from quandl.com

Type of study:

This is observational study.

Data Visualization

Silver and Gold price data are loaded from the datasets

gold_df <- read.csv(file="/Users/anjalhussan/Desktop/data_science/proposal/GOLD.csv", head=TRUE, sep=",",stringsAsFactors = FALSE) 
head(gold_df)
##         Date USD..AM. USD..PM. GBP..AM. GBP..PM. EURO..AM. EURO..PM.
## 1 2017-11-30  1282.15  1280.20   952.64   948.88   1084.06   1074.98
## 2 2017-11-29  1294.85  1283.85   965.70   957.50   1092.46   1085.11
## 3 2017-11-28  1293.90  1291.85   972.75   974.18   1088.95   1087.61
## 4 2017-11-27  1294.70  1294.90   969.73   969.36   1084.83   1085.00
## 5 2017-11-24  1289.15  1290.50   967.89   966.58   1086.37   1082.60
## 6 2017-11-23  1290.15  1290.35   969.93   969.96   1089.40   1089.18
silver_df = read.csv(file="/Users/anjalhussan/Desktop/data_science/proposal/SILVER.csv", head=TRUE, sep=",",stringsAsFactors = FALSE)
head(silver_df)
##         Date    USD   GBP  EURO
## 1 2017-11-30 16.570 12.32 14.00
## 2 2017-11-29 16.895 12.60 14.26
## 3 2017-11-28 17.070 12.84 14.36
## 4 2017-11-27 17.100 12.81 14.32
## 5 2017-11-24 17.050 12.80 14.38
## 6 2017-11-23 17.095 12.84 14.43

Gold Price Data

ggplot (gold_df, aes(as.Date(Date), USD..AM.)) +
  geom_line (aes(color="Gold")) +
  labs (color="Legend") +
  scale_colour_manual ("", breaks = c("gold"), values = c("goldenrod3")) +
  ggtitle ("Gold Prices") + theme (plot.title = element_text(lineheight=0.7, face="bold"))

Gold Price Histogram

ggplot(data=gold_df, aes(gold_df$USD..AM.)) +
  geom_histogram(aes(fill = ..count..)) +
  scale_fill_gradient("Count", low = "yellow", high = "goldenrod3")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 1 rows containing non-finite values (stat_bin).

Silver Price Data

ggplot (silver_df, aes(as.Date(Date), USD)) +
  geom_line (aes(color="Silver")) +
  labs (color="Legend") +
  scale_colour_manual ("", breaks = c("silver"), values = c("ivory4")) +
  ggtitle ("Silver Prices") +
  theme (plot.title = element_text(lineheight=0.7, face="bold"))

Silver Price Histogram

ggplot(data=silver_df, aes(silver_df$USD)) +
geom_histogram(aes(fill = ..count..)) +
scale_fill_gradient("Count", low = "grey", high = "ivory4")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 19 rows containing non-finite values (stat_bin).

Statistical Analysis:

In this section we will create a linear regression model and calculate the correlation between the data to see if there is a strong relationship between silver and gold prices.

Create a function to calculate the correlation and round it to 4 decimal digits

findCorrelation <- function() {
  x = PriceRatioDataSet$SilverPrice
  y = PriceRatioDataSet$GoldPrice
  corr = round(cor(x, y),4)
  print (paste0("Correlation = ",corr))
  return (corr)
}

Create a function for Linear Model

findStatsFunction <- function() {
  m = lm (GoldPrice ~ SilverPrice, data = total_2001_2013_df)
  s = summary(m)
  print(s)
  
  slp = round(m$coefficients[2], 4)
  int = round(m$coefficients[1], 4)

  return (m)
}

Display the Linear Model: In this section, Linear model will be displayed with ggplot

Regression Statistics:

• Linear Regression Equation • Correlation Coefficient

Hypothesis Testing:

H_0 : Null Hypothesis: There is no relationship between silver and gold prices H_A : Alternative Hypothesis: There is a relationship between silver and gold prices

Here the multiple R value is 0.9296 which shows that there is significant correlation between silver and gold prices. Also the value of R square is 0.9296 which shows the extent to which the silver price affects the gold price. Therefore, we reject the null hypothesis (H_0) and accept the Alternative hypothesis (H_1).

Response:

Price of gold is the response variable. It is numerical continuous variable.

Explanatory:

The explanatory variable is the price of silver and is numerical.

End of Project Proposal