gen_var {bvartools} | R Documentation |
gen_var
produces the input for the estimation of a vector autoregressive (VAR) model.
gen_var(data, p = 2, exogen = NULL, s = 2, deterministic = "const", seasonal = FALSE)
data |
a time-series object of endogenous variables. |
p |
an integer of the lag order (default is |
exogen |
an optional time-series object of external regressors. |
s |
an optional integer of the lag order of the exogenous variables (default is |
deterministic |
a character specifying which deterministic terms should
be included. Available values are |
seasonal |
logical. If |
The function produces the variable matrices of a vector autoregressive (VAR) model, which can also include exogenous variables:
y_t = ∑_{i=1}^{p} A_i y_{t - i} + ∑_{i=0}^{s} B_i x_{t - i} + C D_t + u_t,
where y_t is a K-dimensional vector of endogenous variables, A_i is a K \times K coefficient matrix of endogenous variables, x_t is an M-dimensional vector of exogenous regressors and B_i its corresponding K \times M coefficient matrix. D_t is an N-dimensional vector of deterministic terms and C its corresponding K \times N coefficient matrix. p is the lag order of endogenous variables, s is the lag order of exogenous variables, and u_t is an error term.
In matrix notation the above model can be written as
Y = P Z + U,
where
Y is a K \times T matrix of endogenous variables,
Z is a Kp + M(1+s) + N \times T matrix of regressor variables,
and U is a K \times T matrix of errors. The function gen_var
generates the matrices Y and Z.
A list containing the following elements:
Y |
a matrix of endogenous variables. |
Z |
a matrix of regressor variables. |
Lütkepohl, H. (2007). New introduction to multiple time series analysis (2nd ed.). Berlin: Springer.
data("e1") e1 <- diff(log(e1)) data <- gen_var(e1, p = 2, deterministic = "const")