Project title:Bitcoin Historical price Regression Analysis

College: BMSIT

Email: pmprasunn457@gmail.com

Introduction:

A cryptocurrency (or crypto currency) is a digital asset designed to work as a medium of exchange that uses cryptography to secure its transactions, to control the creation of additional units, and to verify the transfer of assets. Cryptocurrencies are classified as a subset of digital currencies and are also classified as a subset of alternative currencies and virtual currencies. Cryptocurrencies use decentralized control as opposed to centralized electronic money and central banking systems. The decentralized control of each cryptocurrency works through a blockchain, which is a public transaction database, functioning as a distributed ledger.

BITCOIN:

Bittcoin is a cryptocurrency and worldwide payment system. It is the first decentralized digital currency, as the system works without a central bank or single administrator. The network is peer-to-peer and transactions take place between users directly, without an intermediary. These transactions are verified by network nodes through the use of cryptography and recorded in a public distributed ledger called a blockchain. Bitcoin was invented by an unknown person or group of people under the name Satoshi Nakamoto and released as open-source software in 2009. Bitcoins are created as a reward for a process known as mining. They can be exchanged for other currencies, products, and services. As of February 2015, over 100,000 merchants and vendors accepted bitcoin as payment. Research produced by the University of Cambridge estimates that in 2017, there are 2.9 to 5.8 million unique users using a cryptocurrency wallet, most of them using bitcoin.

Overview of the Study:

It is common for people to say they are “investing” in Bitcoin, but what essentially that person is doing is betting on the increased adoption of Bitcoin. Why is this true? Bitcoin has no physical value. The USD for example is backed by the US Government and as the world’s reserve currency. The value of BTC is merely based on the law of supply and demand. This is interesting because unlike paper currency BTC has a cap on the amount of coins that can be produced, 21 million, which is usually deemed a positive. This carries significance because governments continue to put more currency into circulation which in turn devalues it over time. Due to the supply being limited to 21 million, as demand increases the value will likely increase. Hypothetically, let’s say the United States were to adopt BTC as its currency. In 2013 there were approximately 1.2 trillion USD in circulation, M1, plus all the money in accounts less than 100k USD, referred to as M2 (Clark and Whitbourne). Along with that information, there will ultimately be 21 million BTC in circulation.

USD per Bitcoin if all bitcoin is mined

USD=1610000000000 # 1.61 Trillion USD in circulation
Bitcoin=21000000   # 21 Million Bitcoin (Most Bitcoin that will be in Circulation)
Value=USD/Bitcoin  # Value of Bitcoin compared to current dollar
cat("Value=",Value)
## Value= 76666.67

Bitcoin Data Insights

1.Reading the BITCOIN Data Set

setwd("~/")#Setting the working directory 
#reading the file
BTC <- read.csv(paste("bitcoin_dataset.csv", sep=" "))

Summary of the BItcoin Data set

library(psych)
summary(BTC)
##                   Date      btc_market_price   btc_total_bitcoins
##  2009-11-10 00:00:00:   1   Min.   :   0.000   Min.   : 1339450  
##  2009-11-11 00:00:00:   1   1st Qu.:   5.177   1st Qu.: 7634838  
##  2009-11-12 00:00:00:   1   Median : 213.115   Median :11965900  
##  2009-11-13 00:00:00:   1   Mean   : 471.826   Mean   :10976895  
##  2009-11-14 00:00:00:   1   3rd Qu.: 546.285   3rd Qu.:14816719  
##  2009-11-15 00:00:00:   1   Max.   :7437.543   Max.   :16669275  
##  (Other)            :2914                                        
##  btc_market_cap      btc_trade_volume    btc_blocks_size   
##  Min.   :0.000e+00   Min.   :0.000e+00   Min.   :     0.0  
##  1st Qu.:4.556e+07   1st Qu.:2.226e+05   1st Qu.:   526.5  
##  Median :2.910e+09   Median :7.884e+06   Median : 11733.0  
##  Mean   :7.290e+09   Mean   :3.161e+07   Mean   : 30700.7  
##  3rd Qu.:7.179e+09   3rd Qu.:2.444e+07   3rd Qu.: 48666.2  
##  Max.   :1.239e+11   Max.   :1.267e+09   Max.   :140294.6  
##                      NA's   :21                            
##  btc_avg_block_size  btc_n_orphaned_blocks btc_n_transactions_per_block
##  Min.   :0.0002152   Min.   :0.0000        Min.   :   1.0              
##  1st Qu.:0.0204443   1st Qu.:0.0000        1st Qu.:  46.0              
##  Median :0.1750999   Median :0.0000        Median : 348.0              
##  Mean   :0.3180708   Mean   :0.3623        Mean   : 609.3              
##  3rd Qu.:0.5971502   3rd Qu.:0.0000        3rd Qu.:1042.5              
##  Max.   :1.0466060   Max.   :7.0000        Max.   :2436.1              
##                                                                        
##  btc_median_confirmation_time btc_hash_rate      btc_difficulty     
##  Min.   : 0.000               Min.   :       0   Min.   :1.000e+00  
##  1st Qu.: 0.000               1st Qu.:      10   1st Qu.:1.468e+06  
##  Median : 7.767               Median :    4127   Median :5.109e+08  
##  Mean   : 7.130               Mean   :  828840   Mean   :1.099e+11  
##  3rd Qu.: 9.852               3rd Qu.:  490384   3rd Qu.:6.225e+10  
##  Max.   :47.733               Max.   :12999790   Max.   :1.453e+12  
##                                                                     
##  btc_miners_revenue btc_transaction_fees btc_cost_per_transaction_percent
##  Min.   :       0   Min.   :  0.000      Min.   :      0.0               
##  1st Qu.:   39709   1st Qu.:  6.253      1st Qu.:      1.2               
##  Median :  769083   Median : 17.546      Median :      2.6               
##  Mean   : 1280992   Mean   : 45.727      Mean   :   1918.6               
##  3rd Qu.: 1687000   3rd Qu.: 44.974      3rd Qu.:      6.4               
##  Max.   :15347363   Max.   :668.132      Max.   :2000000.0               
##                                                                          
##  btc_cost_per_transaction btc_n_unique_addresses btc_n_transactions
##  Min.   : 0.000           Min.   :    49         Min.   :    49    
##  1st Qu.: 3.408           1st Qu.: 12042         1st Qu.:  6713    
##  Median : 7.459           Median : 95554         Median : 58183    
##  Mean   :11.680           Mean   :171251         Mean   : 92272    
##  3rd Qu.:12.451           3rd Qu.:302227         3rd Qu.:159053    
##  Max.   :90.202           Max.   :733878         Max.   :369098    
##                                                                    
##  btc_n_transactions_total btc_n_transactions_excluding_popular
##  Min.   :    26958        Min.   :    49                      
##  1st Qu.:  1834960        1st Qu.:  5642                      
##  Median : 26725555        Median : 42653                      
##  Mean   : 59858433        Mean   : 85010                      
##  3rd Qu.: 91651828        3rd Qu.:154779                      
##  Max.   :269460981        Max.   :361974                      
##                                                               
##  btc_n_transactions_excluding_chains_longer_than_100 btc_output_volume 
##  Min.   :    49                                      Min.   :    2450  
##  1st Qu.:  6034                                      1st Qu.:  431346  
##  Median : 30921                                      Median : 1025858  
##  Mean   : 56864                                      Mean   : 1486692  
##  3rd Qu.: 94479                                      3rd Qu.: 1938697  
##  Max.   :286896                                      Max.   :45992223  
##                                                                        
##  btc_estimated_transaction_volume btc_estimated_transaction_volume_usd
##  Min.   :      0                  Min.   :0.000e+00                   
##  1st Qu.:  83286                  1st Qu.:6.869e+05                   
##  Median : 170951                  Median :3.070e+07                   
##  Mean   : 195545                  Mean   :1.124e+08                   
##  3rd Qu.: 254403                  3rd Qu.:1.097e+08                   
##  Max.   :5825066                  Max.   :2.396e+09                   
## 
str(BTC)
## 'data.frame':    2920 obs. of  24 variables:
##  $ Date                                               : Factor w/ 2920 levels "2009-11-10 00:00:00",..: 1 2 3 4 5 6 7 8 9 10 ...
##  $ btc_market_price                                   : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ btc_total_bitcoins                                 : num  1339450 1342900 1346400 1349900 1354050 ...
##  $ btc_market_cap                                     : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ btc_trade_volume                                   : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ btc_blocks_size                                    : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ btc_avg_block_size                                 : num  0.000215 0.000323 0.000215 0.000242 0.000216 ...
##  $ btc_n_orphaned_blocks                              : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ btc_n_transactions_per_block                       : num  1 1 1 1 1 1 1 1 1 1 ...
##  $ btc_median_confirmation_time                       : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ btc_hash_rate                                      : num  3.53e-06 3.43e-06 3.48e-06 3.48e-06 4.13e-06 ...
##  $ btc_difficulty                                     : num  1 1 1 1 1 1 1 1 1 1 ...
##  $ btc_miners_revenue                                 : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ btc_transaction_fees                               : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ btc_cost_per_transaction_percent                   : num  0 19.2 0 673.1 0 ...
##  $ btc_cost_per_transaction                           : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ btc_n_unique_addresses                             : num  71 71 70 73 83 96 100 91 79 73 ...
##  $ btc_n_transactions                                 : num  71 78 70 73 83 96 100 91 79 73 ...
##  $ btc_n_transactions_total                           : num  26958 27036 27106 27179 27262 ...
##  $ btc_n_transactions_excluding_popular               : num  71 78 70 73 83 96 100 91 79 73 ...
##  $ btc_n_transactions_excluding_chains_longer_than_100: num  71 78 70 73 83 96 100 91 79 73 ...
##  $ btc_output_volume                                  : num  3550 93450 3500 4100 4150 ...
##  $ btc_estimated_transaction_volume                   : num  0 18000 0 520 0 0 0 0 0 0 ...
##  $ btc_estimated_transaction_volume_usd               : num  0 0 0 0 0 0 0 0 0 0 ...
describe(BTC)
##                                                     vars    n         mean
## Date*                                                  1 2920 1.460500e+03
## btc_market_price                                       2 2920 4.718300e+02
## btc_total_bitcoins                                     3 2920 1.097689e+07
## btc_market_cap                                         4 2920 7.290293e+09
## btc_trade_volume                                       5 2899 3.161043e+07
## btc_blocks_size                                        6 2920 3.070073e+04
## btc_avg_block_size                                     7 2920 3.200000e-01
## btc_n_orphaned_blocks                                  8 2920 3.600000e-01
## btc_n_transactions_per_block                           9 2920 6.093000e+02
## btc_median_confirmation_time                          10 2920 7.130000e+00
## btc_hash_rate                                         11 2920 8.288403e+05
## btc_difficulty                                        12 2920 1.099002e+11
## btc_miners_revenue                                    13 2920 1.280992e+06
## btc_transaction_fees                                  14 2920 4.573000e+01
## btc_cost_per_transaction_percent                      15 2920 1.918640e+03
## btc_cost_per_transaction                              16 2920 1.168000e+01
## btc_n_unique_addresses                                17 2920 1.712510e+05
## btc_n_transactions                                    18 2920 9.227195e+04
## btc_n_transactions_total                              19 2920 5.985843e+07
## btc_n_transactions_excluding_popular                  20 2920 8.501016e+04
## btc_n_transactions_excluding_chains_longer_than_100   21 2920 5.686395e+04
## btc_output_volume                                     22 2920 1.486692e+06
## btc_estimated_transaction_volume                      23 2920 1.955447e+05
## btc_estimated_transaction_volume_usd                  24 2920 1.123620e+08
##                                                               sd
## Date*                                               8.430800e+02
## btc_market_price                                    9.349600e+02
## btc_total_bitcoins                                  4.456721e+06
## btc_market_cap                                      1.548875e+10
## btc_trade_volume                                    8.273604e+07
## btc_blocks_size                                     3.926642e+04
## btc_avg_block_size                                  3.400000e-01
## btc_n_orphaned_blocks                               8.400000e-01
## btc_n_transactions_per_block                        6.533900e+02
## btc_median_confirmation_time                        5.050000e+00
## btc_hash_rate                                       1.799654e+06
## btc_difficulty                                      2.364067e+11
## btc_miners_revenue                                  1.999356e+06
## btc_transaction_fees                                7.885000e+01
## btc_cost_per_transaction_percent                    5.128409e+04
## btc_cost_per_transaction                            1.342000e+01
## btc_n_unique_addresses                              1.865764e+05
## btc_n_transactions                                  9.739535e+04
## btc_n_transactions_total                            7.459717e+07
## btc_n_transactions_excluding_popular                9.778191e+04
## btc_n_transactions_excluding_chains_longer_than_100 6.551870e+04
## btc_output_volume                                   2.280472e+06
## btc_estimated_transaction_volume                    2.697794e+05
## btc_estimated_transaction_volume_usd                2.402841e+08
##                                                           median
## Date*                                               1.460500e+03
## btc_market_price                                    2.131200e+02
## btc_total_bitcoins                                  1.196590e+07
## btc_market_cap                                      2.909919e+09
## btc_trade_volume                                    7.884278e+06
## btc_blocks_size                                     1.173300e+04
## btc_avg_block_size                                  1.800000e-01
## btc_n_orphaned_blocks                               0.000000e+00
## btc_n_transactions_per_block                        3.480000e+02
## btc_median_confirmation_time                        7.770000e+00
## btc_hash_rate                                       4.127250e+03
## btc_difficulty                                      5.109297e+08
## btc_miners_revenue                                  7.690828e+05
## btc_transaction_fees                                1.755000e+01
## btc_cost_per_transaction_percent                    2.620000e+00
## btc_cost_per_transaction                            7.460000e+00
## btc_n_unique_addresses                              9.555400e+04
## btc_n_transactions                                  5.818250e+04
## btc_n_transactions_total                            2.672556e+07
## btc_n_transactions_excluding_popular                4.265250e+04
## btc_n_transactions_excluding_chains_longer_than_100 3.092050e+04
## btc_output_volume                                   1.025858e+06
## btc_estimated_transaction_volume                    1.709510e+05
## btc_estimated_transaction_volume_usd                3.070331e+07
##                                                          trimmed
## Date*                                               1.460500e+03
## btc_market_price                                    2.521800e+02
## btc_total_bitcoins                                  1.136309e+07
## btc_market_cap                                      3.550474e+09
## btc_trade_volume                                    1.269097e+07
## btc_blocks_size                                     2.340318e+04
## btc_avg_block_size                                  2.800000e-01
## btc_n_orphaned_blocks                               1.300000e-01
## btc_n_transactions_per_block                        5.175500e+02
## btc_median_confirmation_time                        6.920000e+00
## btc_hash_rate                                       3.448951e+05
## btc_difficulty                                      4.612941e+10
## btc_miners_revenue                                  8.476209e+05
## btc_transaction_fees                                2.621000e+01
## btc_cost_per_transaction_percent                    4.700000e+00
## btc_cost_per_transaction                            8.980000e+00
## btc_n_unique_addresses                              1.451639e+05
## btc_n_transactions                                  7.884295e+04
## btc_n_transactions_total                            4.602158e+07
## btc_n_transactions_excluding_popular                7.055401e+04
## btc_n_transactions_excluding_chains_longer_than_100 4.604016e+04
## btc_output_volume                                   1.152241e+06
## btc_estimated_transaction_volume                    1.702264e+05
## btc_estimated_transaction_volume_usd                5.309453e+07
##                                                              mad     min
## Date*                                               1.082300e+03       1
## btc_market_price                                    3.126000e+02       0
## btc_total_bitcoins                                  4.991562e+06 1339450
## btc_market_cap                                      4.306411e+09       0
## btc_trade_volume                                    1.168391e+07       0
## btc_blocks_size                                     1.739386e+04       0
## btc_avg_block_size                                  2.600000e-01       0
## btc_n_orphaned_blocks                               0.000000e+00       0
## btc_n_transactions_per_block                        4.981500e+02       1
## btc_median_confirmation_time                        3.360000e+00       0
## btc_hash_rate                                       6.119060e+03       0
## btc_difficulty                                      7.575044e+08       1
## btc_miners_revenue                                  1.095266e+06       0
## btc_transaction_fees                                2.287000e+01       0
## btc_cost_per_transaction_percent                    2.520000e+00       0
## btc_cost_per_transaction                            6.460000e+00       0
## btc_n_unique_addresses                              1.401020e+05      49
## btc_n_transactions                                  7.874311e+04      49
## btc_n_transactions_total                            3.932131e+07   26958
## btc_n_transactions_excluding_popular                6.129143e+04      49
## btc_n_transactions_excluding_chains_longer_than_100 3.965288e+04      49
## btc_output_volume                                   1.054362e+06    2450
## btc_estimated_transaction_volume                    1.271492e+05       0
## btc_estimated_transaction_volume_usd                4.549469e+07       0
##                                                              max
## Date*                                               2.920000e+03
## btc_market_price                                    7.437540e+03
## btc_total_bitcoins                                  1.666928e+07
## btc_market_cap                                      1.239385e+11
## btc_trade_volume                                    1.267435e+09
## btc_blocks_size                                     1.402946e+05
## btc_avg_block_size                                  1.050000e+00
## btc_n_orphaned_blocks                               7.000000e+00
## btc_n_transactions_per_block                        2.436070e+03
## btc_median_confirmation_time                        4.773000e+01
## btc_hash_rate                                       1.299979e+07
## btc_difficulty                                      1.452840e+12
## btc_miners_revenue                                  1.534736e+07
## btc_transaction_fees                                6.681300e+02
## btc_cost_per_transaction_percent                    2.000000e+06
## btc_cost_per_transaction                            9.020000e+01
## btc_n_unique_addresses                              7.338780e+05
## btc_n_transactions                                  3.690980e+05
## btc_n_transactions_total                            2.694610e+08
## btc_n_transactions_excluding_popular                3.619740e+05
## btc_n_transactions_excluding_chains_longer_than_100 2.868960e+05
## btc_output_volume                                   4.599222e+07
## btc_estimated_transaction_volume                    5.825066e+06
## btc_estimated_transaction_volume_usd                2.396482e+09
##                                                            range  skew
## Date*                                               2.919000e+03  0.00
## btc_market_price                                    7.437540e+03  3.88
## btc_total_bitcoins                                  1.532983e+07 -0.59
## btc_market_cap                                      1.239385e+11  4.00
## btc_trade_volume                                    1.267435e+09  6.07
## btc_blocks_size                                     1.402946e+05  1.28
## btc_avg_block_size                                  1.050000e+00  0.81
## btc_n_orphaned_blocks                               7.000000e+00  2.80
## btc_n_transactions_per_block                        2.435070e+03  0.97
## btc_median_confirmation_time                        4.773000e+01  0.25
## btc_hash_rate                                       1.299979e+07  3.08
## btc_difficulty                                      1.452840e+12  3.01
## btc_miners_revenue                                  1.534736e+07  3.22
## btc_transaction_fees                                6.681300e+02  3.38
## btc_cost_per_transaction_percent                    2.000000e+06 32.38
## btc_cost_per_transaction                            9.020000e+01  2.08
## btc_n_unique_addresses                              7.338290e+05  0.92
## btc_n_transactions                                  3.690490e+05  0.96
## btc_n_transactions_total                            2.694340e+08  1.29
## btc_n_transactions_excluding_popular                3.619250e+05  1.01
## btc_n_transactions_excluding_chains_longer_than_100 2.868470e+05  1.19
## btc_output_volume                                   4.598977e+07  8.62
## btc_estimated_transaction_volume                    5.825066e+06 11.37
## btc_estimated_transaction_volume_usd                2.396482e+09  4.08
##                                                     kurtosis           se
## Date*                                                  -1.20 1.560000e+01
## btc_market_price                                       17.21 1.730000e+01
## btc_total_bitcoins                                     -0.83 8.247531e+04
## btc_market_cap                                         18.01 2.866323e+08
## btc_trade_volume                                       52.39 1.536635e+06
## btc_blocks_size                                         0.43 7.266600e+02
## btc_avg_block_size                                     -0.82 1.000000e-02
## btc_n_orphaned_blocks                                   8.70 2.000000e-02
## btc_n_transactions_per_block                           -0.39 1.209000e+01
## btc_median_confirmation_time                            1.25 9.000000e-02
## btc_hash_rate                                          10.22 3.330409e+04
## btc_difficulty                                          9.60 4.374902e+09
## btc_miners_revenue                                     13.10 3.699973e+04
## btc_transaction_fees                                   13.35 1.460000e+00
## btc_cost_per_transaction_percent                     1120.49 9.490500e+02
## btc_cost_per_transaction                                4.53 2.500000e-01
## btc_n_unique_addresses                                 -0.42 3.452750e+03
## btc_n_transactions                                     -0.35 1.802380e+03
## btc_n_transactions_total                                0.50 1.380483e+06
## btc_n_transactions_excluding_popular                   -0.36 1.809540e+03
## btc_n_transactions_excluding_chains_longer_than_100     0.21 1.212480e+03
## btc_output_volume                                     117.99 4.220202e+04
## btc_estimated_transaction_volume                      180.14 4.992490e+03
## btc_estimated_transaction_volume_usd                   20.83 4.446656e+06
View(BTC)
BTC$Days <- 1:nrow(BTC) #Add column that adds a count of days for each row
BTC$Date <- as.Date(BTC$Date) #Format Date as Date
BTC2 <- subset(BTC, BTC$btc_median_confirmation_time>0) #Subset of data that is clean

Historical Bitcoin Value

library(ggplot2)
## 
## Attaching package: 'ggplot2'
## The following objects are masked from 'package:psych':
## 
##     %+%, alpha
ggplot(BTC, aes(BTC$Date, BTC$btc_market_price)) + 
  geom_point(color="firebrick") +
  ggtitle('BTC Value vs. Time') +
  theme(plot.title = element_text(size=20, face="bold", 
    margin = margin(10, 0, 10, 0)))+
  labs(x="Date", y="USD")+
  theme(axis.text.x=element_text(angle=50, vjust=0.5)) +
  theme(panel.background = element_rect(fill = 'grey75'))

From the graph we can see that the value of bitcoin with respect to dollar has increased exponentially.

Correlation between variables

BTC<-na.omit(BTC)
library(corrplot)
## corrplot 0.84 loaded
cor <- cor(BTC[,2:12])
#corrplot
corrplot(cor, method = "pie")

#Bitcoin date vs market price
plot(BTC$Date, BTC$btc_market_price)

#Bitcoin market price vs market cap
mod<-lm(btc_market_price~btc_market_cap, data=BTC)
mod1<-lm(btc_market_price~btc_estimated_transaction_volume_usd, data=BTC)
summary(mod)
## 
## Call:
## lm(formula = btc_market_price ~ btc_market_cap, data = BTC)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -105.646  -29.737   -8.419    3.797  280.916 
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)    3.208e+01  9.563e-01   33.55   <2e-16 ***
## btc_market_cap 6.029e-08  5.569e-11 1082.63   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 46.59 on 2897 degrees of freedom
## Multiple R-squared:  0.9975, Adjusted R-squared:  0.9975 
## F-statistic: 1.172e+06 on 1 and 2897 DF,  p-value: < 2.2e-16
summary(mod1)
## 
## Call:
## lm(formula = btc_market_price ~ btc_estimated_transaction_volume_usd, 
##     data = BTC)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3630.5   -63.4   -59.9    20.9  3372.0 
## 
## Coefficients:
##                                       Estimate Std. Error t value Pr(>|t|)
## (Intercept)                          6.336e+01  6.940e+00   9.131   <2e-16
## btc_estimated_transaction_volume_usd 3.629e-06  2.607e-08 139.193   <2e-16
##                                         
## (Intercept)                          ***
## btc_estimated_transaction_volume_usd ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 338.4 on 2897 degrees of freedom
## Multiple R-squared:  0.8699, Adjusted R-squared:  0.8699 
## F-statistic: 1.937e+04 on 1 and 2897 DF,  p-value: < 2.2e-16
plot(BTC$btc_market_price,BTC$btc_market_cap)

plot(BTC$btc_market_price,BTC$btc_estimated_transaction_volume_usd)

Market Price Vs Miners Revenue

ggplot(BTC2, aes(BTC2$btc_miners_revenue/1000000, BTC2$btc_market_price)) + 
  geom_point(color="firebrick") +
  ggtitle('BTC Miners Revenue vs. Market Price') +
  theme(plot.title = element_text(size=19.5, face="bold", 
    margin = margin(10, 0, 10, 0)))+
  labs(x="Miners Revenue MM (USD)", y="Market Price (USD)")+
  theme(axis.text.x=element_text(angle=90, vjust=0.5)) +
  theme(panel.background = element_rect(fill = 'grey75'))+
  stat_smooth(method = "lm",  formula = y ~ poly(x,2), col = "yellow")

Difficulty vs. Market Price

ggplot(BTC2, aes(BTC2$btc_difficulty/1000000000, BTC2$btc_market_price)) + 
  geom_point(color="firebrick") +
  ggtitle('BTC Difficulty vs. Market Price') +
  theme(plot.title = element_text(size=19.5, face="bold", 
    margin = margin(10, 0, 10, 0)))+
  labs(x="Block Find Difficulty (Billions)", y="Market Price (USD)")+
  theme(axis.text.x=element_text(angle=90, vjust=0.5)) +
  theme(panel.background = element_rect(fill = 'grey75'))+
  stat_smooth(method = "lm",  formula = y ~ poly(x,2), col = "yellow")

Hash Rate vs. Market Price

ggplot(BTC2, aes(BTC2$btc_hash_rate/1000000, BTC2$btc_market_price)) + 
  geom_point(color="firebrick") +
  ggtitle('BTC Hash Rate vs. Market Price') +
  theme(plot.title = element_text(size=19.5, face="bold", 
    margin = margin(10, 0, 10, 0)))+
  labs(x="Hash Rate (Millions)", y="Market Price (USD)")+
  theme(axis.text.x=element_text(angle=90, vjust=0.5)) +
  theme(panel.background = element_rect(fill = 'grey75'))+
  stat_smooth(method = "lm",  formula = y ~ poly(x,2), col = "yellow")

Loading Library’s

library(knitr)
library(pander)
library(tidyverse)
## -- Attaching packages ---------------------------------------------------------------- tidyverse 1.2.1 --
## v tibble  1.4.1     v purrr   0.2.4
## v tidyr   0.7.2     v dplyr   0.7.4
## v readr   1.1.1     v stringr 1.2.0
## v tibble  1.4.1     v forcats 0.2.0
## -- Conflicts ------------------------------------------------------------------- tidyverse_conflicts() --
## x ggplot2::%+%()   masks psych::%+%()
## x ggplot2::alpha() masks psych::alpha()
## x dplyr::filter()  masks stats::filter()
## x dplyr::lag()     masks stats::lag()
library(broom)
library(DataCombine)
library(caret)
## Loading required package: lattice
## 
## Attaching package: 'caret'
## The following object is masked from 'package:purrr':
## 
##     lift

Summary of Regression Model

lmfit1<-lm(BTC2$btc_market_price~BTC2$btc_market_cap)
panderOptions("digits", 2)
pander(lmfit1, caption = "Linear Model: Market Price ~ Market Capitalization")
Linear Model: Market Price ~ Market Capitalization
  Estimate Std. Error t value Pr(>|t|)
(Intercept) 46 1.2 38 3.4e-241
BTC2$btc_market_cap 6e-08 6.2e-11 973 0
R1=summary(lmfit1)$r.squared
cat("R-Squared = ", R1)
## R-Squared =  0.9977156

Market Capitalization is signficant to Market Price.

Residuals

plot(lmfit1, pch=16, which=1)

##Estimated USD Transaction Volume vs. Market Price

ggplot(BTC2, aes(BTC2$btc_estimated_transaction_volume_usd/1000000, BTC2$btc_market_price)) + 
  geom_point(color="red") +
  ggtitle('BTC Transaction Volume vs. Market Price') +
  theme(plot.title = element_text(size=19.5, face="bold", 
    margin = margin(10, 0, 10, 0)))+
  labs(x="Transaction Volume MM (USD)", y="Market Price (USD)")+
  theme(axis.text.x=element_text(angle=90, vjust=0.5)) +
  theme(panel.background = element_rect(fill = 'grey75'))+
  stat_smooth(method = "lm",  formula = y ~ poly(x,2), col = "white")

lmfit2<-lm(BTC2$btc_market_price~poly(BTC2$btc_estimated_transaction_volume_usd,2))
panderOptions("digits", 2)
pander(lmfit2, caption = "Linear Model: Market Price ~ Estimated Transaction Volume (USD) Squared")
Linear Model: Market Price ~ Estimated Transaction Volume (USD) Squared (continued below)
  Estimate Std. Error
(Intercept) 635 8.1
poly(BTC2$btc_estimated_transaction_volume_usd, 2)1 44731 377
poly(BTC2$btc_estimated_transaction_volume_usd, 2)2 -4514 377
  t value Pr(>|t|)
(Intercept) 78 0
poly(BTC2$btc_estimated_transaction_volume_usd, 2)1 119 0
poly(BTC2$btc_estimated_transaction_volume_usd, 2)2 -12 4.9e-32
R2=summary(lmfit2)$r.squared
cat("R-Squared = ", R2)
## R-Squared =  0.8678923

Transaction volume is significant to market price ##Residuals

plot(lmfit2, pch=16, which=1)

the price increases the variability increases ##Regression model

lmfit7 <- lm(BTC2$btc_market_price ~ poly(BTC2$btc_estimated_transaction_volume_usd, 2) + poly(BTC2$btc_miners_revenue, degree=2))

panderOptions("digits", 2)
pander(lmfit7, caption = "Linear Model: Market Price ~ Miners Revenue Squared + Count of Transactions Squared")
Linear Model: Market Price ~ Miners Revenue Squared + Count of Transactions Squared (continued below)
  Estimate Std. Error
(Intercept) 635 4.4
poly(BTC2$btc_estimated_transaction_volume_usd, 2)1 16300 462
poly(BTC2$btc_estimated_transaction_volume_usd, 2)2 -6159 269
poly(BTC2$btc_miners_revenue, degree = 2)1 31297 463
poly(BTC2$btc_miners_revenue, degree = 2)2 6864 268
  t value Pr(>|t|)
(Intercept) 143 0
poly(BTC2$btc_estimated_transaction_volume_usd, 2)1 35 2e-215
poly(BTC2$btc_estimated_transaction_volume_usd, 2)2 -23 4.7e-104
poly(BTC2$btc_miners_revenue, degree = 2)1 68 0
poly(BTC2$btc_miners_revenue, degree = 2)2 26 2.9e-126
R7=summary(lmfit7)$r.squared
cat("R-Squared = ", R7)
## R-Squared =  0.9604765

Percentage Change

BTC<-mutate(BTC, pChange=(BTC$btc_market_price-lag(BTC$btc_market_price))/lag(BTC$btc_market_price)*100) #Add column for percentage of change

ggplot(BTC, aes(BTC$Date, BTC$pChange)) + 
  geom_point(color="firebrick") +
  ggtitle('BTC Percent Change vs. Time') +
  theme(plot.title = element_text(size=20, face="bold", 
    margin = margin(10, 0, 10, 0)))+
  labs(x="Date", y="Pct. Change")+
  theme(axis.text.x=element_text(angle=50, vjust=0.5)) +
  theme(panel.background = element_rect(fill = 'grey75'))
## Warning: Removed 280 rows containing missing values (geom_point).

##Mutate Data in Percent Change

library(zoo)
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
BTC2$AVGtransactionvolume<-BTC2$btc_estimated_transaction_volume_usd
BTC2$AVGminersrevenue<-BTC2$btc_miners_revenue
BTC2$AVGmarketcap<-BTC2$btc_market_cap
BTC2$pctChange<-BTC2$btc_market_price
BTC2$AVGtotalbitcoins<-BTC2$btc_total_bitcoins

BTC11<- subset(BTC2, BTC2$AVGminersrevenue>0)
BTC11<-mutate(BTC11, pctChange=(BTC2$btc_market_price-lag(BTC2$btc_market_price))/lag(BTC2$btc_market_price)*100)
BTC11<-mutate(BTC11, AVGtransactionvolume=(BTC2$AVGtransactionvolume-lag(BTC2$AVGtransactionvolume))/lag(BTC2$AVGtransactionvolume)*100)
BTC11<-mutate(BTC11, AVGminersrevenue=(BTC2$AVGminersrevenue-lag(BTC2$AVGminersrevenue))/lag(BTC2$AVGminersrevenue)*100)
BTC11<-mutate(BTC11, AVGmarketcap=(BTC2$AVGmarketcap-lag(BTC2$AVGmarketcap))/lag(BTC2$AVGmarketcap)*100)
BTC11<-mutate(BTC11, AVGtotalbitcoins=(BTC2$AVGtotalbitcoins-lag(BTC2$AVGtotalbitcoins))/lag(BTC2$AVGtotalbitcoins)*100)

ggplot(BTC2, aes(BTC11$Date, BTC11$pctChange)) + 
  geom_point(color="firebrick") +
  ggtitle('BTC Percent Change vs. Time') +
  theme(plot.title = element_text(size=20, face="bold", 
    margin = margin(10, 0, 10, 0)))+
  labs(x="Date", y="Pct. Change")+
  theme(axis.text.x=element_text(angle=50, vjust=0.5)) +
  theme(panel.background = element_rect(fill = 'grey75'))
## Warning: Removed 1 rows containing missing values (geom_point).

##Correlation Analysis of Transformed Variables

cor2 <- cor(BTC11[c(2:2167),c(26:30)]) #selecting variables to include in correlation analysis

colnames(cor2) <- c("% Change Transx Volume", "% Change Miner Rev.","% Change Market Cap", "% Change Market Price","Change Total Coins")
rownames(cor2) <- c("% Change Transx Volume", "% Change Miner Rev.","% Change Market Cap","% Change Market Price", "Change Total Coins")

corrplot(cor2, method = "circle",  tl.srt = 50, tl.col = "black", tl.cex = 0.6, title = "Correlation of Variables", mar=c(0,0,1,0))

##What is the significance of these variables to the percent change in market price?

lmfit8 <- lm(pctChange ~ AVGmarketcap+AVGtotalbitcoins, BTC11)

panderOptions("digits", 2)
pander(lmfit8, caption = "Linear Model: Market Price Change ~ Market Cap Change + Total Coins Change")
Linear Model: Market Price Change ~ Market Cap Change + Total Coins Change
  Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.0036 0.02 0.18 0.86
AVGmarketcap 0.99 0.0025 398 0
AVGtotalbitcoins -1 0.48 -2.1 0.037

T-Test

t.test(BTC$btc_market_price,BTC$btc_market_cap)
## 
##  Welch Two Sample t-test
## 
## data:  BTC$btc_market_price and BTC$btc_market_cap
## t = -25.345, df = 2898, p-value < 2.2e-16
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -7880838055 -6749000205
## sample estimates:
##    mean of x    mean of y 
## 4.730802e+02 7.314920e+09
t.test(BTC$btc_market_price,BTC$btc_total_bitcoins)
## 
##  Welch Two Sample t-test
## 
## data:  BTC$btc_market_price and BTC$btc_total_bitcoins
## t = -132.32, df = 2898, p-value < 2.2e-16
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -11136901 -10811658
## sample estimates:
##    mean of x    mean of y 
## 4.730802e+02 1.097475e+07
t.test(BTC$btc_miners_revenue,BTC$btc_hash_rate)
## 
##  Welch Two Sample t-test
## 
## data:  BTC$btc_miners_revenue and BTC$btc_hash_rate
## t = 8.9353, df = 5733.2, p-value < 2.2e-16
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  349500.2 545962.4
## sample estimates:
## mean of x mean of y 
## 1281695.1  833963.8
t.test(BTC$btc_difficulty,BTC$btc_market_price)
## 
##  Welch Two Sample t-test
## 
## data:  BTC$btc_difficulty and BTC$btc_market_price
## t = 25.107, df = 2898, p-value < 2.2e-16
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  101936970198 119207754485
## sample estimates:
##    mean of x    mean of y 
## 1.105724e+11 4.730802e+02

Train Model and Test Percent Change

Creating the training subset and test subset

set.seed(1)
train2.index<-sample(1:nrow(BTC11),0.90*nrow(BTC11), replace=FALSE)
train2 <- BTC11[train2.index, ]
test2  <- BTC11[-train2.index,]

Training and testing

lmtrain2 <- lm(pctChange~AVGmarketcap+AVGtotalbitcoins, train2)
test2$p1 <- predict(lmtrain2,test2)
error=mean(abs(test2$p1-test2$pctChange))
cat("Mean Error = ", error)
## Mean Error =  0.06610463

Very small amount of error.

ggplot(test2, aes(test2$Date)) + 
  geom_point(aes(y=test2$pctChange),color="Firebrick") +
  geom_line(aes(y=test2$p1), color="Blue")+
  ggtitle('') +
  theme(plot.title = element_text(size=10, face="bold", 
    margin = margin(10, 0, 10, 0)))+
  labs(x="Time", y="Percent Change in Value")+
  theme(axis.text.x=element_text(angle=90, vjust=0.5)) +
  theme(panel.background = element_rect(fill = 'grey75'))+
  labs(title = paste("BTC Market Price % Change ~ BTC Market Cap % Change + Total Coins % Change",
                     "\n\nAdj R2 = ",signif(summary(lmtrain2)$adj.r.squared, 5),
                     " P =",signif(summary(lmtrain2)$coef[2,4], 2)))

Conclusion

It’s difficult to predict the price of bitcoin due to fluctuatuion in market Shown above, percent change in the value of Bitcoin is highly dependent to the percent change in market capitalization and percent change in total bitcoins in circulation.