時系列データの[[統計的仮説検定]]手法。 - 帰無仮説:系列が(トレンド)定常過程である - 対立仮説:系列が単位根過程である --- > [[拡張Dickey-Fuller検定|ADF検定]]が単位根の存在を帰無仮説として仮定するのに対し、KPSS(Kwiatkowski-Phillips-Schmidt-Shin)検定は定常過程を帰無仮説として仮定します。 > [[実践 時系列解析]] 3.2.1.2 ”定常性の定義と拡張ディッキー‐ フラー検定” より引用 [Perma | time series - What is the difference between a stationary test and a unit root test? - Cross Validated](https://perma.cc/D3F2-TATY) --- [KPSS test - Wikipedia](https://en.wikipedia.org/wiki/KPSS_test) > 計量経済学では、Kwiatkowski-Phillips-Schmidt-Shin(KPSS)検定は、観測可能な時系列が単位根の代替案に対して決定論的トレンド(すなわちトレンド定常)の周りに定常であるという帰無仮説を検定するために使用されている[1]。 > 多くの単位根検定とは異なり、単位根の存在は帰無仮説ではなく、対立仮説である。さらに、KPSS テストでは、単位根の不在は、定常性の証明ではなく、設計上、トレンド定常性の証明である。時系列が非定常で単位根を持たず、かつトレンド定常であることは可能であるので、これは重要な区別である。しかし、衝撃があると、[[トレンド定常過程]]は平均回帰する(つまり、一過性で、時系列は衝撃に影響されなかった成長する平均に向かって再び収束する)のに対し、単位根過程は平均に永久的な影響を与える(つまり、時間と共に収束しない)[2]. > その後、Denis Kwiatkowski, Peter C. B. Phillips, Peter Schmidt and Yongcheol Shin (1992) は、観測可能な系列がトレンド定常(決定論的トレンドの周りで定常)であるという帰無仮説の検定を提案した。系列は、決定論的トレンド、ランダムウォーク、定常誤差の和で表され、検定は、ランダムウォークは分散がゼロであるという仮説のラグランジュ乗数検定である。KPSSタイプの検定は、Dickey-Fuller検定などの単位根検定を補完するためのものである。単位根仮説と定常性仮説の両方を検定することで、定常性があると思われる系列、単位根があると思われる系列、定常か積分かを確かめるにはデータ(または検定)の情報が十分でない系列を区別することができる。 --- [[Announcing Smarter Real-Time Alerts With the KPSS Statistic for Signalflow]] ## 参考文献 [1] Andrews, D.W.K. (1991). Heteroskedasticity and autocorrelation consistent covariance matrix estimation. Econometrica, 59: 817-858. [2] Hobijn, B., Frances, B.H., & Ooms, M. (2004). Generalizations of the KPSS-test for stationarity. Statistica Neerlandica, 52: 483-502. [[2004__Statistica Neerlandica__Generalizations of the KPSS-test for Stationarity]] [3] 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: 159-178. [[1992__Journal of Econometrics__Testing the null hypothesis of stationarity against the alternative of a unit root]] [4] Newey, W.K., & West, K.D. (1994). Automatic lag selection in covariance matrix estimation. Review of Economic Studies, 61: 631-653. [5] Schwert, G. W. (1989). Tests for unit roots: A Monte Carlo investigation. Journal of Business and Economic Statistics, 7 (2): 147-159. ## KPSS検定の実装 [statsmodels.tsa.stattools — statsmodels](https://www.statsmodels.org/dev/_modules/statsmodels/tsa/stattools.html#kpss) 1. 線形回帰残差の計算 ```python # p. 162 Kwiatkowski et al. (1992): y_t = beta * t + r_t + e_t, # where beta is the trend, r_t a random walk and e_t a stationary # error term. resids = OLS(x, add_constant(np.arange(1, nobs + 1))).fit().resid ``` 2. ラグの計算 3. etaの計算 残差の[[累積和法|CUSUM]]をとる理由は、おそらく振動に対して蓄積されないようにするため。 ```python eta = np.sum(resids.cumsum() ** 2) / (nobs ** 2) # eq. 11, p. 165 ``` 4. sigma_est ```python s_hat = _sigma_est_kpss(resids, nobs, nlags) def _sigma_est_kpss(resids, nobs, lags): """ Computes equation 10, p. 164 of Kwiatkowski et al. (1992). This is the consistent estimator for the variance. """ s_hat = np.sum(resids ** 2) for i in range(1, lags + 1): resids_prod = np.dot(resids[i:], resids[: nobs - i]) s_hat += 2 * resids_prod * (1.0 - (i / (lags + 1.0))) return s_hat / nobs ``` 5. kpss統計量 ```python kpss_stat = eta / s_hat ```