如何解释statsmodels coint结果?

时间:2018-02-19 08:27:08

标签: python statsmodels p-value

我正在使用statsmodels coint但不确定我的结果告诉我什么。当我比较一对类似股票时,我有兴趣理解协整结果。我使用下面的代码,我得到了非常不同的结果。任何人都可以解释什么是好的/坏的结果,为什么? 我正在努力探索一些概念,为什么当我运行以下代码时,我会得到非常不同的结果 - 当我使用每日adj_close价格与使用adj_close价格的百分比移动相比时?我希望它们是一样的。

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% = ',_)

这是我使用HEI.DU从上面的代码得到的结果与HEI.BE相比。为什么结果如此不同,它们在这两只股票的背景下实际意味着什么呢?

############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 "

1 个答案:

答案 0 :(得分:0)

co整合应按价格差异而不是收益差异进行。