ETSResults.simulate(nsimulations, anchor=None, repetitions=1, random_errors=None, random_state=None)[source]

Random simulations using the state space formulation.


The number of simulation steps.

anchorint, str, or datetime, optional

First period for simulation. The simulation will be conditional on all existing datapoints prior to the anchor. Type depends on the index of the given endog in the model. Two special cases are the strings ‘start’ and ‘end’. start refers to beginning the simulation at the first period of the sample (i.e. using the initial values as simulation anchor), and end refers to beginning the simulation at the first period after the sample. Integer values can run from 0 to nobs, or can be negative to apply negative indexing. Finally, if a date/time index was provided to the model, then this argument can be a date string to parse or a datetime type. Default is ‘start’. Note: anchor corresponds to the observation right before the start observation in the predict method.

repetitionsint, optional

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


Specifies how the random errors should be obtained. Can be one of the following:

  • None: Random normally distributed values with variance estimated from the fit errors drawn from numpy’s standard RNG (can be seeded with the random_state argument). This is the default option.

  • A distribution function from scipy.stats, e.g. scipy.stats.norm: Fits the distribution function to the fit errors and draws from the fitted distribution. Note the difference between scipy.stats.norm and scipy.stats.norm(), the latter one is a frozen distribution function.

  • A frozen distribution function from scipy.stats, e.g. scipy.stats.norm(scale=2): Draws from the frozen distribution function.

  • A np.ndarray with shape (nsimulations, repetitions): Uses the given values as random errors.

  • "bootstrap": Samples the random errors from the fit errors.

random_stateint or np.random.RandomState, optional

A seed for the random number generator or a np.random.RandomState object. Only used if random_errors is None. Default is None.

simpd.Series, pd.DataFrame or np.ndarray

An np.ndarray, pd.Series, or pd.DataFrame of simulated values. If the original data was a pd.Series or pd.DataFrame, sim will be a pd.Series if repetitions is 1, and a pd.DataFrame of shape (nsimulations, repetitions) else. Otherwise, if repetitions is 1, a np.ndarray of shape (nsimulations,) is returned, and if repetitions is not 1 a np.ndarray of shape (nsimulations, repetitions) is returned.

Last update: Dec 14, 2023