arch.unitroot.KPSS

class arch.unitroot.KPSS(y, lags=None, trend='c')[source]

Kwiatkowski, Phillips, Schmidt and Shin (KPSS) stationarity test

Parameters
  • y ({ndarray, Series}) -- The data to test for stationarity

  • lags (int, optional) -- The number of lags to use in the Newey-West estimator of the long-run covariance. If omitted or None, the number of lags is calculated with the data-dependent method of Hobijn et al. (1998). See also Andrews (1991), Newey & West (1994), and Schwert (1989). Set lags=-1 to use the old method that only depends on the sample size, 12 * (nobs/100) ** (1/4).

  • trend ({'c', 'ct'}, optional) --

    The trend component to include in the ADF test

    'c' - Include a constant (Default) 'ct' - Include a constant and linear time trend

Notes

The null hypothesis of the KPSS test is that the series is weakly stationary and the alternative is that it is non-stationary. If the p-value is above a critical size, then the null cannot be rejected that there and the series appears stationary.

The p-values and critical values were computed using an extensive simulation based on 100,000,000 replications using series with 2,000 observations.

Examples

>>> from arch.unitroot import KPSS
>>> import numpy as np
>>> import statsmodels.api as sm
>>> data = sm.datasets.macrodata.load().data
>>> inflation = np.diff(np.log(data['cpi']))
>>> kpss = KPSS(inflation)
>>> print('{0:0.4f}'.format(kpss.stat))
0.2870
>>> print('{0:0.4f}'.format(kpss.pvalue))
0.1473
>>> kpss.trend = 'ct'
>>> print('{0:0.4f}'.format(kpss.stat))
0.2075
>>> print('{0:0.4f}'.format(kpss.pvalue))
0.0128

References

*

Andrews, D.W.K. (1991). "Heteroskedasticity and autocorrelation consistent covariance matrix estimation". Econometrica, 59: 817-858.

Hobijn, B., Frances, B.H., & Ooms, M. (2004). Generalizations of the KPSS-test for stationarity. Statistica Neerlandica, 52: 483-502.

Kwiatkowski, D.; Phillips, P. C. B.; Schmidt, P.; Shin, Y. (1992). "Testing the null hypothesis of stationarity against the alternative of a unit root". Journal of Econometrics 54 (1-3), 159-178

§

Newey, W.K., & West, K.D. (1994). "Automatic lag selection in covariance matrix estimation". Review of Economic Studies, 61: 631-653.

Schwert, G. W. (1989). "Tests for unit roots: A Monte Carlo investigation". Journal of Business and Economic Statistics, 7 (2): 147-159.

Methods

summary()

Summary of test, containing statistic, p-value and critical values

Properties

alternative_hypothesis

The alternative hypothesis

critical_values

Dictionary containing critical values specific to the test, number of observations and included deterministic trend terms.

lags

Sets or gets the number of lags used in the model.

nobs

The number of observations used when computing the test statistic.

null_hypothesis

The null hypothesis

pvalue

Returns the p-value for the test statistic

stat

The test statistic for a unit root

trend

Sets or gets the deterministic trend term used in the test.

valid_trends

List of valid trend terms.

y

Returns the data used in the test statistic