SeasonalUnitRootTest#

class cultivars.diagnostics.seasonality.SeasonalUnitRootTest(*, statistic, pvalue, name, critical_values, null, nobs, lower_tail=False, companions=(), trend, lags, method, break_index=None, family, period)[source]#

Verdict of a seasonal unit-root or seasonal-stability test, one frequency per row.

Seasonal differencing \(1 - L^s\) factors over the \(s\) roots of unity,

\[1 - L^s = (1 - L)(1 + L) \prod_{k = 1}^{s/2 - 1} \bigl(1 - 2\cos(2\pi k / s)\, L + L^2\bigr),\]

one factor per frequency \(\omega_k = 2\pi k / s\), and a seasonal test is a question asked at each factor. This record is a UnitRootTest whose companions are the other frequencies of the same regression, and whose rows may reject in different tails: HEGY’s \(t\) statistics at the two real roots, \(\omega = 0\) and \(\omega = \pi\), reject in the lower tail, its \(F\) statistics at the complex pairs and the joint restrictions in the upper; every Canova-Hansen row, whose null is stationarity, in the upper. The headline record is HEGY’s \(t\) at frequency zero, or Canova-Hansen’s joint statistic, and lower_tail is set per row so reject() reads each correctly. The record adds nothing to the fields but the family and the period; what it adds is the title and the reading notes a mixed-tail table needs.

Variables:
  • family (str) – "HEGY" or "Canova-Hansen".

  • period (int) – Seasonal period s.

Note

The two families answer complementary questions and are read together, as ADF and KPSS are at the zero frequency: a frequency HEGY cannot reject a root at and Canova-Hansen cannot reject stationarity at is one the sample does not decide. The Canova-Hansen lags field is the kernel bandwidth, not an augmentation lag count, and its method says so.

See also

  • hegy() and canova_hansen() – the producers.

  • UnitRootTest – the base, with the zero-frequency tests.

  • kpss() – the zero-frequency counterpart of Canova-Hansen.

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.

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.

Example

A random walk with a fixed quarterly pattern: HEGY keeps the root at frequency zero and rejects every seasonal one, which reads “difference once and use dummies”, and the rows reject in different tails:

>>> import numpy as np
>>> rng = np.random.default_rng(0)
>>> season = np.tile([1.0, -0.5, 2.0, -2.5], 50)
>>> y = np.cumsum(rng.standard_normal(200)) + season
>>> test = hegy(y, period=4, seed=0)
>>> test.family, test.period, test.lower_tail, test.reject()
('HEGY', 4, True, False)
>>> [(c.lower_tail, c.reject()) for c in test.companions]
[(True, True), (False, True), (False, True), (False, True)]

Canova-Hansen on the same series keeps stationary seasonality at every frequency:

>>> test = canova_hansen(y, period=4, seed=0)
>>> test.family, test.lower_tail, test.reject()
('Canova-Hansen', False, False)

Attributes#

family

"HEGY", unit root under the null, or "Canova-Hansen", stationarity.

period

Seasonal period \(s\); even, since the Nyquist root \(\omega = \pi\) is tested.

break_index

First observation of the new regime for a break-allowing test; None otherwise.

companions

Further statistics of the same test on the same sample.

critical_values

{"1%", "5%", "10%"} critical values.

lags

Augmentation lags of the regression, or the kernel bandwidth, whichever the test uses.

lower_tail

Whether rejection lies in the lower tail.

method

How lags was chosen, or which kernel was used.

name

The test.

nobs

Observations the statistic was computed on.

null

The hypothesis under test.

pvalue

Its p-value, or None for a test known only through tabulated critical values.

statistic

The test statistic.

trend

"n", "c", or "ct", as the producer accepted it.

Methods#

reject(*[, alpha])

Whether the null is rejected at level alpha.

summary()

The test as a table, renderable as text, HTML, or a dataframe.