常用函数总结
第一章 协调关系测试
协调关系测试
协整关系说明两个时序具有长期的统计上的关系。
一、coint_johansen
coint_johansen(adf.ar, -1, 4)
函数中adf.ar是一个数组,-1表示不设假设,4表示滞后阶数为4.
二、使用步骤
1.初步检测
from statsmodels.tsa.vector_ar.vecm import coint_johansen
def cointegration_test(df, alpha=0.05):
"""Perform Johanson's Cointegration Test and Report Summary"""
print(df)
out = coint_johansen(df,-1,5)
d = {
'0.90':0, '0.95':1, '0.99':2}
traces = out.lr1
cvts = out.cvt[:, d[str(1-alpha)]]
def adjust