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, **kwargs)¶ 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 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.
- anchor
int
,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’.
- repetitions
int
,optional
Number of simulated paths to generate. Default is 1 simulated path.
- exogarray_like,
optional
New observations of exogenous regressors, if applicable.
- nsimulations
- Returns
- simulated_obs
array
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.
- simulated_obs