simulate!

simulate(::Type{VAR}, T::Int, B::Matrix{<:Number},
         Sigma_u::Matrix{<:Number}=I(size(B,1));
         trend_exponents::Vector{<:Number}=[0],
         initial::Union{Nothing,Vector{<:Number}}=nothing) -> VAR

simulate!(::Type{VAR}, errors::Matrix{<:Number}, B::Matrix{<:Number};
          trend_exponents::Vector{<:Number}=[0],
          initial::Union{Nothing,Vector{<:Number}}=nothing) -> VAR

Simulates a VAR(p) model using the specified coefficient matrix B and optionally a covariance matrix Sigma_u and deterministic trends.

The simulation uses the reduced-form VAR representation:

\[ y_t = C e_t + B_1 y_{t-1} + ... + B_p y_{t-p} + u_t \]

Method 1: simulate!

Simulates a VAR process by overwriting the provided error matrix errors with simulated values. Returns a VAR object constructed from the simulated data.

Method 2: simulate

Generates error terms internally from a Gaussian distribution with covariance Sigma_u (default is the identity matrix). Returns a VAR object containing the simulated series.

Arguments

  • B::Matrix{<:Number}: Coefficient matrix [C B_1 ... B_p], size k × (k * p + m), where m is the number of deterministic components.
  • trend_exponents::Vector{<:Number}: Exponents used to simulate trends (e.g. [0,1] implies constant and linear trend)
  • initial::Union{Nothing, Vector{<:Number}}: Optional initial values for lags (length k * p). Default is zero.
  • T::Int: Number of time periods to simulate
  • Sigma_u::Matrix{<:Number}: Covariance matrix of the error term (default is identity)
  • errors::Matrix{<:Number}: Pre-allocated matrix of shape k × T, initially filled with innovations, overwritten with simulated data

Returns

  • VAR: A new VAR object containing the simulated dataset. The data can be obtained using get_input_data. Alternatively, the model can be directly estimated using fit!.