pandas python中的约翰森协整检验
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12186994/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Johansen cointegration test in python
提问by mspadaccino
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,
我找不到任何关于在处理统计和时间序列分析(pandas 和 statsmodel)的 Python 模块中执行 Johansen 协整测试的功能的参考。anybpdy 是否知道是否有一些代码可以执行这样的时间序列之间的协整测试?谢谢你的帮助,
Maruizio
马鲁齐奥
采纳答案by Josef
statsmodels doesn't have a Johansen cointegration test. And, I have never seen it in any other python package either.
statsmodels 没有约翰森协整检验。而且,我也从未在任何其他 python 包中见过它。
statsmodels has VAR and structural VAR, but no VECM (vector error correction models) yet.
statsmodels 有 VAR 和结构 VAR,但还没有 VECM(向量误差校正模型)。
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.
正如 Wes 所提到的,现在有一个对 Johansen 的 statsmodels 协整测试的拉取请求。我已经翻译了 LeSage 的空间计量经济学工具箱中的 matlab 版本,并编写了一组测试来验证我们得到了相同的结果。它应该在 statsmodels 的下一个版本中可用。
update 2:
更新2:
The test for cointegration coint_johansenwas included in statsmodels 0.9.0 together with the vector error correction models VECM.
(see also 3rd answer)
协整检验coint_johansen与向量误差校正模型 VECM 一起包含在 statsmodels 0.9.0 中。(另见第三个答案)
回答by Wes McKinney
回答by rbonallo
This is now implemented in Python's statsmodels:
这现在在 Python 的 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.
有关输入/结果的完整说明,请参阅文档。

