statsmodels.tsa.stattools.adfuller#
- statsmodels.tsa.stattools.adfuller(x, maxlag=None, regression='c', autolag='AIC', store=False, regresults=False, *, result_object=None)[source]#
Augmented Dickey-Fuller unit root test
The Augmented Dickey-Fuller test can be used to test for a unit root in a univariate process in the presence of serial correlation.
- Parameters:
- xarray_like, 1d
The data series to test.
- maxlag
int,optional Maximum lag which is included in test, default value of 12*(nobs/100)^{1/4} is used when
None.- regression{“c”,”ct”,”ctt”,”n”},
optional Constant and trend order to include in regression.
“c” : constant only (default).
“ct” : constant and trend.
“ctt” : constant, and linear and quadratic trend.
“n” : no constant, no trend.
- autolag{“AIC”, “BIC”, “t-stat”,
None},optional Method to use when automatically determining the lag length among the values 0, 1, …, maxlag.
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.
If None, then the number of included lags is set to maxlag.
- storebool,
optional If True, then a result instance is returned additionally to the adf statistic. Default is False.
- regresultsbool,
optional If True, the full regression results are returned. Default is False.
- result_objectbool,
optional Flag indicating whether to return the results as an
ADFullerResultinstead of a plain tuple. IfNone(the default), the current tuple-returning behavior is used and aFutureWarningis issued.Deprecated since version 0.15.0: In release 0.16.0 or after July 2027, whichever is later, the default will change to always return an
ADFullerResult. Setresult_object=Trueto opt in now, orresult_object=Falseto silence the warning and keep the current return type.
- Returns:
ADFullerResultIf
result_object=True, a result object with fieldsstatistic,pvalue,lags,nobs,critical_values,icbest, andresstore(icbest/resstoreareNonewhen not computed). SeeADFullerResult.Otherwise(thedeprecateddefault),aplaintuplewhoselengthdependsonstoreandautolag,madeupofasubsetof:- statistic
float The test statistic.
- pvalue
float MacKinnon’s approximate p-value based on MacKinnon (1994, 2010).
- lags
int The number of lags used.
- nobs
int The number of observations used for the ADF regression and calculation of the critical values.
- critical_values
dict Critical values for the test statistic at the 1 %, 5 %, and 10 % levels. Based on MacKinnon (2010).
- icbest
float The maximized information criterion if autolag is not None.
- resstore
ResultsStore,optional A dummy class with results attached as attributes.
Notes
The null hypothesis of the Augmented Dickey-Fuller is that there is a unit root, with the alternative that there is no unit root. If the pvalue is above a critical size, then we cannot reject that there is a unit root.
The p-values are obtained through regression surface approximation from MacKinnon 1994, but using the updated 2010 tables. If the p-value is close to significant, then the critical values should be used to judge whether to reject the null.
The autolag option and maxlag for it are described in Greene.
See the notebook Stationarity and detrending (ADF/KPSS) for an overview.
References
[1]Green. “Econometric Analysis,” 5th ed., Pearson, 2003.
[2]Hamilton, J.D. “Time Series Analysis”. Princeton, 1994.
[3]MacKinnon, J.G. 1994. “Approximate asymptotic distribution functions for unit-root and cointegration tests. Journal of Business and Economic Statistics 12, 167-76.
[4]MacKinnon, J.G. 2010. “Critical Values for Cointegration Tests.” Queen’s University, Dept of Economics, Working Papers. Available at http://ideas.repec.org/p/qed/wpaper/1227.html