arch.unitroot.KPSS¶
- 
class arch.unitroot.KPSS(y: ndarray | DataFrame | Series, lags: int | None = None, trend: 'c' | 'ct' ='c')[source]¶
- Kwiatkowski, Phillips, Schmidt and Shin (KPSS) stationarity test - Parameters:¶
- y: ndarray | DataFrame | Series¶
- The data to test for stationarity 
- lags: int | None = None¶
- 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' = 'c'¶
- 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. See [3] for the initial description of the KPSS test. Further details are available in [2] and [5]. Details about the long-run covariance estimation can be found in [1] and [4]. - 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(f"{kpss.stat:0.4f}") 0.2870 >>> print(f"{kpss.pvalue:0.4f}") 0.1473 >>> kpss.trend = "ct" >>> print(f"{kpss.stat:0.4f}") 0.2075 >>> print(f"{kpss.pvalue:0.4f}") 0.0128- References - Methods - summary()- Summary of test, containing statistic, p-value and critical values - Properties - The alternative hypothesis - Dictionary containing critical values specific to the test, number of observations and included deterministic trend terms. - Sets or gets the number of lags used in the model. - The number of observations used when computing the test statistic. - The null hypothesis - Returns the p-value for the test statistic - The test statistic for a unit root - Sets or gets the deterministic trend term used in the test. - List of valid trend terms. - Returns the data used in the test statistic