Last active
September 16, 2021 15:58
-
-
Save h3ik0th/4df628e1c791b545afaeef742b794fa9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# should we expect Granger causality, based on cointegration? | |
# test for cointegration using Engle-Granger | |
# null hypothesis: Tyrion and Cersei are NOT cointegrated | |
# we choose lags up to 10, the typical length of a season, during | |
# which the interested audience received news about Tyrion and Cersei; | |
score, pvalue, _ = coint(df["Tyrion"], df["Cersei"], maxlag=10) | |
pvalue | |
print(f'cointegration: score: {score:.2f}') | |
print(f'cointegration: p-value: {pvalue:.10f}') | |
print("cointegrated - there MUST be Granger causality" if pvalue < ALPHA else "NOT cointegrated (uncertain about Granger causality)") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment