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]
, sizek × (k * p + m)
, wherem
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 (lengthk * p
). Default is zero.T::Int
: Number of time periods to simulateSigma_u::Matrix{<:Number}
: Covariance matrix of the error term (default is identity)errors::Matrix{<:Number}
: Pre-allocated matrix of shapek × T
, initially filled with innovations, overwritten with simulated data
Returns
VAR
: A newVAR
object containing the simulated dataset. The data can be obtained usingget_input_data
. Alternatively, the model can be directly estimated usingfit!
.
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]
(sizek × (k*p + m)
) wherem
is the number of exogenous components.shocks::Matrix{<:Number}
: Structural shocks of shapek × T
T::Int
: Number of time periods to simulatetrend_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 (lengthk * p
). Ifnothing
lags will be initialised at zero.
Returns
SVAR
: A simulatedSVAR
model containing the generated dataset. The data can be accessed usingget_input_data
, or the model can be estimated usingfit!
.