Added some R code for elas anaysis

This commit is contained in:
alex 2022-10-26 22:05:43 -06:00
parent 347852b6d3
commit 1550901784
5 changed files with 8801 additions and 0 deletions

View File

@ -40,6 +40,7 @@
\input{./Sections/Mining_Structure.tex}
\input{./Sections/Mining_Model.tex}
\input{./Sections/Mining_elast.tex}
\input{./Sections/Reg_elas.tex}
\section{Theory}
\section{History}
%\subsection{Key Events}

File diff suppressed because it is too large Load Diff

30
Bitcoin/Hash/R-analysis.r Normal file
View 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)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,11 @@
%------------------------------------------------
\begin{frame}{Elasticity Estimates}
Place Holder
\\
Regresion Equation
\\
Regresion Table
\end{frame}