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!.
simulate(::Type{SVAR}, shocks::Matrix{<:Number}, A0::Matrix{<:Number},
         A_plus::Matrix{<:Number};
         trend_exponents::Vector{<:Number}=[0],
         initial::Union{Nothing,Vector{<:Number}}=nothing) -> SVAR

simulate(::Type{SVAR}, T::Int, A0::Matrix{<:Number}, A_plus::Matrix{<:Number};
         trend_exponents::Vector{<:Number}=[0],
         initial::Union{Nothing,Vector{<:Number}}=nothing) -> SVAR

Simulates a structural VAR (SVAR) model using the structural form characterised by matrices A0 and A_plus.

The SVAR model is given by:

\[ A_0 y_t = C e_t + A_1 y_{t-1} + ... + A_p y_{t-p} + \varepsilon_t \]

Method 1: simulate(::Type{SVAR}, shocks, A0, A_plus)

Simulates an SVAR process given structural shocks.

Method 2: simulate(::Type{SVAR}, T, A0, A_plus)

Generates random structural shocks from a multivariate Guassian with identify covariance and simulates the SVAR process using these shocks.

Arguments

  • A0::Matrix{<:Number}: Contemporaneous impact matrix (invertible)
  • A_plus::Matrix{<:Number}: Coefficient matrix [C A_1 ... A_p] (size k × (k*p + m)) where m is the number of exogenous components.
  • shocks::Matrix{<:Number}: Structural shocks of shape k × T
  • T::Int: Number of time periods to simulate
  • trend_exponents::Vector{<:Number}: Exponents for deterministic trends (e.g., [0,1] for constant and linear trend)
  • initial::Union{Nothing, Vector{<:Number}}: Optional initial conditions for lagged variables (length k * p). If nothing lags will be initialised at zero.

Returns

  • SVAR: A simulated SVAR model containing the generated dataset. The data can be accessed using get_input_data, or the model can be estimated using fit!.