# gen_vec

##### Vector Error Correction Model Input

`gen_vec`

produces the input for the estimation of a vector error correction (VEC) model.

##### Usage

```
gen_vec(data, p = 2, exogen = NULL, s = 2, const = NULL,
trend = NULL, seasonal = NULL)
```

##### Arguments

- data
a time-series object of endogenous variables.

- p
an integer of the lag order of the series (levels) in the VAR.

- exogen
an optional time-series object of external regressors.

- s
an optional integer of the lag order of the exogenous variables of the series (levels) in the VAR.

- const
a character specifying whether a constant term enters the error correction term (

`"restricted"`

) or the non-cointegration term as an`"unrestricted"`

variable. If`NULL`

(default) no constant term will be added.- trend
a character specifying whether a trend term enters the error correction term (

`"restricted"`

) or the non-cointegration term as an`"unrestricted"`

variable. If`NULL`

(default) no constant term will be added.- seasonal
a character specifying whether seasonal dummies should be included in the error correction term (

`"restricted"`

) or in the non-cointegreation term as`"unrestricted"`

variables. If`NULL`

(default) no seasonal terms will be added. The amount of dummy variables depends on the frequency of the time-series object provided in`data`

.

##### Details

The function produces the variable matrices of a vector error correction (VEC) model, which can also include exogenous variables: $$\Delta y_t = \Pi w_t + \sum_{i=1}^{p-1} \Gamma_i \Delta y_{t - i} + \sum_{i=0}^{s-1} \Upsilon_i \Delta x_{t - i} + C^{UR} d^{UR}_t + u_t,$$ where \(\Delta y_t\) is a \(K \times 1\) vector of differenced endogenous variables, \(w_t\) is a \((K + M + N^{R}) \times 1\) vector of cointegration variables, \(\Pi\) is a \(K \times (K + M + N^{R})\) matrix of cointegration parameters, \(\Gamma_i\) is a \(K \times K\) coefficient matrix of endogenous variables, \(\Delta x_t\) is a \(M \times 1\) vector of differenced exogenous regressors, \(\Upsilon_i\) is a \(K \times M\) coefficient matrix of exogenous regressors, \(d^{UR}_t\) is a \(N \times 1\) vector of deterministic terms, and \(C^{UR}\) is a \(K \times N^{UR}\) coefficient matrix of deterministic terms that do not enter the cointegration term. \(p\) is the lag order of endogenous variables and \(s\) is the lag order of exogenous variables of the corresponding VAR model. \(u_t\) is a \(K \times 1\) error term.

In matrix notation the above model can be re-written as $$Y = \Pi W + \Gamma X + U,$$ where \(Y\) is a \(K \times T\) matrix of differenced endogenous variables, \(W\) is a \((K + M + N^{R}) \times T\) matrix of variables in the cointegration term, \(X\) is a \((K(p - 1) + Ms + N^{UR}) \times T\) matrix of differenced regressor variables and unrestricted deterministic terms. \(U\) is a \(K \times T\) matrix of errors.

##### Value

A list containing the following elements:

a matrix of differenced dependent variables.

a matrix of variables in the cointegration term.

a matrix of non-cointegration regressors.

##### References

L<U+00FC>tkepohl, H. (2007). *New introduction to multiple time series analysis* (2nd ed.). Berlin: Springer.

##### Examples

```
# NOT RUN {
data("e6")
data <- gen_vec(e6, p = 4, const = "unrestricted", season = "unrestricted")
# }
```

*Documentation reproduced from package bvartools, version 0.0.1, License: GPL (>= 2)*