Johansen cointegration test in python
Asked Answered
S

4

18

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

Shope answered 29/8, 2012 at 21:47 Comment(0)
T
9

statsmodels doesn't have a Johansen cointegration test. And, I have never seen it in any other python package either.

statsmodels has VAR and structural VAR, but no VECM (vector error correction models) yet.

update:

As Wes mentioned, there is now a pull request for Johansen's cointegration test for statsmodels. I have translated the matlab version in LeSage's spatial econometrics toolbox and wrote a set of tests to verify that we get the same results. It should be available in the next release of statsmodels.

update 2:

The test for cointegration coint_johansen was included in statsmodels 0.9.0 together with the vector error correction models VECM. (see also 3rd answer)

Threecornered answered 29/8, 2012 at 23:14 Comment(0)
B
16

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.

Brandybrandyn answered 14/3, 2019 at 16:32 Comment(1)
The documentation is COMPLETELY WORtHLESSDaven
T
9

statsmodels doesn't have a Johansen cointegration test. And, I have never seen it in any other python package either.

statsmodels has VAR and structural VAR, but no VECM (vector error correction models) yet.

update:

As Wes mentioned, there is now a pull request for Johansen's cointegration test for statsmodels. I have translated the matlab version in LeSage's spatial econometrics toolbox and wrote a set of tests to verify that we get the same results. It should be available in the next release of statsmodels.

update 2:

The test for cointegration coint_johansen was included in statsmodels 0.9.0 together with the vector error correction models VECM. (see also 3rd answer)

Threecornered answered 29/8, 2012 at 23:14 Comment(0)
M
4

See http://github.com/statsmodels/statsmodels/pull/453

Maniple answered 8/9, 2012 at 22:39 Comment(0)
P
1

Check this: https://searchcode.com/codesearch/view/88477497/

It provides a library where you can find the Johansen cointegration test.

Pvc answered 2/9, 2021 at 16:31 Comment(1)
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes.Ut

© 2022 - 2024 — McMap. All rights reserved.