ARMAResult.simulate#
- ARMAResult.simulate(n=200, *, seed=None, burn=_SIMULATION_BURN)[source]#
A fresh sample path at the fitted parameters.
The stationary ARMA part – seasonal and non-seasonal polynomials multiplied out – is generated from a zero start over
burn + nperiods with the firstburndiscarded; the deterministic block is added on the differenced scale with the time index running1 .. n, exactly as the estimator laid it out; and the result is integrateddandDtimes from zero initial levels, so the firstd + sDentries of the returned path are zero.- Parameters:
- Return type:
- Returns:
An array of shape
(n,).- Raises:
SpecificationError – If the counts are not usable or the fit carries exogenous regressors, whose future the result cannot know.
Example
The simulated variance and mean are the ARMA(1, 1) closed forms at the estimates:
>>> rng = np.random.default_rng(0) >>> e = rng.standard_normal(600) >>> y = np.zeros(600) >>> for t in range(1, 600): ... y[t] = 0.6 * y[t - 1] + e[t] + 0.4 * e[t - 1] >>> res = ARMA(y, order=(1, 1)).fit() >>> path = res.simulate(50000, seed=0) >>> phi, theta = float(res.ar_params[0]), float(res.ma_params[0]) >>> variance = res.sigma2 * (1 + 2 * phi * theta + theta**2) / (1 - phi**2) >>> bool(abs(path.var() - variance) < 0.05), bool(abs(path.mean() - res.beta[0]) < 0.05) (True, True) >>> ARIMA(np.cumsum(y), order=(1, 1, 1)).fit().simulate(1) Traceback (most recent call last): ... cultivars.exceptions.SpecificationError: n must exceed the integration orders (1); ...