ADF, Phillips–Perron and DF-GLS
Handle autocorrelated errors with augmenting lags or a long-run variance correction, and use GLS detrending for more power near a unit root.
What runs in CodeSplash
- STAT197Augmented Dickey–Fuller test Runs in CodeSplash
- STAT198Phillips–Perron test Runs in CodeSplash
- STAT199DF GLS or Elliott–Rothenberg–Stock test Runs in CodeSplash
- Unit-root and stationarity tests Verified in Python and R
You will be able to
- Say why plain Dickey–Fuller fails with autocorrelated errors, and how ADF and PP each respond
- Choose lags and deterministic terms for a unit-root test
- Explain why DF-GLS has more power near a unit root
Read first
Augmented Dickey–Fuller
ReadYou still test . The new choice is . Lag selection offers AIC, BIC, or a general-to-specific t rule. Fixed lags overrides them.
Simulated AR(1) data with BIC chooses 0 lags, as it should: the errors of an AR(1) already have no memory. Here = −7.40, p < .001.
Predict the cost of lags
PredictPredict first
A colleague says: "To be safe, always use 24 lags in ADF." What's the catch?
Reveal
It costs power. Each lag uses up degrees of freedom and leaves less information to detect stationarity. Too few lags, and the error rate is off. That's why a selection rule starts from a maximum, here, and works down.
Phillips–Perron
In the appPhillips–Perron estimates the long-run variance with a Bartlett kernel, and adjusts with it. There are no extra regressors to choose, only a bandwidth.
Phillips–Perron Z(τ) = -2.77, p = .062
- Phillips–Perron Z(τ)
- −2.773
- p
- 0.0622
- Recommended d
- 1
Plots
View data
| year | level |
|---|---|
| 1,875 | 580.38 |
| 1,876 | 581.86 |
| 1,877 | 580.97 |
| 1,878 | 580.80 |
| 1,879 | 579.79 |
| 1,880 | 580.39 |
| 1,881 | 580.42 |
| 1,882 | 580.82 |
| 1,883 | 581.40 |
| 1,884 | 581.32 |
| 1,885 | 581.44 |
| 1,886 | 581.68 |
| 1,887 | 581.17 |
| 1,888 | 580.53 |
| 1,889 | 580.01 |
| 1,890 | 579.91 |
| 1,891 | 579.14 |
| 1,892 | 579.16 |
| 1,893 | 579.55 |
| 1,894 | 579.67 |
| 1,895 | 578.44 |
| 1,896 | 578.24 |
| 1,897 | 579.10 |
| 1,898 | 579.09 |
| 1,899 | 579.35 |
| 1,900 | 578.82 |
| 1,901 | 579.32 |
| 1,902 | 579.01 |
| 1,903 | 579 |
| 1,904 | 579.80 |
| 1,905 | 579.83 |
| 1,906 | 579.72 |
| 1,907 | 579.89 |
| 1,908 | 580.01 |
| 1,909 | 579.37 |
| 1,910 | 578.69 |
| 1,911 | 578.19 |
| 1,912 | 578.67 |
| 1,913 | 579.55 |
| 1,914 | 578.92 |
| 1,915 | 578.09 |
| 1,916 | 579.37 |
| 1,917 | 580.13 |
| 1,918 | 580.14 |
| 1,919 | 579.51 |
| 1,920 | 579.24 |
| 1,921 | 578.66 |
| 1,922 | 578.86 |
| 1,923 | 578.05 |
| 1,924 | 577.79 |
| 1,925 | 576.75 |
| 1,926 | 576.75 |
| 1,927 | 577.82 |
| 1,928 | 578.64 |
| 1,929 | 580.58 |
| 1,930 | 579.48 |
| 1,931 | 577.38 |
| 1,932 | 576.90 |
| 1,933 | 576.94 |
| 1,934 | 576.24 |
First 60 of 98 rows.
View data
| level |
|---|
| 580.38 |
| 581.86 |
| 580.97 |
| 580.80 |
| 579.79 |
| 580.39 |
| 580.42 |
| 580.82 |
| 581.40 |
| 581.32 |
| 581.44 |
| 581.68 |
| 581.17 |
| 580.53 |
| 580.01 |
| 579.91 |
| 579.14 |
| 579.16 |
| 579.55 |
| 579.67 |
| 578.44 |
| 578.24 |
| 579.10 |
| 579.09 |
| 579.35 |
| 578.82 |
| 579.32 |
| 579.01 |
| 579 |
| 579.80 |
| 579.83 |
| 579.72 |
| 579.89 |
| 580.01 |
| 579.37 |
| 578.69 |
| 578.19 |
| 578.67 |
| 579.55 |
| 578.92 |
| 578.09 |
| 579.37 |
| 580.13 |
| 580.14 |
| 579.51 |
| 579.24 |
| 578.66 |
| 578.86 |
| 578.05 |
| 577.79 |
| 576.75 |
| 576.75 |
| 577.82 |
| 578.64 |
| 580.58 |
| 579.48 |
| 577.38 |
| 576.90 |
| 576.94 |
| 576.24 |
First 60 of 98 rows.
Tests
| Test | H₀ | Statistic | p | Lags / bandwidth | 5 % critical value | At α = .05 | |
|---|---|---|---|---|---|---|---|
| Phillips–Perron Z(τ) | unit root | −2.773 | .062 | 11 | −2.892 | unit root not rejected |
- 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 9dbe4f6a1f62c235
# Dataset: ts_lakehuron (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/ts_lakehuron.parquet", col_select = c("level", "year")))
n_input <- nrow(df)
df <- df[stats::complete.cases(df[c("level", "year")]), , 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("level", "year")) # infinite values stop the run (registry/errors.yaml)
# %% Series
VALUE <- "level"
TIME <- "year"
TEMPORAL <- FALSE
TEST <- "pp"
DET <- "c"
LAG_RULE <- "aic"
LAGS <- NULL
BW <- "long"
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
))
Phillips–Perron Z(τ) = -2.77, p = .062
- Phillips–Perron Z(τ)
- −2.773
- p
- 0.0622
- Recommended d
- 1
To keep this page light, the plots are shown once, under the R tab.
Tests
| Test | H₀ | Statistic | p | Lags / bandwidth | 5 % critical value | At α = .05 | |
|---|---|---|---|---|---|---|---|
| Phillips–Perron Z(τ) | unit root | −2.773 | .062 | 11 | −2.892 | unit root not rejected |
- 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 9dbe4f6a1f62c235
# Dataset: ts_lakehuron (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/ts_lakehuron.parquet", columns=["level", "year"])
n_input = len(df)
df = df.dropna(subset=["level", "year"]) # 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, ["level", "year"]) # infinite values stop the run (registry/errors.yaml)
# %% Series
VALUE = "level"
TIME = "year"
TEMPORAL = False
TEST = "pp"
DET = "c"
LAG_RULE = "aic"
LAGS = None
BW = "long"
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,
})
For Lake Huron's level, with a long bandwidth of 11 lags, = −2.77, p = .062. The 5% critical value is −2.89.
The series has only 98 years. How would you read a p-value this close to the line?
Low power, and what helps
PredictPredict first
A series is stationary, with , and has 100 values. Will ADF usually reject the unit root?
Reveal
Often not. Its power is low near . "Fail to reject" is the common outcome for persistent stationary series, so don't read it as "there's a unit root".
DF-GLS
ReadDF-GLS (Elliott, Rothenberg & Stock, 1996) first removes the deterministic part by quasi-differencing, using a slightly below 1. The test then runs on the detrended series.
This can give much more power against nearly-integrated alternatives than ADF.
On monthly CO2, with a constant, a trend and 12 lags, = −0.01 against a 5% value of −2.91. The p-value is 0.10, the top of the table: read it as "at least this".
What did the choice of terms do?
Reflect| You see | Deterministic terms |
|---|---|
| Wanders with no direction | Constant (a level) |
| Clear upward or downward drift | Constant and linear trend |
| Centered on a known zero, such as returns | None (mean zero) |
Too few terms means a trending stationary series looks like a unit root. Too many costs power. Which row fits a monthly customer count? A daily stock return?
Check your understanding
CheckpointCheck yourself
The largest lag considered is . For , what is it?
Show the answer
Answer: 12
.
Check yourself
What is the main difference between ADF and Phillips–Perron?
Show the answer
Answer: b
Both have the unit-root null and the same critical values. They treat short-run dependence in different ways.
Check yourself
When is DF-GLS most useful?
Show the answer
Answer: b
GLS detrending gives more power near . For a stationarity null, use KPSS.
Do it in CodeSplash
In the appSet Test to Augmented Dickey–Fuller, Phillips–Perron or DF-GLS (Elliott–Rothenberg–Stock). Lag selection and Long-run variance bandwidth appear in the options.
import pandas as pd
from arch.unitroot import DFGLS, PhillipsPerron
from statsmodels.tsa.stattools import adfuller
y = pd.read_csv("lakehuron.csv")["level"]
print(adfuller(y, regression="c", autolag="AIC")[:2])
print(PhillipsPerron(y).summary())
print(DFGLS(y, trend="c").summary())# install.packages("urca")
y <- as.numeric(LakeHuron)
summary(urca::ur.df(y, type = "drift", selectlags = "AIC"))
summary(urca::ur.pp(y, type = "Z-tau", model = "constant", lags = "long"))
summary(urca::ur.ers(y, type = "DF-GLS", model = "constant"))Recap
Recap- ADF adds lags, while Phillips–Perron corrects the statistic, for the same null.
- Lags and deterministic terms are real choices. Use a rule, and look at the plot.
- These tests have low power near a unit root, and DF-GLS helps.
- "Fail to reject" doesn't mean "unit root". Read it with KPSS, next.
Concepts in this lesson