Skip to content

KPSS, the battery and breaks

Flip the null with KPSS, read the four outcomes of a battery and its recommended differences, and see how a single break can fool them all until Zivot–Andrews looks for it.

Advanced ~14 min10 steps

What runs in CodeSplash

You will be able to

  • State the KPSS null and read it against ADF in a two-way table
  • Read the battery's recommended d, and know its limits
  • Explain how a structural break mimics a unit root, and use Zivot–Andrews and Schmidt–Phillips

Read first

01

Flip the null

Read

Every test so far says "unit root" under H0H_0. With low power, you often can't reject it, and that tells you little.

KPSSKPSS testTests H₀ "the series is stationary" — the reverse of ADF; use both and compare. (Kwiatkowski et al., 1992) swaps them: H0H_0 is stationary, around a level or trend. It rejects when cumulative deviations from the mean drift too far.

On the Nile's flow, KPSS gives 0.87 against a 5% value of 0.46. The p-value of 0.01 is the bottom of the table, so read it as "at most this". Note that this statistic is large for rejection, unlike τ\tau.

02

Read them together

Predict

Predict first

ADF doesn't reject, and KPSS doesn't reject either. What's the reading?

StationaryUnit rootUnclear: too little information
Reveal

Unclear. Both nulls survive, so the data can't separate them. Here is the full table:

KPSS doesn't rejectKPSS rejects
ADF rejectsStationaryConflict: maybe a break
ADF doesn't rejectToo little informationUnit root
03

The battery on AirPassengers

In the app

Battery runs ADF, PP, DF-GLS and KPSS, and differences until ADF rejects and KPSS doesn't.

Unit-root and stationarity testsRecorded · Python and R agreeRecorded 2026-11-17 · 20 values compared
R

Augmented Dickey–Fuller τ = 0.82, p = .992; Phillips–Perron Z(τ) = -1.84, p = .359; DF-GLS τ = 0.99, p = .915; KPSS η = 1.65, p ≤ 0.01

Augmented Dickey–Fuller τ
0.8154
p
0.9919
Recommended d
2

Plots

passengers over timeHow does the series move over time, and where is an estimated break?
View data
monthpassengers
−662,688,000,000112
−660,009,600,000118
−657,590,400,000132
−654,912,000,000129
−652,320,000,000121
−649,641,600,000135
−647,049,600,000148
−644,371,200,000148
−641,692,800,000136
−639,100,800,000119
−636,422,400,000104
−633,830,400,000118
−631,152,000,000115
−628,473,600,000126
−626,054,400,000141
−623,376,000,000135
−620,784,000,000125
−618,105,600,000149
−615,513,600,000170
−612,835,200,000170
−610,156,800,000158
−607,564,800,000133
−604,886,400,000114
−602,294,400,000140
−599,616,000,000145
−596,937,600,000150
−594,518,400,000178
−591,840,000,000163
−589,248,000,000172
−586,569,600,000178
−583,977,600,000199
−581,299,200,000199
−578,620,800,000184
−576,028,800,000162
−573,350,400,000146
−570,758,400,000166
−568,080,000,000171
−565,401,600,000180
−562,896,000,000193
−560,217,600,000181
−557,625,600,000183
−554,947,200,000218
−552,355,200,000230
−549,676,800,000242
−546,998,400,000209
−544,406,400,000191
−541,728,000,000172
−539,136,000,000194
−536,457,600,000196
−533,779,200,000196
−531,360,000,000236
−528,681,600,000235
−526,089,600,000229
−523,411,200,000243
−520,819,200,000264
−518,140,800,000272
−515,462,400,000237
−512,870,400,000211
−510,192,000,000180
−507,600,000,000201

First 60 of 144 rows.

Autocorrelation of passengersIs the series autocorrelated, and at which lags (seasonality, AR order)?
View data
passengers
112
118
132
129
121
135
148
148
136
119
104
118
115
126
141
135
125
149
170
170
158
133
114
140
145
150
178
163
172
178
199
199
184
162
146
166
171
180
193
181
183
218
230
242
209
191
172
194
196
196
236
235
229
243
264
272
237
211
180
201

First 60 of 144 rows.

Tests

TestH₀StatisticpLags / bandwidth5 % critical valueAt α = .05
Augmented Dickey–Fuller τunit root0.8154.99213−2.884unit root not rejected
Phillips–Perron Z(τ)unit root−1.844.3594−2.882unit root not rejected
DF-GLS τunit root0.9918.91513−1.943unit root not rejected
KPSS ηstationary1.651.010≤80.4630reject stationarity
  • Unit-root tests have low power near a unit root: read them with KPSS (the battery does) and a plot of the series.
  • p-values come from nonstandard distributions (MacKinnon response surfaces, KPSS / ERS / Zivot–Andrews tables); a p shown at a table bound (≤ .01 or ≥ .10) means the statistic is beyond the tabulated range.
The exact R script · R R version 4.5.1 (2025-06-13)
# Unit-root and stationarity tests
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method ts.unitroot 1.1.1 · spec 7c26bc63d52c4e27
# Dataset: ml_airpassengers (version 1)
# Runs on its own: outside the app, cs_publish() writes $CS_RESULT_PATH or prints the result JSON.

# %% Setup
library(codesplashr)

# %% Data
df <- as.data.frame(nanoparquet::read_parquet("tests/parity/fixtures/ml_airpassengers.parquet", col_select = c("passengers", "month")))
n_input <- nrow(df)
df <- df[stats::complete.cases(df[c("passengers", "month")]), , drop = FALSE]  # listwise deletion
df[] <- lapply(df, function(x) if (is.factor(x)) droplevels(x) else x)
n_dropped <- n_input - nrow(df)
warnings <- list()
if (n_dropped > 0) {
  warnings <- c(warnings, cs_warning("CS_W_ROWS_DROPPED", dropped = n_dropped, total = n_input))
}
if (n_input > 0 && nrow(df) == 0) cs_error("CS_E_NO_ROWS")
cs_check_finite_columns(df, c("passengers", "month"))  # infinite values stop the run (registry/errors.yaml)

# %% Series
VALUE <- "passengers"
TIME <- "month"
TEMPORAL <- TRUE
TEST <- "battery"
DET <- "c"
LAG_RULE <- "aic"
LAGS <- NULL
BW <- "auto"
ZA_MODEL <- "c"
TRIM <- 0.15
REPS <- 999
SEED <- 42
s <- cs_ts_ordered(df, VALUE, TIME, TEMPORAL)
x <- s$x
labels <- s$labels
n <- length(x)
if (s$dups > 0) warnings <- c(warnings, sprintf("%d repeated time values: the tests assume one observation per evenly spaced time.", s$dups))
det <- DET
if (DET == "n" && !(TEST %in% c("adf", "df", "pp"))) {
  det <- "c"
  warnings <- c(warnings, "No deterministic terms is only defined for ADF, DF and PP; a constant was used.")
}
det_kpss <- if (det == "ct") "ct" else "c"
# The test regressions need at least 2 x (deterministic terms + 1) observations (as statsmodels' adfuller), and
# never fewer than 4, and a series that varies (registry/errors.yaml; the same checks in Python).
cs_check_rows(n, max(4, 2 * (c(n = 0, c = 1, ct = 2)[[det]] + 1)), "A unit-root test")
cs_check_not_constant(x, VALUE)
bw_kpss <- BW
bw <- if (BW == "auto") "short" else BW
LABELS <- list(adf = "Augmented Dickey–Fuller τ", df = "Dickey–Fuller τ", pp = "Phillips–Perron Z(τ)", dfgls = "DF-GLS τ",
               za = "Zivot–Andrews t", sp = "Schmidt–Phillips Z(τ)", kpss = "KPSS η", battery = "Battery")
pf <- function(r) if (!is.null(r$bound) && nzchar(r$bound)) sprintf("p %s %.2f", r$bound, r$p) else cs_fmt_p(r$p)
run_test <- function(test) {
  switch(test,
    adf = cs_ts_adf(x, det, lags = LAGS, autolag = LAG_RULE),
    df = cs_ts_adf(x, det, lags = 0),
    pp = cs_ts_pp(x, det, bw),
    dfgls = cs_ts_dfgls(x, det_kpss, lags = LAGS, autolag = LAG_RULE),
    za = cs_ts_zivot_andrews(x, ZA_MODEL, TRIM, lags = LAGS, autolag = LAG_RULE),
    sp = cs_ts_schmidt_phillips(x, bw, REPS, SEED),
    cs_ts_kpss(x, det_kpss, bw_kpss))
}

# %% Tests
rows <- list()
values <- list(n_obs = n, test = TEST, test_label = LABELS[[TEST]])
battery <- if (TEST == "battery") c("adf", "pp", "dfgls", "kpss") else TEST
res <- list()
for (t in battery) {
  r <- run_test(t)
  res[[t]] <- r
  crit <- if (is.null(r$crit)) list(NULL, NULL, NULL) else as.list(r$crit)
  if (t == "kpss") crit <- list(r$crit[4], r$crit[2], r$crit[1])
  reject <- r$p < 0.05
  verdict <- if (t == "kpss") (if (reject) "reject stationarity" else "stationary") else (if (reject) "reject the unit root" else "unit root not rejected")
  rows[[length(rows) + 1]] <- list(test = LABELS[[t]], h0 = if (t == "kpss") "stationary" else "unit root", statistic = r$stat, p = r$p,
                                   p_note = if (is.null(r$bound)) "" else r$bound, lags = r$lags, crit_5 = crit[[2]], verdict = verdict)
}
main <- res[[battery[1]]]
crit <- if (is.null(main$crit)) list(NULL, NULL, NULL) else as.list(main$crit)
if (battery[1] == "kpss") crit <- list(main$crit[4], main$crit[2], main$crit[1])
values["stat"] <- list(main$stat)
values["p"] <- list(main$p)
values["lags"] <- list(main$lags)
values["crit_1"] <- list(crit[[1]])
values["crit_5"] <- list(crit[[2]])
values["crit_10"] <- list(crit[[3]])
values$reject <- as.integer(main$p < 0.05)
if (TEST == "battery") {
  for (t in battery) {
    values[[paste0(t, "_stat")]] <- res[[t]]$stat
    values[[paste0(t, "_p")]] <- res[[t]]$p
  }
  values$adf_lags <- res$adf$lags
}
if (TEST == "za") values$break_index <- main$break_index
if (TEST == "sp") values$reps <- REPS
rd <- cs_ts_recommend_d(x, if (det == "ct") "ct" else "c", lags = LAGS, autolag = LAG_RULE, bandwidth = bw_kpss, detail = TRUE)  # same lag settings as the tests
values$d_recommended <- rd$d
if (!rd$agreed) warnings <- c(warnings, sprintf("ADF and KPSS never agreed on stationarity up to d = %d; the recommended d is a convention, not a finding.", rd$d))

# %% Result
summary <- if (TEST == "battery") {
  sprintf("Unit-root battery for %s (%d observations): ADF τ = %.2f (%s), KPSS = %.3f (%s); recommended differences d = %d.",
          VALUE, n, res$adf$stat, pf(res$adf), res$kpss$stat, pf(res$kpss), values$d_recommended)
} else {
  sprintf("%s for %s: %.3f, %s — %s.", LABELS[[TEST]], VALUE, main$stat, pf(main), rows[[1]]$verdict)
}
if (TEST == "za") summary <- paste0(summary, sprintf(" Most likely break after %s.", labels[main$break_index + 1]))
notes <- list("Unit-root tests have low power near a unit root: read them with KPSS (the battery does) and a plot of the series.",
              "p-values come from nonstandard distributions (MacKinnon response surfaces, KPSS / ERS / Zivot–Andrews tables); a p shown at a table bound (≤ .01 or ≥ .10) means the statistic is beyond the tabulated range.")
if (TEST == "sp") notes <- c(notes, sprintf("Schmidt–Phillips p from %d simulated random walks (seed %d; identical in Python and R).", REPS, SEED))
kind <- if (TEMPORAL) "temporal" else "numeric"
charts <- list(
  cs_chart("series", "series-line", sprintf("%s over time", VALUE), list(x = cs_col(if (is.null(TIME)) "index" else TIME, labels, kind = kind), y = cs_col(VALUE, x)),
           controls = if (TEST == "za") list(marker = main$break_index + 1) else NULL),
  cs_chart("acf", "acf", sprintf("Autocorrelation of %s", VALUE), list(y = cs_col(VALUE, x))))
cs_publish(list(
  method = "ts.unitroot",
  methodVersion = "1.1.1",
  title = "Unit-root and stationarity tests",
  engine = cs_engine_info("stats", "nanoparquet"),
  n = n,
  summary = summary,
  apa = paste(vapply(battery, function(t) sprintf("%s = %.2f, %s", LABELS[[t]], res[[t]]$stat, pf(res[[t]])), ""), collapse = "; "),
  statistics = list(list(key = "stat", label = LABELS[[battery[1]]], value = main$stat), list(key = "p", label = "p", value = main$p),
                    list(key = "d", label = "Recommended d", value = values$d_recommended)),
  tables = list(list(
    key = "tests", title = "Tests",
    columns = list(list(key = "test", label = "Test", type = "string"), list(key = "h0", label = "H₀", type = "string"),
                   list(key = "statistic", label = "Statistic", type = "number"), list(key = "p", label = "p", type = "pvalue"),
                   list(key = "p_note", label = "", type = "string"), list(key = "lags", label = "Lags / bandwidth", type = "integer"),
                   list(key = "crit_5", label = "5 % critical value", type = "number"), list(key = "verdict", label = "At α = .05", type = "string")),
    rows = rows
  )),
  effectSizes = list(),
  assumptions = list(),
  warnings = warnings,
  notes = notes,
  charts = charts,
  values = values
))
Python

Augmented Dickey–Fuller τ = 0.82, p = .992; Phillips–Perron Z(τ) = -1.84, p = .359; DF-GLS τ = 0.99, p = .915; KPSS η = 1.65, p ≤ 0.01

Augmented Dickey–Fuller τ
0.8154
p
0.9919
Recommended d
2

To keep this page light, the plots are shown once, under the R tab.

Tests

TestH₀StatisticpLags / bandwidth5 % critical valueAt α = .05
Augmented Dickey–Fuller τunit root0.8154.99213−2.884unit root not rejected
Phillips–Perron Z(τ)unit root−1.844.3594−2.882unit root not rejected
DF-GLS τunit root0.9918.91513−1.943unit root not rejected
KPSS ηstationary1.651.010≤80.4630reject stationarity
  • Unit-root tests have low power near a unit root: read them with KPSS (the battery does) and a plot of the series.
  • p-values come from nonstandard distributions (MacKinnon response surfaces, KPSS / ERS / Zivot–Andrews tables); a p shown at a table bound (≤ .01 or ≥ .10) means the statistic is beyond the tabulated range.
The exact Python script · Python Python 3.13.5 · scipy 1.18.1 · pandas 3.1.0
# Unit-root and stationarity tests
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method ts.unitroot 1.1.1 · spec 7c26bc63d52c4e27
# Dataset: ml_airpassengers (version 1)
# Runs on its own: outside the app, cs.publish() writes $CS_RESULT_PATH or prints the result JSON.

# %% Setup
import numpy as np
import pandas as pd

import codesplash as cs
from codesplash.errors import check_not_constant
from codesplash.stats import ts

# %% Data
df = pd.read_parquet("tests/parity/fixtures/ml_airpassengers.parquet", columns=["passengers", "month"])
n_input = len(df)
df = df.dropna(subset=["passengers", "month"])  # listwise deletion over the analysis columns
n_dropped = n_input - len(df)
warnings = []
if n_dropped:
    warnings.append(cs.cs_warning("CS_W_ROWS_DROPPED", dropped=n_dropped, total=n_input))
if n_input and not len(df):
    cs.cs_error("CS_E_NO_ROWS")
cs.check_finite_columns(df, ["passengers", "month"])  # infinite values stop the run (registry/errors.yaml)

# %% Series
VALUE = "passengers"
TIME = "month"
TEMPORAL = True
TEST = "battery"
DET = "c"
LAG_RULE = "aic"
LAGS = None
BW = "auto"
ZA_MODEL = "c"
TRIM = 0.15
REPS = 999
SEED = 42
s = ts.ordered(df, VALUE, TIME, TEMPORAL)
x, labels = s["x"], s["labels"]
n = len(x)
if s["dups"]:
    warnings.append(f"{s['dups']} repeated time values: the tests assume one observation per evenly spaced time.")
det = DET
if DET == "n" and TEST not in ("adf", "df", "pp"):
    det = "c"
    warnings.append("No deterministic terms is only defined for ADF, DF and PP; a constant was used.")
det_kpss = "ct" if det == "ct" else "c"
# The test regressions need at least 2 × (deterministic terms + 1) observations (as statsmodels' adfuller), and
# never fewer than 4, and a series that varies (registry/errors.yaml; the same checks in R).
cs.check_rows(n, max(4, 2 * ({"n": 0, "c": 1, "ct": 2}[det] + 1)), "A unit-root test")
check_not_constant(x, VALUE)
bw_kpss = "auto" if BW == "auto" else BW
bw = "short" if BW == "auto" else BW
LABELS = {"adf": "Augmented Dickey–Fuller τ", "df": "Dickey–Fuller τ", "pp": "Phillips–Perron Z(τ)", "dfgls": "DF-GLS τ",
          "za": "Zivot–Andrews t", "sp": "Schmidt–Phillips Z(τ)", "kpss": "KPSS η", "battery": "Battery"}


def pf(r):
    """p as text, with the table bound when the statistic is beyond the tabulated range."""
    b = r.get("bound") or ""
    return f"p {b} {r['p']:.2f}" if b else cs.fmt_p(r["p"])


def run(test):
    if test == "adf":
        return ts.adf(x, det, lags=LAGS, autolag=LAG_RULE)
    if test == "df":
        return ts.adf(x, det, lags=0)
    if test == "pp":
        return ts.pp(x, det, bw)
    if test == "dfgls":
        return ts.dfgls(x, det_kpss, lags=LAGS, autolag=LAG_RULE)
    if test == "za":
        return ts.zivot_andrews(x, ZA_MODEL, TRIM, lags=LAGS, autolag=LAG_RULE)
    if test == "sp":
        return ts.schmidt_phillips(x, bw, REPS, SEED)
    return ts.kpss(x, det_kpss, bw_kpss)


# %% Tests
rows, values = [], {"n_obs": n, "test": TEST, "test_label": LABELS[TEST]}
battery = ["adf", "pp", "dfgls", "kpss"] if TEST == "battery" else [TEST]
res = {}
for t in battery:
    r = run(t)
    res[t] = r
    crit = r.get("crit") or [None, None, None]
    if t == "kpss":
        crit = [crit[3], crit[1], crit[0]]  # 1 %, 5 %, 10 %
    reject = (r["p"] < 0.05)
    rows.append({"test": LABELS[t], "h0": "stationary" if t == "kpss" else "unit root", "statistic": r["stat"], "p": r["p"],
                 "p_note": r.get("bound") or "", "lags": r.get("lags"), "crit_5": crit[1],
                 "verdict": ("reject stationarity" if reject else "stationary") if t == "kpss" else ("reject the unit root" if reject else "unit root not rejected")})
main = res[battery[0]]
crit = main.get("crit") or [None, None, None]
if battery[0] == "kpss":
    crit = [crit[3], crit[1], crit[0]]
values.update({"stat": main["stat"], "p": main["p"], "lags": main.get("lags"), "crit_1": crit[0], "crit_5": crit[1], "crit_10": crit[2],
               "reject": int(main["p"] < 0.05)})
if TEST == "battery":
    for t in battery:
        values[f"{t}_stat"] = res[t]["stat"]
        values[f"{t}_p"] = res[t]["p"]
    values["adf_lags"] = res["adf"]["lags"]
if TEST == "za":
    values["break_index"] = main["break_index"]
if TEST == "sp":
    values["reps"] = REPS
rd = ts.recommend_d(x, "ct" if det == "ct" else "c", lags=LAGS, autolag=LAG_RULE, bandwidth=bw_kpss, detail=True)  # same lag settings as the tests
values["d_recommended"] = rd["d"]
if not rd["agreed"]:
    warnings.append(f"ADF and KPSS never agreed on stationarity up to d = {rd['d']}; the recommended d is a convention, not a finding.")

# %% Result
if TEST == "battery":
    summary = (f"Unit-root battery for {VALUE} ({n} observations): ADF τ = {res['adf']['stat']:.2f} ({pf(res['adf'])}), "
               f"KPSS = {res['kpss']['stat']:.3f} ({pf(res['kpss'])}); recommended differences d = {values['d_recommended']}.")
else:
    summary = f"{LABELS[TEST]} for {VALUE}: {main['stat']:.3f}, {pf(main)} — {rows[0]['verdict']}."
if TEST == "za":
    summary += f" Most likely break after {labels[main['break_index']]}."
notes = ["Unit-root tests have low power near a unit root: read them with KPSS (the battery does) and a plot of the series.",
         "p-values come from nonstandard distributions (MacKinnon response surfaces, KPSS / ERS / Zivot–Andrews tables); "
         "a p shown at a table bound (≤ .01 or ≥ .10) means the statistic is beyond the tabulated range."]
if TEST == "sp":
    notes.append(f"Schmidt–Phillips p from {REPS} simulated random walks (seed {SEED}; identical in Python and R).")
kind = "temporal" if TEMPORAL else "numeric"
charts = [cs.chart("series", "series-line", f"{VALUE} over time", {"x": cs.col(TIME or "index", labels, kind=kind), "y": cs.col(VALUE, x)},
                   controls={"marker": main["break_index"] + 1} if TEST == "za" else None),
          cs.chart("acf", "acf", f"Autocorrelation of {VALUE}", {"y": cs.col(VALUE, x)})]
cs.publish({
    "method": "ts.unitroot",
    "methodVersion": "1.1.1",
    "title": "Unit-root and stationarity tests",
    "engine": cs.engine_info("pandas", "numpy", "scipy"),
    "n": n,
    "summary": summary,
    "apa": "; ".join(f"{LABELS[t]} = {res[t]['stat']:.2f}, {pf(res[t])}" for t in battery),
    "statistics": [{"key": "stat", "label": LABELS[battery[0]], "value": main["stat"]}, {"key": "p", "label": "p", "value": main["p"]},
                   {"key": "d", "label": "Recommended d", "value": values["d_recommended"]}],
    "tables": [{
        "key": "tests", "title": "Tests",
        "columns": [{"key": "test", "label": "Test", "type": "string"}, {"key": "h0", "label": "H₀", "type": "string"},
                    {"key": "statistic", "label": "Statistic", "type": "number"}, {"key": "p", "label": "p", "type": "pvalue"},
                    {"key": "p_note", "label": "", "type": "string"}, {"key": "lags", "label": "Lags / bandwidth", "type": "integer"},
                    {"key": "crit_5", "label": "5 % critical value", "type": "number"}, {"key": "verdict", "label": "At α = .05", "type": "string"}],
        "rows": rows,
    }],
    "effectSizes": [],
    "assumptions": [],
    "warnings": warnings,
    "notes": notes,
    "charts": charts,
    "values": values,
})

ADF 0.99, PP 0.36, DF-GLS 0.91, KPSS 0.01. The recommended dd is 2.

Look at the plot before you accept that. What's in this series that these tests don't address?

04

A recommendation isn't a model

Predict

Predict first

Monthly passengers have growing seasonal swings. The battery counts regular differences only. What would you do before settling on two of them?

Use d = 2 as it isDeal with the season and the growing swings firstIgnore differencing entirely
Reveal

Deal with the season and the swings first: logs, then a seasonal difference. The classic airline model uses one regular and one seasonal difference: ARIMA(0,1,1)(0,1,1)[12]. A backtest decides between candidates. The battery's dd is a starting point, not an answer.

05

A break can look like a unit root

Predict

Predict first

A series is stationary around a level, and that level jumps once. Perron (1989) asked what ADF does with that.

What do you expect?

Reject the unit root more easilyFail to reject the unit rootIt makes no difference
Reveal

It fails to reject. To ADF, a one-time jump looks like a permanent shock. And KPSS tends to reject stationarity for the same series. So both can point to a unit root that isn't there, when the real story is one break.

06

Zivot–Andrews

Read

Zivot–Andrews searches over break dates, and tests for a unit root against "stationary with one break". Break in sets where the break may be: level, trend, or both.

On the Nile, allowing both, tt = −6.84, p < .001, with the break after observation 27. The series starts in 1871, so that is around 1898, the date of a well-documented drop in the Nile's flow. KPSS suggested a unit root. With one break allowed, the picture changes.

On a simulated level shift, tt = −8.43, with the break after observation 119.

07

Schmidt–Phillips

Reflect

Schmidt–Phillips is a Lagrange multiplier test with a linear trend. Its parameters are defined the same way under both hypotheses, which ADF's aren't. Its p-values come from simulation, on the shared random stream.

For Lake Huron, Z(τ)Z(\tau) = −3.18, p = 0.07 from 299 simulations, close to the Phillips–Perron result you saw.

If several tests agree, what do you gain? If they disagree, what would you do next: run more tests, or plot and think about what happened to the series?

08

Check your understanding

Checkpoint

Check yourself

KPSS gives p = 0.01, and ADF gives p = 0.60. What's the reading?

Show the answer

Answer: b

KPSS rejects stationarity and ADF can't reject a unit root, which is the "unit root" cell. Check the plot for a break.

Check yourself

ADF rejects a unit root, and KPSS rejects stationarity. What should you look at first?

Show the answer

Answer: c

A conflict is information. Over-differencing costs you forecast accuracy.

Check yourself

Zivot–Andrews rejects with a break around 1898. Which statement can you defend?

Show the answer

Answer: a

The test allows a single break, and doesn't establish that one exists or what caused it. Use change-point lessons and subject knowledge for that.

09

Do it in CodeSplash

In the app

Test defaults to the battery. Pick KPSS, Zivot–Andrews (one break) or Schmidt–Phillips (LM) for a single test.

Python
import pandas as pd
from statsmodels.tsa.stattools import adfuller, kpss, zivot_andrews

y = pd.read_csv("nile.csv")["flow"]
print(adfuller(y)[:2])
print(kpss(y, regression="c", nlags="auto")[:2])
print(zivot_andrews(y, regression="ct")[:2])
R
# install.packages("urca")
y <- as.numeric(Nile)
summary(urca::ur.kpss(y, type = "mu"))
summary(urca::ur.za(y, model = "both"))
summary(urca::ur.sp(y, type = "tau", pol.deg = 1))

Packages choose lags and bandwidths differently, so their numbers can differ from the card's.

10

Recap

Recap
  • KPSS reverses the null, so reading it beside ADF gives a two-way table.
  • The battery's recommended dd counts regular differences only, and it ignores seasons.
  • One break can mimic a unit root. Zivot–Andrews lets one break in, and Schmidt–Phillips gives another view with a trend.
  • When tests conflict, go back to the plot before you run another test.

Concepts in this lesson