PerturbationDSGEResult.simulate#

PerturbationDSGEResult.simulate(n=200, *, seed=None, burn=_SIMULATION_BURN)[source]#

A fresh sample of the observables at the estimate.

Standard-normal structural shocks drive the pruned solution from the steady state, the first burn periods are discarded, and the observables are read through the model’s measurement equation with its stated measurement noise.

Parameters:
  • n (int) – Observations kept.

  • seed (int | Generator | None) – Seed or generator.

  • burn (int) – Periods discarded from the start.

Return type:

NDArray[double]

Returns:

An array of shape (n, p) in the order of the data columns.

Raises:

SpecificationError – If the counts are not usable.

Example

>>> import numpy as np
>>> class Latent:
...     parameter_names, bounds = ("rho", "sigma"), ((0.0, 0.99), (0.01, 1.0))
...     n_states, n_controls = 1, 1
...     def equations(self, th, y_next, y, x_next, x):
...         return np.array([y[0] - x[0], x_next[0] - th[0] * x[0]])
...     def steady_state(self, th):
...         return np.zeros(1), np.zeros(1)
...     def shock_loading(self, th):
...         return np.array([[th[1]]])
...     def observation(self, th):
...         return np.array([[0.0, 1.0]]), np.zeros(1), np.array([[1e-4]])
...     def log_prior(self, th):
...         return 0.0
>>> rng = np.random.default_rng(0)
>>> res = PerturbationDSGE(Latent(), rng.standard_normal(80), order=1).fit([0.5, 0.5])
>>> sample = res.simulate(50, seed=1)
>>> sample.shape, bool(np.allclose(sample, res.simulate(50, seed=1)))
((50, 1), True)
>>> res.simulate(0)
Traceback (most recent call last):
cultivars.exceptions.SpecificationError: n must be positive and burn non-negative; ...