statsmodels.regression.recursive_ls.RecursiveLSResults.simulate#

RecursiveLSResults.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, rng=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 of observations.

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.

extend_modelbool, optional

Whether or not to extend the model to accommodate simulating periods outside of the sample. Default is to extend the model if a new exog array is provided or if the model is time-varying.

extend_kwargsdict, optional

Dictionary of keyword arguments to pass to the state space model constructor. For example, for an SARIMAX state space model, this could be used to pass the concentrate_scale=True keyword argument. Any arguments that are not explicitly set in this dictionary will be copied from the current model instance.

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.

rng{None, int, numpy.random.Generator, numpy.random.RandomState}, optional

If rng is None or an int, a new Generator is created (seeded with rng if an int is given). If rng is already a Generator or RandomState instance, 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