TARNNResult#
- class cultivars.univariate.mean_function.TARNNResult(*, endog, fittedvalues, resid, llf, nobs, n_params, order, sigma2, engine, engine_config, delay, threshold, threshold_values, self_exciting, lower_predictor, upper_predictor, n_lower, n_upper)[source]#
A fitted two-regime neural threshold autoregression.
The model
\[\begin{split}y_t = \begin{cases} f_L(y_{t-1}, \ldots, y_{t-p}) + \varepsilon_t, & z_{t-d} \le r, \\ f_U(y_{t-1}, \ldots, y_{t-p}) + \varepsilon_t, & z_{t-d} > r, \end{cases}\end{split}\]with \(z\) the series itself (self-exciting) or an external variable, \(r\) a fixed threshold, and \(f_L\), \(f_U\) two networks trained separately on their regime’s subsample under one pooled innovation variance.
Shares vocabulary with
SETARResult– a delay, a threshold, a lower and an upper regime – but deliberately does not share its base class. That base exposes per-regime companion eigenvalues, and a learned regime has no autoregressive polynomial to take eigenvalues of; inheriting a stationarity property that could only lie is the failure mode this package refuses everywhere else.- Variables:
delay – Delay of the threshold variable.
threshold – The split point, in the units of the threshold variable.
threshold_values – The threshold variable, aligned with
resid.self_exciting – Whether the threshold variable is a lag of the series.
lower_predictor – Learned mean for observations at or below the split.
upper_predictor – Learned mean for observations above it.
n_lower – Observations assigned to the lower regime.
n_upper – Observations assigned to the upper regime.
Note
The inherited fields and properties are those of
ARNNResult. The effective sample dropsmax(order, delay)leading observations so both the feature lags and the threshold lag exist. The threshold is fixed at construction (the median of the lagged threshold variable by default), not searched, so it carries no sampling uncertainty of the kind a searched threshold would, andn_paramscounts the two networks and the variance only.See also
TARNN– the specification that produces this.ARNNResult– one function over the whole sample.SETARResult– the linear-per-regime model, with a searched threshold and per-regime stability verdicts.
Example
A regime map with slope 0.6 below zero and -0.4 above, recovered at a fixed split:
>>> import numpy as np >>> rng = np.random.default_rng(1) >>> z = np.zeros(600) >>> for t in range(1, 600): ... slope = 0.6 if z[t - 1] <= 0 else -0.4 ... z[t] = slope * z[t - 1] + 0.3 * rng.standard_normal() >>> res = TARNN(z, order=1, threshold=0.0).fit() >>> res.nobs, res.n_lower + res.n_upper, res.self_exciting (599, 599, True) >>> point = np.array([[-1.0], [1.0]]) >>> means = res.predict(point, point[:, 0]) >>> bool(abs(means[0] + 0.6) < 0.2), bool(abs(means[1] - -0.4) < 0.2) (True, True)
Attributes#
Lag applied to the threshold variable before the split. |
|
The split point, in the units of the threshold variable. |
|
|
|
|
|
Network trained on the lower-regime subsample. |
|
Network trained on the upper-regime subsample. |
|
Effective-sample observations with |
|
Effective-sample observations with |
|
AIC, BIC, and HQIC derived from the likelihood and parameter count. |
|
Weights and biases across both regime networks. |
|
Nominal learner parameters divided by the effective sample size. |
|
Share of the effective sample's variance the fitted mean explains. |
|
|
|
Sum of squared residuals over the effective sample. |
|
Share of the effective sample assigned to the upper regime. |
Methods#
|
Rank this result against others by an information criterion. |
|
Refuse the test: a network's weights are unidentified under a linear null. |
|
The fitted two-network threshold mean as a noisily observed state space. |
|
Conditional means, routing each row to its regime's learner. |
|
The estimation summary, renderable as text, HTML, or a dataframe. |
|
The aligned per-observation outputs as plain numpy arrays. |
|
The aligned per-observation outputs as a |
The aligned per-observation outputs as a |