Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Johansen cointegration test in python

I can't find any reference on funcionality to perform Johansen cointegration test in any Python module dealing eith statistics and time series analysis (pandas and statsmodel). Does anybpdy know if there's some code around that can perform such a test for cointegration among time series? Thanks for your help,

Maruizio

like image 817
mspadaccino Avatar asked Aug 29 '12 21:08

mspadaccino


People also ask

What is Johansen cointegration test?

Cointegration > Johansen's test is a way to determine if three or more time series are cointegrated. More specifically, it assesses the validity of a cointegrating relationship, using a maximum likelihood estimates (MLE) approach.

How do you test for cointegration?

Methods of Testing for CointegrationThe Engle-Granger Two-Step method starts by creating residuals based on the static regression and then testing the residuals for the presence of unit-roots. It uses the Augmented Dickey-Fuller Test (ADF) or other tests to test for stationarity units in time series.


1 Answers

This is now implemented in Python's statsmodels:

from statsmodels.tsa.vector_ar.vecm import coint_johansen
x = getx() # dataframe of n series for cointegration analysis
jres = coint_johansen(x, det_order=0, k_ar_diff=1)

For a full description of inputs/results, see the documentation.

like image 162
rbonallo Avatar answered Sep 18 '22 23:09

rbonallo