Repository navigation
Description
Title
Feature proposal: Johansen cointegration test with Fourier-type smooth nonlinear trends (Kurita & Shintani, 2025)
Body
Summary
I'd like to gauge interest in adding the Johansen trace test with Fourier-type
smooth nonlinear deterministic trends restricted to the cointegrating relations
to statsmodels.tsa.vector_ar, alongside the existing coint_johansen /
VECM implementations. This is the test developed in:
Kurita, T. & Shintani, M. (2025). Johansen test with Fourier-type smooth
nonlinear trends in cointegrating relations. Econometric Reviews, 44(10),
1589–1616. https://doi.org/10.1080/07474938.2025.2530640
I have a working external implementation (fjohansen, MIT-licensed,
~2.5k LOC, on PyPI: https://pypi.org/project/fjohansen/) and I'm willing to
port and relicense it as BSD-3 for statsmodels if maintainers think it's in
scope. Opening this issue first per the usual practice of discussing larger
additions before sending a PR.
What the test does
Standard Johansen assumes deterministic terms in the cointegrating relations
are at most a linear trend. Many macro/finance series show smooth structural
change that a linear trend cannot capture (e.g. long-rate term premia, real
exchange rates, demographic-driven trends). KS-2025 augment the cointegrating
space with a low-frequency Fourier basis
f_t = (sin(2π k t / T), cos(2π k t / T)), k ∈ {1, …, K}
restricted to the cointegrating relations. They derive the limit distribution
of the trace statistic under each of the five Johansen deterministic-component
cases and tabulate critical values. A pre-step using the Perron–Shintani–Yabu
FGLS Wald test selects k from the data.
Why this belongs in statsmodels (or doesn't)
For:
- Fills a real gap. The current
VECMAPI hard-codes Johansen's five
deterministic cases; users with smooth structural change have no in-package
option. - Clean fit: the test reuses the reduced-rank regression machinery already
instatsmodels.tsa.vector_ar.vecm. The Fourier columns are additional
regressors restricted to the cointegrating relations. - Tractable critical values: response-surface coefficients are published in
the paper, so we don't need a Monte Carlo at import time.
Against (anticipated objections):
- It's one paper, one year old. Maintainers may prefer to wait for the
technique to settle in the literature. - Adds a second deterministic-trend "family" to the VECM API surface, which
needs a clean signature so users don't get confused with the existing
deterministic=argument.
I'd defer to maintainers on both.
Proposed API shape (sketch — happy to revise)
from statsmodels.tsa.vector_ar.vecm import coint_johansen_fourier
res = coint_johansen_fourier(
endog, # T x K array
det_order=1, # one of Johansen's five cases
k_ar_diff=2, # lag order in differences
fourier_freqs=None, # int, list[int], or None → auto-select via PSY
)
res.trace_stat # mirrors coint_johansen.trace_stat / .lr1
res.trace_stat_crit_vals # mirrors coint_johansen.cvt (90/95/99%)
res.eig # eigenvalues from the reduced-rank regression
res.fourier_freqs # NEW: frequencies used (auto-selected or supplied)
res.selected_rank # NEW: sequential-5%-test rankReuses the attribute names from JohansenTestResult so existing rank-test
consumers are a near drop-in.
Scope of the PR I'd open if greenlit
statsmodels/tsa/vector_ar/vecm.py— addcoint_johansen_fourierand a
thinVECMFourierresults class (subclass of the existing results).statsmodels/tsa/vector_ar/_fourier_trend.py(new) — basis construction,
PSY frequency selection, response-surface critical values, p-values.statsmodels/tsa/vector_ar/tests/test_johansen_fourier.py— unit tests
against the published tables in KS-2025 (Table B1 critical values, Table 2
size/power) and against my external implementation as a regression suite.- Docs: extend
vector_ar.rstwith a short worked example. - License: BSD-3 (I am the sole author of the existing MIT code, so I can
relicense unilaterally). - Dependencies: numpy + scipy only. No new top-level deps.
I'd keep fjohansen on PyPI as a thin shim around the statsmodels function so
existing users don't break.
Questions for maintainers before I start
- Is this in scope? A one-line "yes proceed", "yes but with X changes",
or "no, too niche" is exactly what I'm looking for here — I'd rather hear
"no" now than after a 2k-line PR. - API placement. Free function (
coint_johansen_fourier) vs. a
fourier=...kwarg oncoint_johansen? I lean toward a separate function
to avoid overloading the existing signature, but I'll defer. - Critical-value source. OK to ship the published response-surface
coefficients as a constant table, with asimulate_critical_valueshelper
for users who want to verify? Or do you want simulated values regenerated
in CI? - PSY pre-step. Ship as a public helper in
statsmodels.tsa.stattools
(it's useful on its own — Perron, Shintani & Yabu 2021), or keep it
private under_fourier_trend?
Happy to send a small proof-of-concept PR (just the basis + a single test
case) to demonstrate the shape before doing the full port, if that's helpful.
Thanks for reading.
Disclosure: I'm the author of the external fjohansen package and
maintainer of https://github.com/merwanroudane/fjohansen.
Activity