statsmodels.tsa.stattools.coint¶
-
statsmodels.tsa.stattools.
coint
(y0, y1, trend='c', method='aeg', maxlag=None, autolag='aic', return_results=None)[source]¶ Test for no-cointegration of a univariate equation
The null hypothesis is no cointegration. Variables in y0 and y1 are assumed to be integrated of order 1, I(1).
This uses the augmented Engle-Granger two-step cointegration test. Constant or trend is included in 1st stage regression, i.e. in cointegrating equation.
Warning: The autolag default has changed compared to statsmodels 0.8. In 0.8 autolag was always None, no the keyword is used and defaults to ‘aic’. Use autolag=None to avoid the lag search.
- Parameters
- y1array_like, 1d
first element in cointegrating vector
- y2array_like
remaining elements in cointegrating vector
- trendstr {‘c’, ‘ct’}
trend term included in regression for cointegrating equation
‘c’ : constant
‘ct’ : constant and linear trend
also available quadratic trend ‘ctt’, and no constant ‘nc’
- methodstring
currently only ‘aeg’ for augmented Engle-Granger test is available. default might change.
- maxlagNone or int
keyword for adfuller, largest or given number of lags
- autolagstring
keyword for adfuller, lag selection criterion.
if None, then maxlag lags are used without lag search
if ‘AIC’ (default) or ‘BIC’, then the number of lags is chosen to minimize the corresponding information criterion
‘t-stat’ based choice of maxlag. Starts with maxlag and drops a lag until the t-statistic on the last lag length is significant using a 5%-sized test
- return_resultsbool
for future compatibility, currently only tuple available. If True, then a results instance is returned. Otherwise, a tuple with the test outcome is returned. Set return_results=False to avoid future changes in return.
- Returns
- coint_tfloat
t-statistic of unit-root test on residuals
- pvaluefloat
MacKinnon’s approximate, asymptotic p-value based on MacKinnon (1994)
- crit_valuedict
Critical values for the test statistic at the 1 %, 5 %, and 10 % levels based on regression curve. This depends on the number of observations.
Notes
The Null hypothesis is that there is no cointegration, the alternative hypothesis is that there is cointegrating relationship. If the pvalue is small, below a critical size, then we can reject the hypothesis that there is no cointegrating relationship.
P-values and critical values are obtained through regression surface approximation from MacKinnon 1994 and 2010.
If the two series are almost perfectly collinear, then computing the test is numerically unstable. However, the two series will be cointegrated under the maintained assumption that they are integrated. In this case the t-statistic will be set to -inf and the pvalue to zero.
TODO: We could handle gaps in data by dropping rows with nans in the auxiliary regressions. Not implemented yet, currently assumes no nans and no gaps in time series.
References
- MacKinnon, J.G. 1994 “Approximate Asymptotic Distribution Functions for
Unit-Root and Cointegration Tests.” Journal of Business & Economics Statistics, 12.2, 167-76.
- MacKinnon, J.G. 2010. “Critical Values for Cointegration Tests.”
Queen’s University, Dept of Economics Working Papers 1227. http://ideas.repec.org/p/qed/wpaper/1227.html