ibnummuhammad
commited on
Commit
•
672c1c4
1
Parent(s):
5818f5c
Add grangers_causation_matrix()
Browse files- granger_causality_testing.ipynb +371 -2
granger_causality_testing.ipynb
CHANGED
@@ -2,20 +2,23 @@
|
|
2 |
"cells": [
|
3 |
{
|
4 |
"cell_type": "code",
|
5 |
-
"execution_count":
|
6 |
"metadata": {},
|
7 |
"outputs": [],
|
8 |
"source": [
|
|
|
9 |
"import pandas as pd\n",
|
10 |
"import plotly.express as px\n",
|
|
|
11 |
"from statsmodels.tsa.api import VAR\n",
|
12 |
"from statsmodels.tsa.stattools import adfuller\n",
|
|
|
13 |
"from statsmodels.tsa.stattools import kpss"
|
14 |
]
|
15 |
},
|
16 |
{
|
17 |
"cell_type": "code",
|
18 |
-
"execution_count":
|
19 |
"metadata": {},
|
20 |
"outputs": [],
|
21 |
"source": [
|
@@ -6934,6 +6937,372 @@
|
|
6934 |
" print('HQIC: ', result.hqic, '\\n')"
|
6935 |
]
|
6936 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6937 |
{
|
6938 |
"cell_type": "code",
|
6939 |
"execution_count": null,
|
|
|
2 |
"cells": [
|
3 |
{
|
4 |
"cell_type": "code",
|
5 |
+
"execution_count": 37,
|
6 |
"metadata": {},
|
7 |
"outputs": [],
|
8 |
"source": [
|
9 |
+
"import numpy as np\n",
|
10 |
"import pandas as pd\n",
|
11 |
"import plotly.express as px\n",
|
12 |
+
"from statsmodels.stats.stattools import durbin_watson\n",
|
13 |
"from statsmodels.tsa.api import VAR\n",
|
14 |
"from statsmodels.tsa.stattools import adfuller\n",
|
15 |
+
"from statsmodels.tsa.stattools import grangercausalitytests\n",
|
16 |
"from statsmodels.tsa.stattools import kpss"
|
17 |
]
|
18 |
},
|
19 |
{
|
20 |
"cell_type": "code",
|
21 |
+
"execution_count": 30,
|
22 |
"metadata": {},
|
23 |
"outputs": [],
|
24 |
"source": [
|
|
|
6937 |
" print('HQIC: ', result.hqic, '\\n')"
|
6938 |
]
|
6939 |
},
|
6940 |
+
{
|
6941 |
+
"cell_type": "code",
|
6942 |
+
"execution_count": 28,
|
6943 |
+
"metadata": {},
|
6944 |
+
"outputs": [
|
6945 |
+
{
|
6946 |
+
"data": {
|
6947 |
+
"text/plain": [
|
6948 |
+
" Summary of Regression Results \n",
|
6949 |
+
"==================================\n",
|
6950 |
+
"Model: VAR\n",
|
6951 |
+
"Method: OLS\n",
|
6952 |
+
"Date: Sun, 25, Feb, 2024\n",
|
6953 |
+
"Time: 21:40:09\n",
|
6954 |
+
"--------------------------------------------------------------------\n",
|
6955 |
+
"No. of Equations: 3.00000 BIC: 14.5979\n",
|
6956 |
+
"Nobs: 128.000 HQIC: 12.7724\n",
|
6957 |
+
"Log likelihood: -1144.35 FPE: 111728.\n",
|
6958 |
+
"AIC: 11.5231 Det(Omega_mle): 44477.8\n",
|
6959 |
+
"--------------------------------------------------------------------\n",
|
6960 |
+
"Results for equation apple\n",
|
6961 |
+
"==============================================================================\n",
|
6962 |
+
" coefficient std. error t-stat prob\n",
|
6963 |
+
"------------------------------------------------------------------------------\n",
|
6964 |
+
"const -0.699238 0.584786 -1.196 0.232\n",
|
6965 |
+
"L1.apple 0.014847 0.140038 0.106 0.916\n",
|
6966 |
+
"L1.walmart -0.113138 0.105005 -1.077 0.281\n",
|
6967 |
+
"L1.tesla 0.081087 0.038983 2.080 0.038\n",
|
6968 |
+
"L2.apple -0.167780 0.135627 -1.237 0.216\n",
|
6969 |
+
"L2.walmart -0.031901 0.104304 -0.306 0.760\n",
|
6970 |
+
"L2.tesla 0.109001 0.039080 2.789 0.005\n",
|
6971 |
+
"L3.apple 0.085712 0.136509 0.628 0.530\n",
|
6972 |
+
"L3.walmart 0.157405 0.102108 1.542 0.123\n",
|
6973 |
+
"L3.tesla -0.081028 0.038433 -2.108 0.035\n",
|
6974 |
+
"L4.apple -0.440097 0.112933 -3.897 0.000\n",
|
6975 |
+
"L4.walmart -0.028011 0.102538 -0.273 0.785\n",
|
6976 |
+
"L4.tesla 0.196295 0.038369 5.116 0.000\n",
|
6977 |
+
"L5.apple 0.187708 0.125176 1.500 0.134\n",
|
6978 |
+
"L5.walmart -0.059267 0.102669 -0.577 0.564\n",
|
6979 |
+
"L5.tesla -0.089774 0.042168 -2.129 0.033\n",
|
6980 |
+
"L6.apple -0.021143 0.124388 -0.170 0.865\n",
|
6981 |
+
"L6.walmart -0.236903 0.105059 -2.255 0.024\n",
|
6982 |
+
"L6.tesla 0.021333 0.040789 0.523 0.601\n",
|
6983 |
+
"L7.apple 0.034935 0.121061 0.289 0.773\n",
|
6984 |
+
"L7.walmart -0.196441 0.105540 -1.861 0.063\n",
|
6985 |
+
"L7.tesla 0.124142 0.039365 3.154 0.002\n",
|
6986 |
+
"L8.apple 0.263352 0.114911 2.292 0.022\n",
|
6987 |
+
"L8.walmart 0.124926 0.105791 1.181 0.238\n",
|
6988 |
+
"L8.tesla -0.064692 0.037117 -1.743 0.081\n",
|
6989 |
+
"L9.apple -0.161093 0.118119 -1.364 0.173\n",
|
6990 |
+
"L9.walmart 0.142378 0.105329 1.352 0.176\n",
|
6991 |
+
"L9.tesla -0.003729 0.036768 -0.101 0.919\n",
|
6992 |
+
"L10.apple 0.052834 0.118872 0.444 0.657\n",
|
6993 |
+
"L10.walmart -0.012512 0.106188 -0.118 0.906\n",
|
6994 |
+
"L10.tesla 0.014551 0.036445 0.399 0.690\n",
|
6995 |
+
"L11.apple -0.196153 0.120203 -1.632 0.103\n",
|
6996 |
+
"L11.walmart -0.189079 0.103137 -1.833 0.067\n",
|
6997 |
+
"L11.tesla 0.046769 0.033933 1.378 0.168\n",
|
6998 |
+
"L12.apple 0.281041 0.113450 2.477 0.013\n",
|
6999 |
+
"L12.walmart 0.248444 0.097517 2.548 0.011\n",
|
7000 |
+
"L12.tesla -0.131892 0.034494 -3.824 0.000\n",
|
7001 |
+
"L13.apple -0.033669 0.107860 -0.312 0.755\n",
|
7002 |
+
"L13.walmart 0.034415 0.101916 0.338 0.736\n",
|
7003 |
+
"L13.tesla -0.018055 0.036536 -0.494 0.621\n",
|
7004 |
+
"L14.apple -0.255695 0.103146 -2.479 0.013\n",
|
7005 |
+
"L14.walmart 0.139620 0.095459 1.463 0.144\n",
|
7006 |
+
"L14.tesla 0.100374 0.036446 2.754 0.006\n",
|
7007 |
+
"L15.apple 0.196757 0.104793 1.878 0.060\n",
|
7008 |
+
"L15.walmart 0.017978 0.097782 0.184 0.854\n",
|
7009 |
+
"L15.tesla -0.030502 0.036230 -0.842 0.400\n",
|
7010 |
+
"==============================================================================\n",
|
7011 |
+
"\n",
|
7012 |
+
"Results for equation walmart\n",
|
7013 |
+
"==============================================================================\n",
|
7014 |
+
" coefficient std. error t-stat prob\n",
|
7015 |
+
"------------------------------------------------------------------------------\n",
|
7016 |
+
"const -0.103331 0.633837 -0.163 0.870\n",
|
7017 |
+
"L1.apple 0.144375 0.151784 0.951 0.342\n",
|
7018 |
+
"L1.walmart -0.076127 0.113813 -0.669 0.504\n",
|
7019 |
+
"L1.tesla -0.048764 0.042252 -1.154 0.248\n",
|
7020 |
+
"L2.apple -0.125694 0.147003 -0.855 0.393\n",
|
7021 |
+
"L2.walmart -0.017047 0.113053 -0.151 0.880\n",
|
7022 |
+
"L2.tesla -0.008949 0.042358 -0.211 0.833\n",
|
7023 |
+
"L3.apple 0.162286 0.147959 1.097 0.273\n",
|
7024 |
+
"L3.walmart -0.060079 0.110672 -0.543 0.587\n",
|
7025 |
+
"L3.tesla 0.031460 0.041656 0.755 0.450\n",
|
7026 |
+
"L4.apple 0.080359 0.122405 0.657 0.512\n",
|
7027 |
+
"L4.walmart -0.068210 0.111139 -0.614 0.539\n",
|
7028 |
+
"L4.tesla 0.023108 0.041587 0.556 0.578\n",
|
7029 |
+
"L5.apple 0.025574 0.135675 0.188 0.850\n",
|
7030 |
+
"L5.walmart -0.232336 0.111281 -2.088 0.037\n",
|
7031 |
+
"L5.tesla 0.020971 0.045705 0.459 0.646\n",
|
7032 |
+
"L6.apple -0.201452 0.134822 -1.494 0.135\n",
|
7033 |
+
"L6.walmart -0.134846 0.113871 -1.184 0.236\n",
|
7034 |
+
"L6.tesla 0.068019 0.044210 1.539 0.124\n",
|
7035 |
+
"L7.apple 0.186968 0.131215 1.425 0.154\n",
|
7036 |
+
"L7.walmart -0.110714 0.114393 -0.968 0.333\n",
|
7037 |
+
"L7.tesla -0.016329 0.042667 -0.383 0.702\n",
|
7038 |
+
"L8.apple 0.175006 0.124550 1.405 0.160\n",
|
7039 |
+
"L8.walmart -0.016260 0.114665 -0.142 0.887\n",
|
7040 |
+
"L8.tesla -0.072481 0.040230 -1.802 0.072\n",
|
7041 |
+
"L9.apple 0.198956 0.128027 1.554 0.120\n",
|
7042 |
+
"L9.walmart -0.084669 0.114164 -0.742 0.458\n",
|
7043 |
+
"L9.tesla -0.004090 0.039852 -0.103 0.918\n",
|
7044 |
+
"L10.apple -0.091041 0.128843 -0.707 0.480\n",
|
7045 |
+
"L10.walmart 0.052878 0.115095 0.459 0.646\n",
|
7046 |
+
"L10.tesla -0.003499 0.039502 -0.089 0.929\n",
|
7047 |
+
"L11.apple -0.212327 0.130285 -1.630 0.103\n",
|
7048 |
+
"L11.walmart -0.065408 0.111788 -0.585 0.558\n",
|
7049 |
+
"L11.tesla 0.070514 0.036780 1.917 0.055\n",
|
7050 |
+
"L12.apple 0.341238 0.122966 2.775 0.006\n",
|
7051 |
+
"L12.walmart -0.128880 0.105697 -1.219 0.223\n",
|
7052 |
+
"L12.tesla -0.035130 0.037387 -0.940 0.347\n",
|
7053 |
+
"L13.apple -0.009063 0.116907 -0.078 0.938\n",
|
7054 |
+
"L13.walmart 0.138496 0.110464 1.254 0.210\n",
|
7055 |
+
"L13.tesla -0.016126 0.039601 -0.407 0.684\n",
|
7056 |
+
"L14.apple 0.050583 0.111798 0.452 0.651\n",
|
7057 |
+
"L14.walmart 0.123218 0.103466 1.191 0.234\n",
|
7058 |
+
"L14.tesla 0.005768 0.039503 0.146 0.884\n",
|
7059 |
+
"L15.apple 0.153644 0.113583 1.353 0.176\n",
|
7060 |
+
"L15.walmart -0.039947 0.105984 -0.377 0.706\n",
|
7061 |
+
"L15.tesla -0.054155 0.039269 -1.379 0.168\n",
|
7062 |
+
"==============================================================================\n",
|
7063 |
+
"\n",
|
7064 |
+
"Results for equation tesla\n",
|
7065 |
+
"==============================================================================\n",
|
7066 |
+
" coefficient std. error t-stat prob\n",
|
7067 |
+
"------------------------------------------------------------------------------\n",
|
7068 |
+
"const -2.063049 1.878392 -1.098 0.272\n",
|
7069 |
+
"L1.apple -0.171895 0.449815 -0.382 0.702\n",
|
7070 |
+
"L1.walmart -0.105253 0.337288 -0.312 0.755\n",
|
7071 |
+
"L1.tesla 0.190132 0.125216 1.518 0.129\n",
|
7072 |
+
"L2.apple -0.046830 0.435648 -0.107 0.914\n",
|
7073 |
+
"L2.walmart -0.125800 0.335034 -0.375 0.707\n",
|
7074 |
+
"L2.tesla 0.315252 0.125529 2.511 0.012\n",
|
7075 |
+
"L3.apple 0.806135 0.438482 1.838 0.066\n",
|
7076 |
+
"L3.walmart -0.279177 0.327980 -0.851 0.395\n",
|
7077 |
+
"L3.tesla -0.426441 0.123450 -3.454 0.001\n",
|
7078 |
+
"L4.apple -0.685840 0.362751 -1.891 0.059\n",
|
7079 |
+
"L4.walmart 0.055336 0.329363 0.168 0.867\n",
|
7080 |
+
"L4.tesla 0.397299 0.123244 3.224 0.001\n",
|
7081 |
+
"L5.apple 0.071231 0.402077 0.177 0.859\n",
|
7082 |
+
"L5.walmart -0.108462 0.329783 -0.329 0.742\n",
|
7083 |
+
"L5.tesla -0.050922 0.135447 -0.376 0.707\n",
|
7084 |
+
"L6.apple -0.389905 0.399548 -0.976 0.329\n",
|
7085 |
+
"L6.walmart -0.362135 0.337460 -1.073 0.283\n",
|
7086 |
+
"L6.tesla -0.029577 0.131017 -0.226 0.821\n",
|
7087 |
+
"L7.apple 0.402571 0.388859 1.035 0.301\n",
|
7088 |
+
"L7.walmart -0.773885 0.339006 -2.283 0.022\n",
|
7089 |
+
"L7.tesla 0.070900 0.126445 0.561 0.575\n",
|
7090 |
+
"L8.apple 0.057018 0.369107 0.154 0.877\n",
|
7091 |
+
"L8.walmart -0.253383 0.339812 -0.746 0.456\n",
|
7092 |
+
"L8.tesla -0.060940 0.119222 -0.511 0.609\n",
|
7093 |
+
"L9.apple -0.814436 0.379410 -2.147 0.032\n",
|
7094 |
+
"L9.walmart 0.692883 0.338329 2.048 0.041\n",
|
7095 |
+
"L9.tesla 0.170148 0.118103 1.441 0.150\n",
|
7096 |
+
"L10.apple 0.165284 0.381830 0.433 0.665\n",
|
7097 |
+
"L10.walmart -0.070246 0.341086 -0.206 0.837\n",
|
7098 |
+
"L10.tesla 0.111133 0.117065 0.949 0.342\n",
|
7099 |
+
"L11.apple -0.257494 0.386104 -0.667 0.505\n",
|
7100 |
+
"L11.walmart -0.834862 0.331288 -2.520 0.012\n",
|
7101 |
+
"L11.tesla 0.318169 0.108998 2.919 0.004\n",
|
7102 |
+
"L12.apple 1.048785 0.364413 2.878 0.004\n",
|
7103 |
+
"L12.walmart 0.390809 0.313235 1.248 0.212\n",
|
7104 |
+
"L12.tesla -0.268612 0.110798 -2.424 0.015\n",
|
7105 |
+
"L13.apple -0.201846 0.346456 -0.583 0.560\n",
|
7106 |
+
"L13.walmart 0.385814 0.327363 1.179 0.239\n",
|
7107 |
+
"L13.tesla -0.250162 0.117359 -2.132 0.033\n",
|
7108 |
+
"L14.apple -0.934654 0.331317 -2.821 0.005\n",
|
7109 |
+
"L14.walmart -0.212581 0.306624 -0.693 0.488\n",
|
7110 |
+
"L14.tesla 0.296885 0.117067 2.536 0.011\n",
|
7111 |
+
"L15.apple 1.015922 0.336607 3.018 0.003\n",
|
7112 |
+
"L15.walmart -0.438696 0.314087 -1.397 0.162\n",
|
7113 |
+
"L15.tesla -0.205261 0.116373 -1.764 0.078\n",
|
7114 |
+
"==============================================================================\n",
|
7115 |
+
"\n",
|
7116 |
+
"Correlation matrix of residuals\n",
|
7117 |
+
" apple walmart tesla\n",
|
7118 |
+
"apple 1.000000 0.281952 0.608528\n",
|
7119 |
+
"walmart 0.281952 1.000000 0.187816\n",
|
7120 |
+
"tesla 0.608528 0.187816 1.000000\n",
|
7121 |
+
"\n"
|
7122 |
+
]
|
7123 |
+
},
|
7124 |
+
"execution_count": 28,
|
7125 |
+
"metadata": {},
|
7126 |
+
"output_type": "execute_result"
|
7127 |
+
}
|
7128 |
+
],
|
7129 |
+
"source": [
|
7130 |
+
"results = model.fit(maxlags=15, ic='aic')\n",
|
7131 |
+
"results.summary()"
|
7132 |
+
]
|
7133 |
+
},
|
7134 |
+
{
|
7135 |
+
"cell_type": "code",
|
7136 |
+
"execution_count": 31,
|
7137 |
+
"metadata": {},
|
7138 |
+
"outputs": [],
|
7139 |
+
"source": [
|
7140 |
+
"out = durbin_watson(results.resid)"
|
7141 |
+
]
|
7142 |
+
},
|
7143 |
+
{
|
7144 |
+
"cell_type": "code",
|
7145 |
+
"execution_count": 32,
|
7146 |
+
"metadata": {},
|
7147 |
+
"outputs": [
|
7148 |
+
{
|
7149 |
+
"name": "stdout",
|
7150 |
+
"output_type": "stream",
|
7151 |
+
"text": [
|
7152 |
+
"apple : 2.12\n",
|
7153 |
+
"walmart : 1.9\n",
|
7154 |
+
"tesla : 2.13\n"
|
7155 |
+
]
|
7156 |
+
}
|
7157 |
+
],
|
7158 |
+
"source": [
|
7159 |
+
"for col, val in zip(df.columns, out):\n",
|
7160 |
+
" print(col, ':', round(val, 2))"
|
7161 |
+
]
|
7162 |
+
},
|
7163 |
+
{
|
7164 |
+
"cell_type": "code",
|
7165 |
+
"execution_count": 34,
|
7166 |
+
"metadata": {},
|
7167 |
+
"outputs": [],
|
7168 |
+
"source": [
|
7169 |
+
"maxlag=15\n",
|
7170 |
+
"test = 'ssr_chi2test'"
|
7171 |
+
]
|
7172 |
+
},
|
7173 |
+
{
|
7174 |
+
"cell_type": "code",
|
7175 |
+
"execution_count": 35,
|
7176 |
+
"metadata": {},
|
7177 |
+
"outputs": [],
|
7178 |
+
"source": [
|
7179 |
+
"def grangers_causation_matrix(data, variables, test='ssr_chi2test', verbose=False): \n",
|
7180 |
+
" \n",
|
7181 |
+
" df = pd.DataFrame(np.zeros((len(variables), len(variables))), columns=variables, index=variables)\n",
|
7182 |
+
" for c in df.columns:\n",
|
7183 |
+
" for r in df.index:\n",
|
7184 |
+
" test_result = grangercausalitytests(data[[r, c]], maxlag=maxlag, verbose=False)\n",
|
7185 |
+
" p_values = [round(test_result[i+1][0][test][1],4) for i in range(maxlag)]\n",
|
7186 |
+
" if verbose: print(f'Y = {r}, X = {c}, P Values = {p_values}')\n",
|
7187 |
+
" min_p_value = np.min(p_values)\n",
|
7188 |
+
" df.loc[r, c] = min_p_value\n",
|
7189 |
+
" df.columns = [var + '_x' for var in variables]\n",
|
7190 |
+
" df.index = [var + '_y' for var in variables]\n",
|
7191 |
+
" return df"
|
7192 |
+
]
|
7193 |
+
},
|
7194 |
+
{
|
7195 |
+
"cell_type": "code",
|
7196 |
+
"execution_count": 38,
|
7197 |
+
"metadata": {},
|
7198 |
+
"outputs": [
|
7199 |
+
{
|
7200 |
+
"name": "stderr",
|
7201 |
+
"output_type": "stream",
|
7202 |
+
"text": [
|
7203 |
+
"/home/ibnu/miniconda3/envs/py312/lib/python3.12/site-packages/statsmodels/tsa/stattools.py:1545: FutureWarning:\n",
|
7204 |
+
"\n",
|
7205 |
+
"verbose is deprecated since functions should not print results\n",
|
7206 |
+
"\n",
|
7207 |
+
"/home/ibnu/miniconda3/envs/py312/lib/python3.12/site-packages/statsmodels/tsa/stattools.py:1545: FutureWarning:\n",
|
7208 |
+
"\n",
|
7209 |
+
"verbose is deprecated since functions should not print results\n",
|
7210 |
+
"\n",
|
7211 |
+
"/home/ibnu/miniconda3/envs/py312/lib/python3.12/site-packages/statsmodels/tsa/stattools.py:1545: FutureWarning:\n",
|
7212 |
+
"\n",
|
7213 |
+
"verbose is deprecated since functions should not print results\n",
|
7214 |
+
"\n",
|
7215 |
+
"/home/ibnu/miniconda3/envs/py312/lib/python3.12/site-packages/statsmodels/tsa/stattools.py:1545: FutureWarning:\n",
|
7216 |
+
"\n",
|
7217 |
+
"verbose is deprecated since functions should not print results\n",
|
7218 |
+
"\n",
|
7219 |
+
"/home/ibnu/miniconda3/envs/py312/lib/python3.12/site-packages/statsmodels/tsa/stattools.py:1545: FutureWarning:\n",
|
7220 |
+
"\n",
|
7221 |
+
"verbose is deprecated since functions should not print results\n",
|
7222 |
+
"\n",
|
7223 |
+
"/home/ibnu/miniconda3/envs/py312/lib/python3.12/site-packages/statsmodels/tsa/stattools.py:1545: FutureWarning:\n",
|
7224 |
+
"\n",
|
7225 |
+
"verbose is deprecated since functions should not print results\n",
|
7226 |
+
"\n",
|
7227 |
+
"/home/ibnu/miniconda3/envs/py312/lib/python3.12/site-packages/statsmodels/tsa/stattools.py:1545: FutureWarning:\n",
|
7228 |
+
"\n",
|
7229 |
+
"verbose is deprecated since functions should not print results\n",
|
7230 |
+
"\n",
|
7231 |
+
"/home/ibnu/miniconda3/envs/py312/lib/python3.12/site-packages/statsmodels/tsa/stattools.py:1545: FutureWarning:\n",
|
7232 |
+
"\n",
|
7233 |
+
"verbose is deprecated since functions should not print results\n",
|
7234 |
+
"\n",
|
7235 |
+
"/home/ibnu/miniconda3/envs/py312/lib/python3.12/site-packages/statsmodels/tsa/stattools.py:1545: FutureWarning:\n",
|
7236 |
+
"\n",
|
7237 |
+
"verbose is deprecated since functions should not print results\n",
|
7238 |
+
"\n"
|
7239 |
+
]
|
7240 |
+
},
|
7241 |
+
{
|
7242 |
+
"data": {
|
7243 |
+
"text/html": [
|
7244 |
+
"<div>\n",
|
7245 |
+
"<style scoped>\n",
|
7246 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
7247 |
+
" vertical-align: middle;\n",
|
7248 |
+
" }\n",
|
7249 |
+
"\n",
|
7250 |
+
" .dataframe tbody tr th {\n",
|
7251 |
+
" vertical-align: top;\n",
|
7252 |
+
" }\n",
|
7253 |
+
"\n",
|
7254 |
+
" .dataframe thead th {\n",
|
7255 |
+
" text-align: right;\n",
|
7256 |
+
" }\n",
|
7257 |
+
"</style>\n",
|
7258 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
7259 |
+
" <thead>\n",
|
7260 |
+
" <tr style=\"text-align: right;\">\n",
|
7261 |
+
" <th></th>\n",
|
7262 |
+
" <th>apple_x</th>\n",
|
7263 |
+
" <th>walmart_x</th>\n",
|
7264 |
+
" <th>tesla_x</th>\n",
|
7265 |
+
" </tr>\n",
|
7266 |
+
" </thead>\n",
|
7267 |
+
" <tbody>\n",
|
7268 |
+
" <tr>\n",
|
7269 |
+
" <th>apple_y</th>\n",
|
7270 |
+
" <td>1.0</td>\n",
|
7271 |
+
" <td>0.0003</td>\n",
|
7272 |
+
" <td>0.0</td>\n",
|
7273 |
+
" </tr>\n",
|
7274 |
+
" <tr>\n",
|
7275 |
+
" <th>walmart_y</th>\n",
|
7276 |
+
" <td>0.0</td>\n",
|
7277 |
+
" <td>1.0000</td>\n",
|
7278 |
+
" <td>0.0</td>\n",
|
7279 |
+
" </tr>\n",
|
7280 |
+
" <tr>\n",
|
7281 |
+
" <th>tesla_y</th>\n",
|
7282 |
+
" <td>0.0</td>\n",
|
7283 |
+
" <td>0.0000</td>\n",
|
7284 |
+
" <td>1.0</td>\n",
|
7285 |
+
" </tr>\n",
|
7286 |
+
" </tbody>\n",
|
7287 |
+
"</table>\n",
|
7288 |
+
"</div>"
|
7289 |
+
],
|
7290 |
+
"text/plain": [
|
7291 |
+
" apple_x walmart_x tesla_x\n",
|
7292 |
+
"apple_y 1.0 0.0003 0.0\n",
|
7293 |
+
"walmart_y 0.0 1.0000 0.0\n",
|
7294 |
+
"tesla_y 0.0 0.0000 1.0"
|
7295 |
+
]
|
7296 |
+
},
|
7297 |
+
"execution_count": 38,
|
7298 |
+
"metadata": {},
|
7299 |
+
"output_type": "execute_result"
|
7300 |
+
}
|
7301 |
+
],
|
7302 |
+
"source": [
|
7303 |
+
"grangers_causation_matrix(df_train_transformed, variables = df_train_transformed.columns)"
|
7304 |
+
]
|
7305 |
+
},
|
7306 |
{
|
7307 |
"cell_type": "code",
|
7308 |
"execution_count": null,
|