pyeeg.simulate.simulate_var

pyeeg.simulate.simulate_var(order, coef, nobs=500, ndim=2, seed=42, verbose=False)

Simulate a VAR model of order order.

The VAR model is defined as:

\[x_t = A_1 x_{t-1} + A_2 x_{t-2} + ... + A_p x_{t-p} + \epsilon_t x_t = \sum_{i=1}^p A_i x_{t-i} + \epsilon_t\]

where \(x_t\) is a vector of shape (ndim, 1), \(A_i\) is a matrix of shape (ndim, ndim).

Parameters:
  • order (int) – The order of the VAR model.

  • coef (array_like) – The coefficients of the VAR model. Shape (order, ndim, ndim). If order == 1 and coef is 2D, it is reshaped to (1, ndim, ndim).

  • nobs (int) – The number of observations to simulate.

  • ndim (int) – The number of dimensions of the VAR process.

  • seed (int) – The random seed used to initialise the process.

  • verbose (bool) – Whether to log information about the simulation.

Returns:

data – The simulated VAR time series. Shape (nobs, ndim).

Return type:

ndarray

Notes

The coefficients at a given lag are such as \(C_ij\) is i->j, so it will be the coefficients for dimension j! For example, each row of the first column are determining the contributions of each component onto the first component.