4.1.2. pywhy_graphs.simulate.simulate_data_from_var#
- pywhy_graphs.simulate.simulate_data_from_var(var_arr: ndarray, n_times: int = 1000, n_realizations: int = 1, var_names: Optional[List[Union[int, float, str, Any]]] = None, random_state: Optional[int] = None)[source]#
Simulate data from an already set VAR process.
- Parameters:
var_arr : ArrayLike of shape (n_variables, n_variables, max_lag + 1)
The stationary time-series vector-auto-regressive process. The 3rd dimension is the lag and we assume that there are lag points
(t=0, ..., t=-max_lag)
.n_times : int, optional
Number of observations (time points) to simulate, this includes the initial observations to start the autoregressive process. By default 1000.
n_realizations : int, optional
The number of independent realizations to generate the VAR process, by default 1.
var_names : list of nodes, optional
The variable names. If passed in, then must have length equal
n_variables
. If passed in, then the output will be converted to a pandas DataFrame withvar_names
as the columns. By default, None.random_state : int, optional
The random state, by default None.
- Returns:
- xArrayLike of shape (n_variables, n_times * n_realizations), or
pandas.DataFrame of shape (n_times * n_realizations, n_variables)
The simulated data. If
node_names
are passed in, then the output will be converted to a pandas DataFrame.
Notes
The simulated
x
array consists of multiple “instances” of the underlying stationary VAR process. For example, ifn_times
is 1000, andmax_lag = 2
, then technically you have 500 realizations of the time-series graph occurring over this multivariate time-series. However, each realization is dependent on the previous realizations in this case.In order to start from a completely independent initial conditions, then one can modify the
n_realizations
parameter instead. To generate 500 independent realizations in the above example, one would setn_realizations = 500
andn_times=2
.