简体   繁体   English

如果我使用Johansen测试来确定python中两个时间序列之间的相关性,如何读取测试结果?

[英]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. 我正在尝试使用2个时间序列拟合向量自动回归模型。我需要先进行协整测试,然后再应用VAR来检查两个时间序列是否相关。我能够成功实现Johansen测试,但无法读取测试结果。 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 我已经熟悉增强的Dicky Fuller检验,并且我知道如何使用检验统计量和临界值来推断单变量时间序列的平稳性

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. 以下代码给出了跟踪统计信息的临界值(90,95,99)。

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])

One way you could approach this is to use coint.test() in statsmodels. 解决此问题的一种方法是在statsmodels中使用coint.test()

As an example, consider that we are seeking to determine whether cointegration exists between oil price movements and the S&P 500 index. 例如,考虑我们正在寻求确定油价走势与标准普尔500指数之间是否存在协整关系。 The Engle-Granger test for cointegration (with the null hypothesis of no cointegration present) is run: 运行用于协整的Engle-Granger检验(不存在不存在协整的零假设):

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. 正如我们所看到的,p值0.39> 0.05意味着在5%的显着性水平上不能拒绝没有协整的零假设。

You could try Engle-Granger with your data and see what the reading is - it might prove to be more simplistic. 您可以将Engle-Granger与您的数据一起使用,看看读数是多少-可能会变得更加简单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM