statsmodels.tsa.statespace.sarimax.SARIMAXResults.simulate

SARIMAXResults.simulate(nsimulations, measurement_shocks=None, state_shocks=None, initial_state=None, anchor=None, repetitions=None, exog=None, extend_model=None, extend_kwargs=None, pretransformed_measurement_shocks=True, pretransformed_state_shocks=True, pretransformed_initial_state=True, random_state=None, **kwargs)

Simulate a new time series following the state space model

Parameters:
nsimulationsint

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 initial state vector to use in simulation, 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. This must be specified if anchor is anything other than “start” or 0.

anchorint, str, or datetime, optional

Starting point from which to begin the simulations; type depends on the index of the given endog model. Two special cases are the strings ‘start’ and ‘end’, which refer to starting at the beginning and end of the sample, respectively. If a date/time index was provided to the model, then this argument can be a date string to parse or a datetime type. Otherwise, an integer index should be given. Default is ‘start’.

repetitionsint, optional

Number of simulated paths to generate. Default is 1 simulated path.

exogarray_like, optional

New observations of exogenous regressors, if applicable.

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.

random_state{None, int, Generator, RandomState}, optional

If seed is None (or np.random), the class:~numpy.random.RandomState singleton is used. If seed is an int, a new class:~numpy.random.RandomState instance is used, seeded with seed. If seed is already a class:~numpy.random.Generator or class:~numpy.random.RandomState instance then that instance is used.

Returns:
simulated_obsndarray

An array of simulated observations. If repetitions=None, then it will be shaped (nsimulations x k_endog) or (nsimulations,) if k_endog=1. Otherwise it will be shaped (nsimulations x k_endog x repetitions). If the model was given Pandas input then the output will be a Pandas object. If k_endog > 1 and repetitions is not None, then the output will be a Pandas DataFrame that has a MultiIndex for the columns, with the first level containing the names of the endog variables and the second level containing the repetition number.

See also

impulse_responses

Impulse response functions


Last update: Mar 18, 2024