<jupyter_start><jupyter_text>Data Preparation Story Background: https://www.gemini.com/cryptopedia/the-dao-hack-makerdaoEvent: July 20, 2016, at block 192,000 [Data Metrics](https://github.com/coinmetrics-io/data/blob/master/csv/metrics.csv)<jupyter_code>import pandas as pd
import numpy as np<jupyter_output><empty_output><jupyter_text>import the data for Ethereum<jupyter_code>df_eth=pd.read_csv("https://raw.githubusercontent.com/coinmetrics-io/data/master/csv/eth.csv")
df_eth.head()
df_eth['time']=pd.to_datetime(df_eth['time'])
df_eth.dtypes
df_eth['Type'] = 'eth'
df_eth.head()<jupyter_output><empty_output><jupyter_text>Import the Data for Ethereum Classic<jupyter_code>df_etc=pd.read_csv("https://raw.githubusercontent.com/coinmetrics-io/data/master/csv/etc.csv")
df_etc.head()
### change to dateime
df_etc['time']=pd.to_datetime(df_etc['time'])
df_etc.dtypes
df_etc['Type'] = 'etc'
df_etc.head()<jupyter_output><empty_output><jupyter_text>Regression Discontinguity https://youtu.be/TfKwgGT2fSM  create the identifier varaible for Dao Hack<jupyter_code>from datetime import date
df_eth ['After_DaoHack'] =df_eth['time'].apply(lambda x: 1 if x>= date(2016,7,20) else 0)
df_eth[df_eth.time.dt.date>=date(2016,7,18)].head()
df_eth['days']=df_eth.index
df_eth.head()<jupyter_output><empty_output><jupyter_text>normalize the data<jupyter_code>df_eth['days'][df_eth.time.dt.date==date(2016,7,20)]
df_eth['days']=df_eth['days']-356
df_eth[df_eth.time.dt.date>=date(2016,7,18)].head()<jupyter_output><empty_output><jupyter_text>create the regression function https://www.statsmodels.org/stable/index.html<jupyter_code>import statsmodels.api as sm
 import statsmodels.formula.api as smf
results = smf.ols('PriceUSD ~ 1+ After_DaoHack +days+TxTfrValAdjUSD ', data=df_eth).fit()
print(results.summary())
results = smf.ols('PriceUSD ~ 1+ After_DaoHack + days +After_DaoHack*days +TxTfrValAdjUSD', data=df_eth).fit()
print(results.summary())<jupyter_output>OLS Regression Results                            
==============================================================================
Dep. Variable:               PriceUSD   R-squared:                       0.703
Model:                            OLS   Adj. R-squared:                  0.702
Method:                 Least Squares   F-statistic:                     1262.
Date:                Tue, 15 Jun 2021   Prob (F-statistic):               0.00
Time:                        14:51:30   Log-Likelihood:                -15327.
No. Observations:                2138   AIC:                         3.066e+04
Df Residuals:                    2133   BIC:                         3.069e+04
Df Model:                           4                                         
Covariance Type:            nonrobust                                         
======================================================================================
                         coef    std err    [...]<jupyter_text>Difference in Difference https://towardsdatascience.com/causal-inference-101-difference-in-differences-1fbbb0f55e85  prepare the datasets<jupyter_code>Columns =["time","PriceUSD","TxTfrValAdjUSD","FeeMedUSD","RevUSD","GasLmtTxMean","Type"]
df_eth =df_eth[Columns]
df_etc =df_etc[Columns]
df_etc =df_etc.dropna()
df_etc.head()
df_eth =df_eth[df_eth.time.dt.date>=date(2016,7,25)]
df_etc =df_etc[df_etc.time.dt.date>=date(2016,7,25)]
df_eth=df_eth.reset_index()
df_etc=df_etc.reset_index()
df_eth["days"]=df_eth.index
df_eth.head()
df_etc["days"]=df_etc.index
df_etc.head()
df = pd.concat([df_eth, df_etc], axis=0)
df.head()
df["etc"]=df["Type"].apply(lambda x: 1 if x=="etc" else 0)
df.head()<jupyter_output><empty_output><jupyter_text>run the regressionTreatment: ETC hard-fork<jupyter_code>import statsmodels.api as sm
 import statsmodels.formula.api as smf
results = smf.ols('PriceUSD ~ 1+ etc +days+TxTfrValAdjUSD+FeeMedUSD+RevUSD+GasLmtTxMean', data=df).fit()
print(results.summary())
results = smf.ols('PriceUSD ~ 1+ etc +days +etc*days+TxTfrValAdjUSD+FeeMedUSD+RevUSD+GasLmtTxMean', data=df).fit()
print(results.summary())<jupyter_output>OLS Regression Results                            
==============================================================================
Dep. Variable:               PriceUSD   R-squared:                       0.978
Model:                            OLS   Adj. R-squared:                  0.978
Method:                 Least Squares   F-statistic:                 2.260e+04
Date:                Tue, 15 Jun 2021   Prob (F-statistic):               0.00
Time:                        14:59:42   Log-Likelihood:                -20294.
No. Observations:                3572   AIC:                         4.060e+04
Df Residuals:                    3564   BIC:                         4.065e+04
Df Model:                           7                                         
Covariance Type:            nonrobust                                         
==================================================================================
                     coef    std err          t [...]
{'fraction_non_alphanumeric': 0.18124383020730503, 'fraction_numerical': 0.03632773938795657, 'mean_word_length': 2.7277409860191315, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 36, 'https://': 7, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '489612', 'license': 'MIT', 'n_tokens_mistral': 1805, 'n_tokens_neox': 1601, 'n_words': 261, 'path': 'Economics_Milestone5_Causal_ipynb.ipynb', 'repo_name': 'duke-sunshine/NYU_Econometrics_Summer2021', 'size': '5065'}