Gold Price Analytics (Descriptive Analysis)

This is a Markdown document about Analysis of Gold Stock Price Trend Details

library(gplots)
## 
## Attaching package: 'gplots'
## The following object is masked from 'package:stats':
## 
##     lowess
library(ggplot2)
library(ROCR)
gold <- read.csv("/Users/maheshgurumoorthi/Dropbox/BSE-BOM590111.csv", header = TRUE)
str(gold)
## 'data.frame':    1660 obs. of  13 variables:
##  $ Date                      : chr  "2017-02-06" "2017-02-03" "2017-02-02" "2017-01-31" ...
##  $ Open                      : num  0.79 0.79 0.83 0.87 0.91 0.91 0.91 0.93 0.89 0.88 ...
##  $ High                      : num  0.79 0.79 0.83 0.87 0.91 0.91 0.91 0.93 0.89 0.88 ...
##  $ Low                       : num  0.76 0.79 0.83 0.87 0.91 0.9 0.91 0.92 0.89 0.85 ...
##  $ Close                     : num  0.76 0.79 0.83 0.87 0.91 0.91 0.91 0.92 0.89 0.85 ...
##  $ WAP                       : num  0.79 0.79 0.83 0.87 0.91 0.91 0.91 0.92 0.88 0.87 ...
##  $ No..of.Shares             : num  7430 310 75 1050 400 ...
##  $ No..of.Trades             : num  7 4 1 2 1 6 1 2 2 2 ...
##  $ Total.Turnover            : num  5848 244 62 913 364 ...
##  $ Deliverable.Quantity      : num  7430 310 75 1050 400 ...
##  $ X..Deli..Qty.to.Traded.Qty: num  100 100 100 100 100 100 100 100 100 100 ...
##  $ Spread.H.L                : num  0.03 0 0 0 0 0.01 0 0.01 0 0.03 ...
##  $ Spread.C.O                : num  -0.03 0 0 0 0 0 0 -0.01 0 -0.03 ...
summary(gold)
##      Date                Open             High            Low       
##  Length:1660        Min.   : 0.500   Min.   : 0.52   Min.   : 0.50  
##  Class :character   1st Qu.: 1.350   1st Qu.: 1.38   1st Qu.: 1.32  
##  Mode  :character   Median : 5.255   Median : 5.38   Median : 4.95  
##                     Mean   :11.834   Mean   :12.17   Mean   :11.22  
##                     3rd Qu.:11.393   3rd Qu.:11.94   3rd Qu.:11.25  
##                     Max.   :84.950   Max.   :84.95   Max.   :71.50  
##      Close             WAP         No..of.Shares    No..of.Trades  
##  Min.   : 0.520   Min.   : 0.000   Min.   :     1   Min.   :  1.0  
##  1st Qu.: 1.350   1st Qu.: 1.336   1st Qu.:  4393   1st Qu.: 14.0  
##  Median : 5.085   Median : 5.120   Median : 33871   Median : 72.5  
##  Mean   :11.674   Mean   :11.689   Mean   :101330   Mean   :123.0  
##  3rd Qu.:11.377   3rd Qu.:11.452   3rd Qu.:153417   3rd Qu.:185.2  
##  Max.   :74.550   Max.   :74.972   Max.   :849341   Max.   :752.0  
##  Total.Turnover     Deliverable.Quantity X..Deli..Qty.to.Traded.Qty
##  Min.   :       0   Min.   :     1       Min.   :  4.76            
##  1st Qu.:    7160   1st Qu.:  4300       1st Qu.: 78.93            
##  Median :  108630   Median : 31095       Median :100.00            
##  Mean   : 1664520   Mean   : 75754       Mean   : 88.68            
##  3rd Qu.: 2057775   3rd Qu.:122723       3rd Qu.:100.00            
##  Max.   :23830476   Max.   :631381       Max.   :100.00            
##    Spread.H.L        Spread.C.O      
##  Min.   : 0.0000   Min.   :-17.1500  
##  1st Qu.: 0.0400   1st Qu.: -0.1500  
##  Median : 0.1800   Median :  0.0000  
##  Mean   : 0.9525   Mean   : -0.1604  
##  3rd Qu.: 0.8900   3rd Qu.:  0.0300  
##  Max.   :23.3000   Max.   : 14.0000
#adding new variable isexpensive (assumption) as response variable:
gold$isexpensive <- gold$Close > 1.00

set.seed(1)
istest <- runif(nrow(gold)) >0.70
train <- gold[istest == FALSE,]
test <- gold[istest ==TRUE,]

#Model 1 : Open as the only predictor:
fit1 <- glm(gold$isexpensive ~ gold$Open, data = gold, family = binomial())
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
#Model 2 : High as the only predictor:
fit2 <- glm(gold$isexpensive ~ gold$High, data = gold, family = binomial())
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
#Model 3 : Close as the only predictor: 
fit3 <- glm(gold$isexpensive ~ gold$Close, data = gold, family = binomial())
## Warning: glm.fit: algorithm did not converge

## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred

Creating Binary Plot of Gold with Closing Price & Gold Shares on daily basis

## Warning in plot.window(...): "colorize" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "colorize" is not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "colorize" is not a
## graphical parameter

## Warning in axis(side = side, at = at, labels = labels, ...): "colorize" is not a
## graphical parameter
## Warning in box(...): "colorize" is not a graphical parameter
## Warning in title(...): "colorize" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "colorize" is not a
## graphical parameter
## Warning in title(sub = sub.caption, ...): "colorize" is not a graphical
## parameter

## Warning in plot.window(...): "colorize" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "colorize" is not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "colorize" is not a
## graphical parameter

## Warning in axis(side = side, at = at, labels = labels, ...): "colorize" is not a
## graphical parameter
## Warning in box(...): "colorize" is not a graphical parameter
## Warning in title(...): "colorize" is not a graphical parameter
## Warning in title(sub = sub.caption, ...): "colorize" is not a graphical
## parameter

## Warning in plot.window(...): "colorize" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "colorize" is not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "colorize" is not a
## graphical parameter

## Warning in axis(side = side, at = at, labels = labels, ...): "colorize" is not a
## graphical parameter
## Warning in box(...): "colorize" is not a graphical parameter
## Warning in title(...): "colorize" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "colorize" is not a
## graphical parameter
## Warning in title(sub = sub.caption, ...): "colorize" is not a graphical
## parameter

## Warning in plot.window(...): "colorize" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "colorize" is not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "colorize" is not a
## graphical parameter

## Warning in axis(side = side, at = at, labels = labels, ...): "colorize" is not a
## graphical parameter
## Warning in box(...): "colorize" is not a graphical parameter
## Warning in title(...): "colorize" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "colorize" is not a
## graphical parameter
## Warning in title(sub = sub.caption, ...): "colorize" is not a graphical
## parameter

## Warning in plot.window(...): "add" is not a graphical parameter
## Warning in plot.window(...): "colorize" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "add" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "colorize" is not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "add" is not a
## graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "colorize" is not a
## graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "add" is not a
## graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "colorize" is not a
## graphical parameter
## Warning in box(...): "add" is not a graphical parameter
## Warning in box(...): "colorize" is not a graphical parameter
## Warning in title(...): "add" is not a graphical parameter
## Warning in title(...): "colorize" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "add" is not a graphical
## parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "colorize" is not a
## graphical parameter
## Warning in title(sub = sub.caption, ...): "add" is not a graphical parameter
## Warning in title(sub = sub.caption, ...): "colorize" is not a graphical
## parameter

## Warning in plot.window(...): "add" is not a graphical parameter
## Warning in plot.window(...): "colorize" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "add" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "colorize" is not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "add" is not a
## graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "colorize" is not a
## graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "add" is not a
## graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "colorize" is not a
## graphical parameter
## Warning in box(...): "add" is not a graphical parameter
## Warning in box(...): "colorize" is not a graphical parameter
## Warning in title(...): "add" is not a graphical parameter
## Warning in title(...): "colorize" is not a graphical parameter
## Warning in title(sub = sub.caption, ...): "add" is not a graphical parameter
## Warning in title(sub = sub.caption, ...): "colorize" is not a graphical
## parameter

## Warning in plot.window(...): "add" is not a graphical parameter
## Warning in plot.window(...): "colorize" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "add" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "colorize" is not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "add" is not a
## graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "colorize" is not a
## graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "add" is not a
## graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "colorize" is not a
## graphical parameter
## Warning in box(...): "add" is not a graphical parameter
## Warning in box(...): "colorize" is not a graphical parameter
## Warning in title(...): "add" is not a graphical parameter
## Warning in title(...): "colorize" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "add" is not a graphical
## parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "colorize" is not a
## graphical parameter
## Warning in title(sub = sub.caption, ...): "add" is not a graphical parameter
## Warning in title(sub = sub.caption, ...): "colorize" is not a graphical
## parameter

## Warning in plot.window(...): "add" is not a graphical parameter
## Warning in plot.window(...): "colorize" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "add" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "colorize" is not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "add" is not a
## graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "colorize" is not a
## graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "add" is not a
## graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "colorize" is not a
## graphical parameter
## Warning in box(...): "add" is not a graphical parameter
## Warning in box(...): "colorize" is not a graphical parameter
## Warning in title(...): "add" is not a graphical parameter
## Warning in title(...): "colorize" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "add" is not a graphical
## parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "colorize" is not a
## graphical parameter
## Warning in title(sub = sub.caption, ...): "add" is not a graphical parameter
## Warning in title(sub = sub.caption, ...): "colorize" is not a graphical
## parameter

## Warning in plot.window(...): "add" is not a graphical parameter
## Warning in plot.window(...): "colorize" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "add" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "colorize" is not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "add" is not a
## graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "colorize" is not a
## graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "add" is not a
## graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "colorize" is not a
## graphical parameter
## Warning in box(...): "add" is not a graphical parameter
## Warning in box(...): "colorize" is not a graphical parameter
## Warning in title(...): "add" is not a graphical parameter
## Warning in title(...): "colorize" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "add" is not a graphical
## parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "colorize" is not a
## graphical parameter
## Warning in title(sub = sub.caption, ...): "add" is not a graphical parameter
## Warning in title(sub = sub.caption, ...): "colorize" is not a graphical
## parameter

## Warning in plot.window(...): "add" is not a graphical parameter
## Warning in plot.window(...): "colorize" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "add" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "colorize" is not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "add" is not a
## graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "colorize" is not a
## graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "add" is not a
## graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "colorize" is not a
## graphical parameter
## Warning in box(...): "add" is not a graphical parameter
## Warning in box(...): "colorize" is not a graphical parameter
## Warning in title(...): "add" is not a graphical parameter
## Warning in title(...): "colorize" is not a graphical parameter
## Warning in title(sub = sub.caption, ...): "add" is not a graphical parameter
## Warning in title(sub = sub.caption, ...): "colorize" is not a graphical
## parameter

## Warning in plot.window(...): "add" is not a graphical parameter
## Warning in plot.window(...): "colorize" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "add" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "colorize" is not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "add" is not a
## graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "colorize" is not a
## graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "add" is not a
## graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "colorize" is not a
## graphical parameter
## Warning in box(...): "add" is not a graphical parameter
## Warning in box(...): "colorize" is not a graphical parameter
## Warning in title(...): "add" is not a graphical parameter
## Warning in title(...): "colorize" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "add" is not a graphical
## parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "colorize" is not a
## graphical parameter
## Warning in title(sub = sub.caption, ...): "add" is not a graphical parameter
## Warning in title(sub = sub.caption, ...): "colorize" is not a graphical
## parameter

## Warning in plot.window(...): "add" is not a graphical parameter
## Warning in plot.window(...): "colorize" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "add" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "colorize" is not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "add" is not a
## graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "colorize" is not a
## graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "add" is not a
## graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "colorize" is not a
## graphical parameter
## Warning in box(...): "add" is not a graphical parameter
## Warning in box(...): "colorize" is not a graphical parameter
## Warning in title(...): "add" is not a graphical parameter
## Warning in title(...): "colorize" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "add" is not a graphical
## parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "colorize" is not a
## graphical parameter
## Warning in title(sub = sub.caption, ...): "add" is not a graphical parameter
## Warning in title(sub = sub.caption, ...): "colorize" is not a graphical
## parameter
## Warning in sqrt(crit * p * (1 - hh)/hh): NaNs produced

## Warning in sqrt(crit * p * (1 - hh)/hh): NaNs produced

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.