SETARResult.simulate#
- SETARResult.simulate(n=200, *, seed=None, burn=_SIMULATION_BURN)[source]#
A fresh sample path at the fitted parameters.
The regime at each step is read from the simulated series’ own
delay-th lag with the estimator’sz <= rassignment, so only a self-exciting fit can simulate; a TAR fit’s transition variable is an external series whose future is not part of the model. Innovations are Gaussian at the fittedsigma2.- Parameters:
- Return type:
- Returns:
An array of shape
(n,).- Raises:
SpecificationError – If the counts are not usable or the fit is not self-exciting.
Example
>>> import numpy as np >>> rng = np.random.default_rng(0) >>> y = np.zeros(400) >>> for t in range(1, 400): ... y[t] = (0.6 if y[t - 1] <= 0.0 else -0.4) * y[t - 1] + rng.standard_normal() >>> res = SETAR(y, order=1, delay=1).fit() >>> path = res.simulate(300, seed=3) >>> path.shape, bool(np.array_equal(path, res.simulate(300, seed=3))) ((300,), True) >>> share_lower = np.mean(path <= res.threshold) >>> bool(abs(share_lower - res.n_lower / res.nobs) < 0.1) True >>> z = rng.standard_normal(400) >>> x = np.zeros(400) >>> for t in range(1, 400): ... x[t] = (0.5 if z[t - 1] <= 0.0 else -0.5) * x[t - 1] + rng.standard_normal() >>> tar = TAR(x, order=1, delay=1, threshold_variable=z).fit() >>> tar.simulate(10) Traceback (most recent call last): cultivars.exceptions.SpecificationError: a TAR fit cannot simulate its own sample: ...