Skip to content

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.

Advanced ~12 min10 steps

What runs in CodeSplash

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

01

Autocorrelated errors break the plain test

Read

The Dickey–Fuller critical values assume uncorrelated errors. Real series rarely oblige, and using them anyway gives the wrong error rate.

There are two ways out:

  • ADF adds lagged differences to the regression, to soak up the autocorrelation.
  • Phillips–Perron keeps the simple regression, and corrects the statistic afterwards.

Both end up using the same critical values.

02

Augmented Dickey–Fuller

Read
Δyt=α+γ yt−1+∑j=1pβj Δyt−j+et\Delta y_t = \alpha + \gamma\, y_{t-1} + \sum_{j=1}^{p} \beta_j\, \Delta y_{t-j} + e_t

You still test γ=0\gamma = 0. The new choice is pp. 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 τ\tau = −7.40, p < .001.

03

Predict the cost of lags

Predict

Predict first

A colleague says: "To be safe, always use 24 lags in ADF." What's the catch?

None: more lags are always saferIt can cost powerIt changes the null hypothesis
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, 12(n/100)1/412(n/100)^{1/4} here, and works down.

04

Phillips–Perron

In the app

Phillips–Perron estimates the long-run variance with a Bartlett kernel, and adjusts τ\tau with it. There are no extra regressors to choose, only a bandwidth.

Unit-root and stationarity testsRecorded · Python and R agreeRecorded 2026-11-17 · 11 values compared · largest relative difference 5.0e-9
R

Phillips–Perron Z(τ) = -2.77, p = .062

Phillips–Perron Z(τ)
−2.773
p
0.0622
Recommended d
1

Plots

level over timeHow does the series move over time, and where is an estimated break?
View data
yearlevel
1,875580.38
1,876581.86
1,877580.97
1,878580.80
1,879579.79
1,880580.39
1,881580.42
1,882580.82
1,883581.40
1,884581.32
1,885581.44
1,886581.68
1,887581.17
1,888580.53
1,889580.01
1,890579.91
1,891579.14
1,892579.16
1,893579.55
1,894579.67
1,895578.44
1,896578.24
1,897579.10
1,898579.09
1,899579.35
1,900578.82
1,901579.32
1,902579.01
1,903579
1,904579.80
1,905579.83
1,906579.72
1,907579.89
1,908580.01
1,909579.37
1,910578.69
1,911578.19
1,912578.67
1,913579.55
1,914578.92
1,915578.09
1,916579.37
1,917580.13
1,918580.14
1,919579.51
1,920579.24
1,921578.66
1,922578.86
1,923578.05
1,924577.79
1,925576.75
1,926576.75
1,927577.82
1,928578.64
1,929580.58
1,930579.48
1,931577.38
1,932576.90
1,933576.94
1,934576.24

First 60 of 98 rows.

Autocorrelation of levelIs the series autocorrelated, and at which lags (seasonality, AR order)?
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

TestH₀StatisticpLags / bandwidth5 % critical valueAt α = .05
Phillips–Perron Z(τ)unit root−2.773.06211−2.892unit 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
))
Python

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

TestH₀StatisticpLags / bandwidth5 % critical valueAt α = .05
Phillips–Perron Z(τ)unit root−2.773.06211−2.892unit 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, Z(τ)Z(\tau) = −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?

05

Low power, and what helps

Predict

Predict first

A series is stationary, with ϕ=0.95\phi = 0.95, and has 100 values. Will ADF usually reject the unit root?

Yes, nearly alwaysOften not, unless the series is longOnly with a trend term
Reveal

Often not. Its power is low near ϕ=1\phi = 1. "Fail to reject" is the common outcome for persistent stationary series, so don't read it as "there's a unit root".

06

DF-GLS

Read

DF-GLS (Elliott, Rothenberg & Stock, 1996) first removes the deterministic part by quasi-differencing, using a ϕ\phi 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, τ\tau = −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".

07

What did the choice of terms do?

Reflect
You seeDeterministic terms
Wanders with no directionConstant (a level)
Clear upward or downward driftConstant and linear trend
Centered on a known zero, such as returnsNone (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?

08

Check your understanding

Checkpoint

Check yourself

The largest lag considered is 12(n/100)1/412(n/100)^{1/4}. For n=100n = 100, what is it?

Show the answer

Answer: 12

12×11/4=1212 \times 1^{1/4} = 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 ϕ=1\phi = 1. For a stationarity null, use KPSS.

09

Do it in CodeSplash

In the app

Set Test to Augmented Dickey–Fuller, Phillips–Perron or DF-GLS (Elliott–Rothenberg–Stock). Lag selection and Long-run variance bandwidth appear in the options.

Python
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())
R
# 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"))
10

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