Added some R code for elas anaysis
This commit is contained in:
parent
347852b6d3
commit
1550901784
@ -40,6 +40,7 @@
|
|||||||
\input{./Sections/Mining_Structure.tex}
|
\input{./Sections/Mining_Structure.tex}
|
||||||
\input{./Sections/Mining_Model.tex}
|
\input{./Sections/Mining_Model.tex}
|
||||||
\input{./Sections/Mining_elast.tex}
|
\input{./Sections/Mining_elast.tex}
|
||||||
|
\input{./Sections/Reg_elas.tex}
|
||||||
\section{Theory}
|
\section{Theory}
|
||||||
\section{History}
|
\section{History}
|
||||||
%\subsection{Key Events}
|
%\subsection{Key Events}
|
||||||
|
|||||||
5045
Bitcoin/Hash/BCHAIN-HRATE.csv
Normal file
5045
Bitcoin/Hash/BCHAIN-HRATE.csv
Normal file
File diff suppressed because it is too large
Load Diff
30
Bitcoin/Hash/R-analysis.r
Normal file
30
Bitcoin/Hash/R-analysis.r
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
library(tidyverse)
|
||||||
|
library(lubridate)
|
||||||
|
library(tidyquant)
|
||||||
|
|
||||||
|
BTC <- tq_get("BTC-USD")
|
||||||
|
hash <- read_csv("BCHAIN-HRATE.csv") %>% rename(date=Date,hash=Value)
|
||||||
|
df <- hash %>% inner_join(BTC)
|
||||||
|
df$hash_dif <- c(NA,diff(df$hash))
|
||||||
|
df$hash_dif <- ifelse(df$hash_dif==0,0.0001,df$hash_dif)
|
||||||
|
df <- df %>% mutate(p_dif = close-open)
|
||||||
|
df$p <- (df$close+df$open)/2
|
||||||
|
df$p_dif <- ifelse(df$p_dif==0,0.0001,df$p_dif)
|
||||||
|
df$p_dif2 <- c(NA,diff(df$p))
|
||||||
|
df$down <- ifelse(0>df$p_dif2,1,0)
|
||||||
|
#lag_dis <- 30*12
|
||||||
|
df <- df %>% arrange(date)
|
||||||
|
lag_dis <- 90
|
||||||
|
df$pw <- df$p-lag(df$p,lag_dis)
|
||||||
|
df$pw <- ifelse(df$pw==0,0.0001,df$pw)
|
||||||
|
df$down <- ifelse(df$pw<0,1,0)
|
||||||
|
df$hw <- df$hash-lag(df$hash,lag_dis)
|
||||||
|
df$hw <- ifelse(df$hw==0,0.0001,df$hw)
|
||||||
|
|
||||||
|
model1 <- (lm(log(hw)~as.factor(year(date))+as.factor(month(date))+lag(log(hash),30)+log(pw),data=df))
|
||||||
|
model1 <- (lm(log(hw)~as.factor(year(date))+as.factor(month(date))+log(pw),data=filter(df,year(df$date)>2012)))
|
||||||
|
summary(model1)
|
||||||
|
pacf(model1$resid)
|
||||||
|
acf(model1$resid)
|
||||||
|
plot(model1$resid)
|
||||||
|
|
||||||
3714
Bitcoin/Hash/bitcoin_2012-08-26_2022-10-26.csv
Normal file
3714
Bitcoin/Hash/bitcoin_2012-08-26_2022-10-26.csv
Normal file
File diff suppressed because it is too large
Load Diff
11
Bitcoin/Sections/Reg_elas.tex
Normal file
11
Bitcoin/Sections/Reg_elas.tex
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
%------------------------------------------------
|
||||||
|
\begin{frame}{Elasticity Estimates}
|
||||||
|
|
||||||
|
Place Holder
|
||||||
|
\\
|
||||||
|
Regresion Equation
|
||||||
|
\\
|
||||||
|
Regresion Table
|
||||||
|
|
||||||
|
\end{frame}
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user