KPSS test
The KPSS test, or Kwiatkowski–Phillips–Schmidt–Shin test, is a statistical test used in time series analysis to assess the null hypothesis of stationarity around a deterministic trend (or level stationarity) against the alternative of a unit root process, which implies non-stationarity. Developed by Denis Kwiatkowski, Peter C. B. Phillips, Peter Schmidt, and Yongcheol Shin, the test was introduced in 1992 as a complement to unit root tests like the augmented Dickey–Fuller (ADF) test, where the null and alternative hypotheses are reversed: here, failure to reject the null supports trend stationarity, while rejection suggests the presence of a unit root.[1] The test statistic is based on a Lagrange multiplier (LM) approach, involving residuals from a regression of the time series on a constant and/or linear trend, and is compared to asymptotic critical values for inference. It is widely implemented in statistical software such as R and Python for evaluating the stationarity properties of economic and financial time series data prior to modeling.[2]Overview
Definition and Purpose
The Kwiatkowski–Phillips–Schmidt–Shin (KPSS) test is a unit root test designed to evaluate whether a univariate time series is stationary around a deterministic trend (trend-stationary) or non-stationary due to a unit root.[3] Under its framework, the time series is decomposed into a deterministic trend component, a random walk component, and a stationary error term, with the test assessing the variance of the random walk.[3] The primary purpose of the KPSS test is to test for stationarity in time series data, particularly in econometrics and economic analysis, where it serves as a complement to traditional unit root tests like the Augmented Dickey-Fuller (ADF) test by reversing the null hypothesis.[3] Whereas the ADF test assumes non-stationarity (presence of a unit root) under the null and seeks evidence of stationarity in the alternative, the KPSS test posits stationarity around a mean or trend as the null, with non-stationarity (unit root) as the alternative; this inversion addresses the frequent failure of unit root tests to reject their null in finite samples, reducing ambiguity in classifying series as non-stationary by default.[3] A key conceptual distinction addressed by the KPSS test is between trend-stationarity, where deviations from a deterministic trend revert to a constant mean with finite variance, and difference-stationarity, where a unit root causes shocks to accumulate indefinitely, requiring first differencing for stationarity.[3] This differentiation is vital in real-world applications such as economic forecasting, as misidentifying the process can invalidate models—trend-stationary series support direct regression around the trend, while difference-stationary ones demand transformation to avoid spurious results and ensure reliable predictions.[3] The test's application to macroeconomic datasets, such as those compiled by Nelson and Plosser (1982), has shown that many economic series align with trend-stationarity rather than unit roots, challenging prior assumptions and enhancing model robustness.[3]Historical Development
The KPSS test was developed by Denis Kwiatkowski, Peter C. B. Phillips, Peter Schmidt, and Yongcheol Shin as a response to limitations in existing unit root testing frameworks. It was first published in 1992 under the title "Testing the null hypothesis of stationarity against the alternative of a unit root: How sure are we that economic time series have a unit root?" in the Journal of Econometrics, volume 54, issues 1–3, pages 159–178.[1] The test emerged in the early 1990s during a period of heightened interest in unit root testing within econometrics, spurred by economic volatility from events such as the 1970s and 1980s oil price shocks and the 1987 stock market crash, which raised questions about the persistence of shocks in time series data.[4] Prior tests like the Augmented Dickey-Fuller (ADF) and Phillips-Perron (PP) procedures had focused on the null hypothesis of a unit root, often leading to inconclusive results; the KPSS test addressed this by reversing the hypotheses, with stationarity as the null and a unit root as the alternative, thereby complementing earlier methods.[1] Upon publication, the KPSS test received rapid adoption in econometric research for its ability to clarify ambiguities from unit root tests, particularly in analyzing economic time series where near-unit-root processes were common.[5] Its influence is evident in subsequent literature, where it has become a standard tool for stationarity assessment, inspiring extensions and generalizations that account for structural breaks and serial correlation.[6]Theoretical Foundations
Stationarity and Unit Roots
In time series analysis, a stochastic process is considered stationary if its statistical properties remain invariant over time. Strict stationarity, also known as strong stationarity, requires that the joint probability distribution of any collection of observations is identical to the joint distribution of the same number of observations shifted forward in time by any lag.[7] This stringent condition implies constant mean and variance, as well as time-invariant autocovariances. In practice, strict stationarity is often difficult to verify and may not be necessary for many applications, leading to the more commonly used concept of weak stationarity, or second-order stationarity.[7] Weak stationarity holds if the mean of the process is constant over time, the variance is finite and constant, and the autocovariance between observations depends solely on the time lag between them, not on the specific time points.[7] Within weak stationarity, processes can be further distinguished as level-stationary or trend-stationary. A level-stationary process fluctuates around a constant mean without any systematic trend, exhibiting properties that do not evolve with time.[8] In contrast, a trend-stationary process includes a deterministic trend—such as a linear or polynomial function of time—around which the deviations are stationary; removing this trend through detrending yields a level-stationary series.[9] A unit root represents a specific form of non-stationarity in autoregressive processes, where the root of the characteristic equation equals one, causing the process to be integrated of order one, or I(1).[10] For example, consider an AR(1) process defined as y_t = y_{t-1} + e_t, where e_t is white noise; here, the coefficient on the lagged term is exactly 1, resulting in a random walk that accumulates shocks over time.[10] The presence of a unit root implies that random shocks have permanent effects on the level of the series, as the variance grows linearly with time and the process does not revert to a fixed mean.[10] Such non-stationarity due to unit roots has critical implications for time series modeling, notably the risk of spurious regressions, where unrelated non-stationary series appear to exhibit a significant linear relationship owing to shared stochastic trends rather than true economic causation.[11] For instance, regressing two independent random walks can yield high t-statistics and R-squared values that mislead inference, highlighting the need to test for and address unit roots before proceeding with standard regression analysis.[11] Trend-stationarity differs fundamentally from processes with unit roots, which are difference-stationary or integrated, requiring first differencing to achieve stationarity rather than simple detrending.[9] In a trend-stationary process, the underlying trend is deterministic and predictable, so forecasts eventually converge to this trend line after accounting for stationary fluctuations.[9] Conversely, integrated processes with unit roots feature stochastic trends, where differencing removes the non-stationarity by transforming the series into a stationary one, but the original level retains memory of all past shocks.[9] This distinction is essential for appropriate modeling, as misapplying detrending to a unit root process or differencing to a trend-stationary one can distort inferences about persistence and long-run behavior.[12]Null and Alternative Hypotheses
The Kwiatkowski–Phillips–Schmidt–Shin (KPSS) test inverts the hypothesis framework of traditional unit root tests by examining the null hypothesis of stationarity rather than non-stationarity. Under the null hypothesis H_0, the observable time series is stationary around a deterministic component, such as a constant level or a linear trend, which implies the existence of a stationary error process.[1] This formulation posits that any deviations from the deterministic component revert to equilibrium, maintaining overall stationarity.[1] In contrast, the alternative hypothesis H_a specifies that the series is non-stationary due to the presence of a unit root, modeling it as an integrated process akin to a random walk with possible drift.[1] Rejection of H_0 in favor of H_a indicates that the series exhibits persistent shocks and requires first differencing to induce stationarity.[1] The test's design as a Lagrange multiplier (LM) procedure specifically targets the variance of the random walk component being zero under H_0.[1] The KPSS test features two primary variants to accommodate different assumptions about the deterministic component. In the level stationarity case, H_0 assumes the series fluctuates around a constant mean without a trend, suitable for data without evident long-term movement.[1] The trend stationarity variant, however, includes a linear deterministic trend under H_0, testing whether deviations from this trend are stationary, which is more appropriate for series displaying gradual evolution.[1] This reversed hypothesis structure addresses limitations in conventional tests like the Dickey–Fuller procedure, which often suffer from low power and may over-reject the null of a unit root when the series is actually stationary.[1] By prioritizing confirmation of stationarity, the KPSS framework provides a complementary tool to build greater confidence in inferences about unit roots in economic and time series data, challenging the prevailing view that such series are typically non-stationary.[1]Methodology
Test Statistic Formulation
The KPSS test is formulated for a univariate time series y_t, expressed as y_t = r_t + u_t, where r_t represents the deterministic component (either a constant or a linear trend) and u_t is a stationary process under the null hypothesis of trend stationarity.[1] Under the null, u_t follows an I(0) process with short-run variance \sigma^2 and long-run variance \lambda^2 = \sigma^2 / (1 - \sum_{i=1}^\infty \rho_i)^2, where \rho_i are the autocorrelations, while the alternative hypothesis posits that r_t includes a stochastic component resembling a random walk.[1] To obtain the residuals for the test, the series y_t is regressed via ordinary least squares (OLS) on the deterministic regressors: either a constant (level stationarity case) or a constant plus linear time trend (trend stationarity case). The resulting residuals \hat{u}_t serve as estimates of u_t, capturing deviations from the deterministic component.[1] The core test statistic, denoted as \eta or LM, is a Lagrange multiplier statistic given by \eta = \frac{1}{T^2} \sum_{t=1}^T S_t^2 / \hat{\sigma}^2, where T is the sample size, S_t = \sum_{i=1}^t \hat{u}_i is the cumulative sum of the residuals up to time t, and \hat{\sigma}^2 is a consistent estimate of the long-run variance \lambda^2 of u_t.[1] This formulation measures the cumulative deviations from the mean or trend, normalized by the estimated variance, with larger values indicating evidence against the null.[1] The cumulative sum S_t explicitly aggregates the OLS residuals as S_t = \sum_{i=1}^t \hat{u}_i, starting from S_0 = 0. The long-run variance estimator \hat{\sigma}^2 is computed as a weighted sum of sample autocovariances: \hat{\sigma}^2 = \hat{\gamma}(0) + 2 \sum_{i=1}^l w(i/l) \hat{\gamma}(i), where \hat{\gamma}(i) is the sample autocovariance at lag i, l is the bandwidth parameter, and w(\cdot) is a lag window function. A common choice is the Newey-West quadratic spectral kernel with bandwidth l = \lfloor 4(T/100)^{2/9} \rfloor to ensure consistency under potential serial correlation and heteroskedasticity in u_t.[1]Asymptotic Distribution and Critical Values
Under the null hypothesis of stationarity, the KPSS test statistic exhibits a non-standard asymptotic distribution derived from functional central limit theorems applied to partial sums of the time series. For the level stationarity case (no deterministic trend), the statistic \eta_\mu converges in distribution to \int_0^1 V_1(r)^2 \, dr, where V_1(r) = W(r) - r W(1) and W(r) denotes a standard Brownian motion on [0,1]. This is equivalent to the integral of the square of a Brownian bridge process. In the trend stationarity case (with a linear deterministic trend), the limiting distribution is \int_0^1 V_2(r)^2 \, dr, where V_2(r) = W(r) + r (3 \int_0^1 s W(s) \, ds - 2 \int_0^1 W(s) \, ds - r W(1)) represents a detrended Brownian motion functional. These distributions arise from the asymptotic behavior of the cumulative sums after removing deterministic components, ensuring the test's validity under the null.[1] Critical values for the KPSS test are obtained through Monte Carlo simulations of the respective asymptotic distributions, as the limiting forms do not yield closed-form quantiles. Table 1 in the original study provides these values for the level and trend cases at common significance levels, applicable for large samples. Representative critical values are as follows:| Significance Level | Level Stationarity (\eta_\mu) | Trend Stationarity (\eta_\tau) |
|---|---|---|
| 10% | 0.347 | 0.119 |
| 5% | 0.463 | 0.146 |
| 1% | 0.739 | 0.216 |
Implementation
Computational Steps
The computation of the KPSS test involves a series of sequential steps to evaluate the stationarity of a time series under the null hypothesis. These steps transform the raw data into the test statistic and facilitate hypothesis testing, assuming the series is observed over T periods. The procedure is grounded in the original formulation and can be performed manually or as a basis for programmatic implementation.[1]- Data Preparation: Begin by ensuring the time series data is complete and free of missing values, which could bias the regression and subsequent calculations; impute or exclude incomplete observations as needed. Visually inspect a plot of the series to determine whether to test for level stationarity (around a constant mean) or trend stationarity (around a linear trend), selecting the level model if the data fluctuates horizontally without an apparent slope, or the trend model if a clear upward or downward pattern is evident.[14]
- Estimate Deterministic Component via OLS Regression: Fit an ordinary least squares (OLS) regression of the observed series y_t on a constant (for the level model) or on both a constant and a linear time trend t (for the trend model) to detrend or de-mean the series and isolate the stochastic component. This yields the estimated residuals \hat{e}_t = y_t - \hat{\mu}_t, where \hat{\mu}_t represents the fitted deterministic part.[1]
- Compute Residuals and Cumulative Sums: Using the residuals \hat{e}_t from the regression, calculate the partial sums (cumulative sums) S_t = \sum_{i=1}^t \hat{e}_i for each time period t = 1, \dots, T, which form the basis for measuring deviations from stationarity.[1]
- Estimate Long-Run Variance: Compute an estimate of the long-run variance \hat{\sigma}^2 of the residuals \hat{e}_t to account for serial correlation, typically using kernel-based methods such as the Bartlett kernel with a bandwidth parameter (e.g., l = \lfloor 4(T/100)^{1/4} \rfloor) to ensure consistency under the null hypothesis. This step is crucial for scaling the test statistic appropriately.[1]
- Calculate LM Statistic and Perform Hypothesis Test: Form the Lagrange multiplier (LM) test statistic as \eta = \frac{1}{T^2} \sum_{t=1}^T S_t^2 / \hat{\sigma}^2, then compare it to critical values from the asymptotic distribution (detailed in the methodology section) at a chosen significance level, such as 5%, or compute the corresponding p-value. Under the null hypothesis of stationarity, the LM statistic converges to a specific distribution involving Brownian motion bridges.[1]
Software Packages and Examples
The KPSS test is implemented in various statistical software packages, facilitating its application in time series analysis. In R, the test is available through the tseries package, which provides the kpss.test() function for computing the test statistic under the null hypothesis of level or trend stationarity.[15] The basic syntax is kpss.test(x, null = c("Level", "Trend"), lshort = TRUE), where x is the input time series vector, null specifies the model ("Level" for constant only or "Trend" for constant and linear trend), and lshort = TRUE selects a short truncation lag parameter for the long-run variance estimation to improve finite-sample performance.[16] In Python, the statsmodels library offers the kpss() function within the tsa.stattools module, which computes the KPSS statistic with options for regression type and lag selection.[17] The syntax is statsmodels.tsa.stattools.kpss(x, regression='c', nlags="auto"), where x is the input array-like time series, regression can be 'c' (constant only) or 'ct' (constant and trend), and nlags determines the number of lags for the Newey-West variance estimator, defaulting to "auto" based on a formula involving sample size.[17] Other software includes Stata, where the user-contributed kpss command from SSC performs the test with syntax kpss varname [, maxlag(#) notrend], allowing specification of maximum lags and omission of the trend term if desired.[18] In EViews, the KPSS test is accessed via the graphical interface under Quick > Series Statistics > Unit Root Test, selecting KPSS as the test type, with options for lag length and inclusion of a linear trend in the underlying regression.[19] A worked example illustrates the implementation using hypothetical quarterly log real GDP levels for a developed economy, consisting of 100 observations from 2000Q1 to 2024Q4. In R, after loading the tseries package and preparing the data as a time series object (e.g., gdp_ts <- ts(log_gdp_data, frequency=4)), the command kpss.test(gdp_ts, null="Trend") yields a test statistic of 1.2, indicating evidence against trend stationarity at conventional significance levels. The p-value of 0.01 leads to rejection of the null hypothesis, suggesting the series is not stationary around a deterministic trend and may require differencing or further modeling for unit root presence.[20] The output from this R execution can be summarized in the following table:| Component | Value |
|---|---|
| KPSS Test Statistic | 1.2 |
| Truncation Lag Parameter | 4 |
| p-value (Trend Stationary) | 0.01 |
| Critical Values (1%, 5%, 10%) | 0.216, 0.146, 0.119 |
Comparisons and Applications
Differences from Unit Root Tests
The Kwiatkowski-Phillips-Schmidt-Shin (KPSS) test differs from traditional unit root tests primarily in its null hypothesis, which posits stationarity (either around a level or a deterministic trend) against the alternative of a unit root or non-stationarity. In contrast, the Augmented Dickey-Fuller (ADF) test assumes a null hypothesis of a unit root (non-stationarity) with an alternative of stationarity, making the two tests complementary for robust inference.[21] This reversal addresses limitations in unit root tests, which often suffer from low power against stationary alternatives near the unit root boundary, while the KPSS test can exhibit size distortions in finite samples but provides higher power for detecting trend stationarity in processes like moving averages.[22] The Phillips-Perron (PP) test shares the ADF's null of non-stationarity but employs a non-parametric correction to the test statistic for serial correlation and heteroskedasticity, using a bandwidth parameter rather than parametric lags.[23] The KPSS test similarly relies on non-parametric long-run variance estimation via a kernel-based approach (e.g., quadratic spectral kernel), but its stationary null distinguishes it from the PP test's focus on unit root detection.[21] Simulations show the KPSS test outperforming the PP in power across various sample sizes and models, particularly for stationary processes, though both can face size distortions in small samples.[24] Compared to tests accommodating structural breaks, such as the Zivot-Andrews test, the standard KPSS lacks provisions for endogenous breaks in the series, assuming smooth trend stationarity under the null.[25] The Zivot-Andrews test maintains a unit root null but allows one structural break in intercept, trend, or both, estimated endogenously to avoid bias from ignored shifts.[26] This makes the KPSS less suitable for series with potential regime changes, where the Zivot-Andrews may offer higher power by modeling breaks explicitly.| Test | Null Hypothesis | Test Statistic Adjustment for Serial Correlation | Power Characteristics Relative to KPSS |
|---|---|---|---|
| Augmented Dickey-Fuller (ADF) | Unit root (non-stationary) | Parametric (lagged differences) | Lower power against stationary alternatives; better for autoregressive processes[22] |
| Phillips-Perron (PP) | Unit root (non-stationary) | Non-parametric (bandwidth correction) | Comparable adjustment method but lower overall power in finite samples[24] |
| Zivot-Andrews | Unit root with structural break | Parametric with endogenous break estimation | Higher power when breaks present; KPSS assumes no breaks[25] |
| KPSS | Stationary (level or trend) | Non-parametric (long-run variance kernel) | Higher power for detecting non-stationarity in trend processes; minimal size distortions[24] |