VAR
VAR
VAR <: Model
Vector Autoregressive (VAR) model in matrix form.
A VAR of lag order p is specified as:
\[ y_t = C e_t + B_1 y_{t-1} + ... + B_p y_{t-p} + u_t \]
where:
- \(e_t\) is a vector of deterministic components (constant, trends, etc)
- \(C, B_i\) are conformable matrices
- \(u_t\) is vector white noise
This can be rewritten compactly as:
\[ y_t' = z_t' B_+' + u_t' \]
where:
- \(z_t = [e_t; y_{t-1}; ...; y_{t-p}]\) includes deterministic components and lagged values of all variables
- \(B_+ = [C, B_1, ..., B_p]\) is the coefficient matrix stacking trend and autoregressive terms
Stacking observations from \(t = p+1\) to \(T\), the system can be written in matrix form:
\[ Y = X B_+' + U \]
where:
- \(Y\): an \((T - p) \times k\) matrix of outcomes
- \(X\): an \((T - p) \times (k p + d)\) matrix of regressors (lags and trends)
- \(B_+\): a \(k \times (kp + d)\) matrix of coefficients where \(d\) is the number of deterministic components.
- \(U\): a \((T - p) \times k\) matrix of residuals
This structure is represented by the VAR object.
Fields
B::Matrix{<:Number}: Coefficient matrix[C, B_1, ..., B_p]Sigma_u::Matrix{<:Number}: Covariance matrix of the error termp::Int: Lag order of the VARtrend_exponents::Vector{<:Number}: Time trend exponents (e.g.,[0,1]implies constant and linear trend)input_data::DataFrame: Original dataset used to estimate the VARY::Matrix{<:Number}: Left-hand side matrix of outcomesy_t, shape(T - p, k)X::Matrix{<:Number}: Right-hand side matrix of regressorsz_t, shape(T - p, k * p + d)U::Matrix{<:Number}: Residualsu_t, shape(T - p, k)Yhat::Matrix{<:Number}: Fitted valuesX * B_+', shape(T - p, k)
VAR
VAR(B::Matrix{<:Number},
Sigma_u::Matrix{<:Number},
p::Int,
trend_exponents::Vector{<:Number},
data::DataFrame)
Constructs a VAR model from estimated coefficient matrix B, error covariance matrix Sigma_u, lag length p, time trend exponents, and the dataset data.
Arguments
B::Matrix{<:Number}: Coefficient matrixSigma_u::Matrix{<:Number}: Covariance matrix of residualsp::Int: Lag ordertrend_exponents::Vector{<:Number}: Trend exponents for time trend termsdata::DataFrame: Dataset used to construct X and Y
VAR
VAR(data::DataFrame, p::Int;
trend_exponents::Vector{<:Number} = [0])
Constructs a VAR model object with data, lag length p, and specified time trend exponents. Coefficients and residuals are uninitialised but can be estimed using fit!.
Arguments
data::DataFrame: Dataset to construct lag matrix and outcomesp::Int: Lag length
Keyword Arguments
trend_exponents::Vector{<:Number}: Exponents of time trends (default:[0])