tsay#
- cultivars.diagnostics.nonlinearity.tsay(endog, *, order, delay=1)[source]#
Tsay’s (1989) arranged-autoregression test of linearity against a threshold.
The AR(\(p\)) rows are sorted by the threshold variable \(y_{t-d}\) and the regression fitted recursively down the sorted sample from \(3\sqrt{T} + p\) rows on, each step producing a standardized one-step predictive residual \(\hat e_t\). Under linearity the sorting is irrelevant, the predictive residuals are white, and they are orthogonal to the regressors; under a threshold the recursion crosses it at some point in the sorted sample, after which the residuals shift in mean with the regressors. The statistic is the \(F\) test of the predictive residuals on the regressors,
\[\hat e_t = \gamma^\top w_t + v_t, \qquad F = \frac{(SSR_0 - SSR_1) / (p + 1)}{SSR_1 / (n - 2p - 1)},\]with \(n\) the rows after the recursion’s start. It assumes no functional form for the transition, only that the threshold variable is a lag of the series, and is the natural first look before a SETAR; at order 1 it holds 5% size on 100 observations.
- Parameters:
- Return type:
- Returns:
The
LinearityTestnamed"Tsay", withalternative="threshold"and no companions.- Raises:
SpecificationError – If the order or delay is not positive or the series is too short for the auxiliary regression.
NumericalError – If a value is not finite, the recursion cannot start, or the final regression is degenerate.
Note
The test does not locate the threshold;
hansen_threshold()does. Its power is against a shift in the conditional mean across the sorted sample, so a threshold in the variance alone is not what it catches.See also
hansen_threshold()– the sup-F test for the same alternative, with a threshold estimate.terasvirta()– the test for a smooth rather than abrupt transition.SETAR– the model a rejection licenses.
References
Tsay, R. S. (1989). Testing and modeling threshold autoregressive processes. Journal of the American Statistical Association, 84(405), 231-240.
Tong, H. (1990). Non-linear Time Series: A Dynamical System Approach. Oxford University Press.
Example
A two-regime SETAR is rejected; white noise is not:
>>> import numpy as np >>> rng = np.random.default_rng(0) >>> y = np.zeros(300) >>> for t in range(1, 300): ... slope = 0.8 if y[t - 1] <= 0.0 else -0.5 ... y[t] = slope * y[t - 1] + rng.standard_normal() >>> tsay(y, order=1).reject() True >>> tsay(rng.standard_normal(300), order=1).reject() False