cultivars.multivariate.nonlinear.threshold#
The threshold vector autoregression: two systems, one observable switch.
A TVAR is two complete VARs – coefficients, deterministics, and innovation covariance – glued along a threshold on an observable variable,
below the split one system generates the data, above it the other. The regime is computed, never inferred, which is what separates this family from the Markov-switching one and what makes estimation least squares rather than EM. The canonical macro-finance use is exactly this shape: credit conditions tighten past some level and the whole transmission mechanism changes, not just one coefficient (Balke, 2000).
Two commitments shape the surface. First, the estimator is honest about
the geometry of the problem. The likelihood is a step function of the
threshold – piecewise constant, nowhere differentiable in it – so no
gradient method applies, and the search is an exhaustive grid over trimmed
quantiles of the transition variable (and over the delays 1..order
when the delay is left to be chosen, which is allowed only for a
self-exciting model) with regime-wise multivariate least squares at each
candidate. The criterion is the total Gaussian log-likelihood with a
separate covariance per regime,
\(\ell_L(\hat\Sigma_L) + \ell_U(\hat\Sigma_U)\); a sum of squares
would weight the equations by their innovation variances and let the
noisiest series choose the split, and holding the covariance fixed across
regimes would assume away the volatility shift that is usually half the
finding. Second, everything downstream must name a regime, and the result
refuses to pretend otherwise: there is no single companion matrix, no
single moving-average representation, and no chi-squared linearity test
– the threshold is not identified under the null (Davies; Hansen, 1996),
so TVARResult.likelihood_ratio_test() raises rather than returning a
well-formed and wrong p-value, and information criteria rank threshold
specifications against one another without testing for a threshold.
Impulse responses, variance decompositions and moving-average matrices
are regime-conditional linearizations, stated as such; the forecast is
the skeleton iteration, exact at one step and an approximation beyond,
because the multi-step conditional mean of a nonlinear model averages the
switch over future shocks. Standard errors are not yet offered.
Layout. TVAR validates on
_ThresholdVectorAutoRegressionModel in _internals, which takes the
named-or-external transition variable, its delay or delay range and the
aligned design from _ObservedRegimeVectorModel, adds the grid’s
trim and n_grid, and in _fit_regimes scans every delay and
candidate threshold through _split_moments – one regime’s least
squares, residuals, covariance and log-likelihood – skipping candidates
that leave a regime fewer than w + 1 rows or a singular covariance,
and packs a _VectorThresholdFit at the winner. TVARResult
extends _VectorObservedRegimeResult – the two coefficient stacks, the
regime-conditional propagation surface, the forecast, regime-wise
stability and comparison by information criteria – supplying the
indicator weight and a covariance per regime. The smooth relaxation is
smooth_transition; the
nonparametric check on the switch’s shape is
functional_coefficient; regimes
inferred from a latent chain are in
markov_switching; the
univariate model is threshold.
References
Tsay, R. S. (1998). Testing and modeling multivariate threshold models. Journal of the American Statistical Association, 93(443), 1188-1202.
Balke, N. S. (2000). Credit and economic activity: Credit regimes and nonlinear propagation of shocks. Review of Economics and Statistics, 82(2), 344-349.
Hansen, B. E. (1996). Inference when a nuisance parameter is not identified under the null hypothesis. Econometrica, 64(2), 413-430.
Davies, R. B. (1987). Hypothesis testing when a nuisance parameter is present only under the alternative. Biometrika, 74(1), 33-43.
Example
A credit-regime shape in miniature: when the first variable’s lag is at or below zero the system is persistent and quiet, above it the system mean-reverts and its shocks are twice as volatile. The fit finds the split, both coefficient stacks, and the volatility shift:
>>> import numpy as np
>>> rng = np.random.default_rng(0)
>>> y = np.zeros((400, 2))
>>> for t in range(1, 400):
... tight = y[t - 1, 0] > 0.0
... a, scale = (-0.3, 2.0) if tight else (0.6, 1.0)
... y[t] = a * y[t - 1] + scale * rng.standard_normal(2)
>>> res = TVAR(y, order=1, transition_variable="y1", delay=1).fit()
>>> bool(abs(res.threshold) < 0.4), res.n_lower > res.n_upper
(True, True)
>>> lower, upper = np.diag(res.lower_coefficients[0]), np.diag(res.upper_coefficients[0])
>>> bool(np.all(lower > 0.4)), bool(np.all(upper < 0.0))
(True, True)
>>> ratio = np.diag(res.upper_sigma_u) / np.diag(res.lower_sigma_u)
>>> bool(np.all(ratio > 2.5))
True
>>> res.likelihood_ratio_test(res)
Traceback (most recent call last):
cultivars.exceptions.SpecificationError: a chi-squared likelihood-ratio test is not valid ...
Classes#
Two-regime threshold vector autoregression, after Tsay (1998). |
|
A fitted two-regime threshold vector autoregression. |