Johansen cointegration test in python

你离开我真会死。 提交于 2020-01-22 14:50:49

问题


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


回答1:


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)




回答2:


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




回答3:


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.



来源:https://stackoverflow.com/questions/12186994/johansen-cointegration-test-in-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!