Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read test results if I am using Johansen Test to determine correlation between two time series in python?

I am trying to fit Vector Auto Regression Model using 2 time series.I need to perform cointegration test before applying VAR to check whether two Time series are related or not.I was able to successfully implement Johansen test,but couldn't read the test results. The answer I am searching is whether the results show correlation between the two time series or not.

I am already familiar with Augmented Dicky Fuller test and I know how to deduce stationarity for a univariate Time series using Test statistic and critical values

Following code gives eigen value.

from statsmodels.tsa.vector_ar.vecm import coint_johansen
coint_johansen(train_model_mul,-1,1).eig

>>>array([0.09947583, 0.00235395])

Following code gives critical values(90,95,99) for trace statistic.

coint_johansen(train_model_mul,-1,1).cvt
>>>array([[10.4741, 12.3212, 16.364 ],
       [ 2.9762,  4.1296,  6.9406]])

Following code gives trace statistic values.

coint_johansen(train_model_mul,-1,1).lr1
>>>array([83.2438963 ,  1.83117555])
like image 903
Aditya Mahajan Avatar asked Oct 16 '25 02:10

Aditya Mahajan


1 Answers

One way you could approach this is to use coint.test() in statsmodels.

As an example, consider that we are seeking to determine whether cointegration exists between oil price movements and the S&P 500 index. The Engle-Granger test for cointegration (with the null hypothesis of no cointegration present) is run:

import statsmodels.tsa.stattools as ts 
result=ts.coint(oil, gspc)
result

The result is as follows:

(-2.2598677154038014,
 0.3937399201683496,
 array([-3.91847791, -3.34837749, -3.05294328]))

As we can see, a p-value of 0.39 > 0.05 means that the null hypothesis of no cointegration cannot be rejected at the 5% level of significance.

You could try Engle-Granger with your data and see what the reading is - it might prove to be more simplistic.

like image 161
Michael Grogan Avatar answered Oct 18 '25 16:10

Michael Grogan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!