cultivars.diagnostics.seasonality#
Seasonal unit roots: is the seasonal pattern deterministic, or does it wander?
Seasonal differencing \(1 - L^s\) removes \(s\) unit roots at once, one at every frequency \(\omega_k = 2\pi k / s\),
and a series rarely needs all of them: a stable seasonal pattern is handled by dummies, a unit root at the zero frequency by \(1 - L\), and only a pattern whose summers slowly turn into winters by the seasonal difference. Over-differencing a stable pattern plants a moving-average unit root the model then has to undo, so which factors are needed is a question to test, not assume. HEGY (1990) tests each root separately in one regression, with the seasonal random walk as the null, so the augmented Dickey-Fuller reading carries over frequency by frequency: a \(t\) that cannot reject at the zero frequency and \(F\) statistics that reject at every seasonal one say “difference once, use dummies”. Canova and Hansen (1995) turn the null around, as KPSS does for the zero frequency: stationary seasonality against a unit root at the frequency tested, so that a series HEGY cannot reject a seasonal root for and Canova-Hansen cannot reject stationarity for is one the sample does not decide, and that is a finding.
Two commitments shape the surface. First, both tests are read against
simulated laws rather than the published tables. HEGY’s finite-sample
null is drawn at the sample size and deterministic set in hand for any
even period, so a monthly test with a trend and dummies is not read
against a quarterly table, and the Canova-Hansen limit is the
generalized von Mises law, drawn as the integral of a squared Brownian
bridge of the tested dimension. Second, every frequency is a row and
every row is a full record: the headline record carries the others as
companions, each with its own tail, p-value, and critical values,
so a single frequency can be read alone, the joint statistic can be
read as the headline, and a mixed table in which \(t\) rows reject
low and \(F\) rows reject high still reads correctly through
reject.
Layout. SeasonalUnitRootTest is the record, a
UnitRootTest with the family
and period added and the title and reading notes a mixed-tail table
needs; hegy() and canova_hansen() are the producers. The
numerics live in _core: _validate_seasonal checks the period
and the sample, _hegy_statistics builds the filtered regressors and
the regression, _select_hegy_lags chooses the augmentation on a
common sample, _hegy_null_draws simulates the seasonal random walk
through the same regression, _canova_hansen computes the LM
statistics and their dimensions, _von_mises_draws simulates the
bridge integrals, _frequency_labels names the frequencies, and
_simulated_critical_values turns either set of draws into a
p-value and critical values in the row’s tail; the Schwert and
Newey-West bandwidth rules and the replication default are the
module’s named constants.
References
Hylleberg, S., Engle, R. F., Granger, C. W. J., & Yoo, B. S. (1990). Seasonal integration and cointegration. Journal of Econometrics, 44(1-2), 215-238.
Beaulieu, J. J., & Miron, J. A. (1993). Seasonal unit roots in aggregate U.S. data. Journal of Econometrics, 55(1-2), 305-328.
Canova, F., & Hansen, B. E. (1995). Are seasonal patterns constant over time? A test for seasonal stability. Journal of Business & Economic Statistics, 13(3), 237-252.
Ghysels, E., & Osborn, D. R. (2001). The Econometric Analysis of Seasonal Time Series. Cambridge University Press.
Example
A random walk with a fixed quarterly pattern: HEGY keeps the root at frequency zero and rejects every seasonal one, Canova-Hansen keeps stationary seasonality, and together they say “difference once and model the season with dummies”:
>>> import numpy as np
>>> rng = np.random.default_rng(0)
>>> y = np.cumsum(rng.standard_normal(200)) + np.tile([1.0, -0.5, 2.0, -2.5], 50)
>>> root = hegy(y, period=4, replications=500, seed=0)
>>> root.reject(), [c.reject() for c in root.companions]
(False, [True, True, True, True])
>>> canova_hansen(y, period=4, seed=0).reject()
False
Classes#
Verdict of a seasonal unit-root or seasonal-stability test, one frequency per row. |
Functions#
|
Canova-Hansen test of stationary seasonality against a seasonal unit root. |
|
HEGY test of a unit root at each seasonal frequency, and at the zero frequency. |