statsmodels.tsa.statespace.kalman_filter.KalmanFilter.simulate¶
-
KalmanFilter.simulate(nsimulations, measurement_shocks=
None
, state_shocks=None
, initial_state=None
, pretransformed_measurement_shocks=True
, pretransformed_state_shocks=True
, pretransformed_initial_state=True
, simulator=None
, return_simulator=False
, random_state=None
)[source]¶ Simulate a new time series following the state space model
- Parameters:¶
- nsimulations
int
The number of observations to simulate. If the model is time-invariant this can be any number. If the model is time-varying, then this number must be less than or equal to the number
- measurement_shocksarray_like,
optional
If specified, these are the shocks to the measurement equation, \(\varepsilon_t\). If unspecified, these are automatically generated using a pseudo-random number generator. If specified, must be shaped nsimulations x k_endog, where k_endog is the same as in the state space model.
- state_shocksarray_like,
optional
If specified, these are the shocks to the state equation, \(\eta_t\). If unspecified, these are automatically generated using a pseudo-random number generator. If specified, must be shaped nsimulations x k_posdef where k_posdef is the same as in the state space model.
- initial_statearray_like,
optional
If specified, this is the state vector at time zero, which should be shaped (k_states x 1), where k_states is the same as in the state space model. If unspecified, but the model has been initialized, then that initialization is used. If unspecified and the model has not been initialized, then a vector of zeros is used. Note that this is not included in the returned simulated_states array.
- pretransformed_measurement_shocksbool,
optional
If measurement_shocks is provided, this flag indicates whether it should be directly used as the shocks. If False, then it is assumed to contain draws from the standard Normal distribution that must be transformed using the obs_cov covariance matrix. Default is True.
- pretransformed_state_shocksbool,
optional
If state_shocks is provided, this flag indicates whether it should be directly used as the shocks. If False, then it is assumed to contain draws from the standard Normal distribution that must be transformed using the state_cov covariance matrix. Default is True.
- pretransformed_initial_statebool,
optional
If initial_state is provided, this flag indicates whether it should be directly used as the initial_state. If False, then it is assumed to contain draws from the standard Normal distribution that must be transformed using the initial_state_cov covariance matrix. Default is True.
- return_simulatorbool,
optional
Whether or not to return the simulator object. Typically used to improve performance when performing repeated sampling. Default is False.
- random_state{
None
,int
,Generator
,RandomState
},optionall
If seed is None (or np.random), the numpy.random.RandomState singleton is used. If seed is an int, a new
RandomState
instance is used, seeded with seed. If seed is already aGenerator
orRandomState
instance then that instance is used.
- nsimulations
- Returns:¶
- simulated_obs
ndarray
An (nsimulations x k_endog) array of simulated observations.
- simulated_states
ndarray
An (nsimulations x k_states) array of simulated states.
- simulator
SimulationSmoothResults
If return_simulator=True, then an instance of a simulator is returned, which can be reused for additional simulations of the same size.
- simulated_obs