TVAR.fit#
- TVAR.fit()[source]#
Estimate the threshold, the delay, and both regimes by grid search.
For each candidate delay the trimmed quantile grid of the delayed transition variable is scanned; candidates leaving either regime fewer than
w + 1observations, or with a singular regime covariance, are skipped; the surviving candidate with the largest total log-likelihood fixes the delay, the threshold and both regimes. The covariances are divided by each regime’s own degrees of freedom.- Return type:
- Returns:
The fitted
TVARResult.- Raises:
NumericalError – If no candidate split is admissible.
Example
The hard split and its smooth relaxation rank through the shared comparison surface, and the hard split’s two covariances can differ where the smooth model is forced to share one:
>>> import numpy as np >>> from cultivars.multivariate.nonlinear.smooth_transition import STVAR >>> rng = np.random.default_rng(0) >>> y = np.zeros((300, 2)) >>> for t in range(1, 300): ... a = 0.6 if y[t - 1, 0] <= 0.0 else -0.3 ... y[t] = a * y[t - 1] + rng.standard_normal(2) >>> hard = TVAR(y, order=1, transition_variable="y1", delay=1).fit() >>> smooth = STVAR(y, order=1, transition_variable="y1").fit() >>> hard.n_params, smooth.n_params (19.0, 17.0) >>> table = hard.compare(smooth, criterion="aic") >>> sorted(row[0] for row in table.rows) ['STVAR(1, logistic, d=1)', 'TVAR(1, d=1)'] >>> hard.lower_sigma_u.shape == hard.upper_sigma_u.shape == (2, 2) True