Python 如何解释statsmodels coint结果?
我正在使用statsmodels coint,但不确定我的结果告诉了我什么。当我比较一对相似的股票时,我有兴趣了解协整结果。我使用了下面的代码,得到了非常不同的结果。谁能解释一下什么是好的/坏的结果以及为什么? 我很难理解其中的一些概念,为什么当我运行下面的代码时会得到非常不同的结果?当我使用每日调整收盘价时,与使用调整收盘价的百分比移动相比?我希望他们是一样的Python 如何解释statsmodels coint结果?,python,statsmodels,p-value,Python,Statsmodels,P Value,我正在使用statsmodels coint,但不确定我的结果告诉了我什么。当我比较一对相似的股票时,我有兴趣了解协整结果。我使用了下面的代码,得到了非常不同的结果。谁能解释一下什么是好的/坏的结果以及为什么? 我很难理解其中的一些概念,为什么当我运行下面的代码时会得到非常不同的结果?当我使用每日调整收盘价时,与使用调整收盘价的百分比移动相比?我希望他们是一样的 from statsmodels.tsa.stattools import coint import pandas as pd imp
from statsmodels.tsa.stattools import coint
import pandas as pd
import pandas_datareader.data as web
import datetime as dt
start = dt.datetime(2013, 1,1)
end = dt.datetime.today()
intquery1 = web.DataReader(['HEI.DU','HEI.BE'], 'yahoo', start, end) ##<<<<<put start to finish date.
int1 = intquery1['Adj Close']
print('############THIS cointegration on prices#####################')
score, pvalue, _ = coint(int1['HEI.DU'], int1['HEI.BE'])
print ('this is the coint score =',score,'\nthis is the pvalue =', pvalue,
'\nthis is the 1% 5% & 10% = ',_)
df_normalize = (int1[:] / int1[:].shift(1) - 1).fillna(0)
print('############THIS cointegration on Daily percetage move#####################')
score, pvalue, _ = coint(df_normalize['HEI.DU'], df_normalize['HEI.BE'])
print ('this is the coint score =',score,'\nthis is the pvalue =', pvalue,
'\nthis is the 1% 5% & 10% = ',_)
协整应该在价格差异上进行,而不是回报差异上
############THIS cointegration on prices#####################
this is the coint score = 0
this is the pvalue = 0.985900258026
this is the 1% 5% & 10% = [-3.90485841 -3.34081967 -3.04770405]
############THIS cointegration on Daily percetage move#####################
this is the coint score = -7.88182772484
this is the pvalue = 5.97585656581e-11
this is the 1% 5% & 10% = [-3.90485841 -3.34081967 -3.04770405]
/home/ross/anaconda3/lib/python3.6/site-packages/numpy/linalg/linalg.py:1574: RuntimeWarning: invalid value encountered in greater
return (S > tol).sum(axis=-1)
/home/ross/anaconda3/lib/python3.6/site-packages/statsmodels/tsa/stattools.py:1018: UserWarning: y0 and y1 are perfectly colinear. Cointegration test is not reliable in this case.
warnings.warn("y0 and y1 are perfectly colinear. Cointegration test "