arch.univariate.LS.simulate

LS.simulate(params: ndarray | Series | Sequence[float], nobs: int, burn: int = 500, initial_value: float | ndarray[Any, dtype[float64]] | None = None, x: ndarray | DataFrame | Series | None = None, initial_value_vol: float | ndarray[Any, dtype[float64]] | None = None) DataFrame

Simulates data from a linear regression, AR or HAR models

Parameters:
params: ndarray | Series | Sequence[float]

Parameters to use when simulating the model. Parameter order is [mean volatility distribution] where the parameters of the mean model are ordered [constant lag[0] lag[1] … lag[p] ex[0] … ex[k-1]] where lag[j] indicates the coefficient on the jth lag in the model and ex[j] is the coefficient on the jth exogenous variable.

nobs: int

Length of series to simulate

burn: int = 500

Number of values to simulate to initialize the model and remove dependence on initial values.

initial_value: float | ndarray[Any, dtype[float64]] | None = None

Either a scalar value or max(lags) array set of initial values to use when initializing the model. If omitted, 0.0 is used.

x: ndarray | DataFrame | Series | None = None

nobs + burn by k array of exogenous variables to include in the simulation.

initial_value_vol: float | ndarray[Any, dtype[float64]] | None = None

An array or scalar to use when initializing the volatility process.

Returns:

simulated_data – DataFrame with columns data containing the simulated values, volatility, containing the conditional volatility and errors containing the errors used in the simulation

Return type:

pandas.DataFrame

Examples

>>> import numpy as np
>>> from arch.univariate import HARX, GARCH
>>> harx = HARX(lags=[1, 5, 22])
>>> harx.volatility = GARCH()
>>> harx_params = np.array([1, 0.2, 0.3, 0.4])
>>> garch_params = np.array([0.01, 0.07, 0.92])
>>> params = np.concatenate((harx_params, garch_params))
>>> sim_data = harx.simulate(params, 1000)

Simulating models with exogenous regressors requires the regressors to have nobs plus burn data points

>>> nobs = 100
>>> burn = 200
>>> x = np.random.randn(nobs + burn, 2)
>>> x_params = np.array([1.0, 2.0])
>>> params = np.concatenate((harx_params, x_params, garch_params))
>>> sim_data = harx.simulate(params, nobs=nobs, burn=burn, x=x)