TAR.fit#

TAR.fit()[source]#

Estimate the threshold and both regimes by grid search.

Return type:

SETARResult

Returns:

The fitted two-regime autoregression, with self_exciting false.

Raises:

NumericalError – If no candidate split leaves both regimes with at least order + 2 observations.

Example

>>> import numpy as np
>>> rng = np.random.default_rng(1)
>>> z = rng.standard_normal(300)
>>> y = np.zeros(300)
>>> for t in range(1, 300):
...     y[t] = (0.5 if z[t - 1] <= 0.0 else -0.5) * y[t - 1] + rng.standard_normal()
>>> res = TAR(y, order=1, threshold_variable=z).fit()
>>> res.self_exciting, res.n_lower + res.n_upper == res.nobs
(False, True)