# vec2var

Convert VEC model to VAR model

## Syntax

## Description

Econometrics Toolbox™ VAR model functions such as `simulate`

, `forecast`

, and `armairf`

are appropriate for vector autoregression
(VAR) models. To simulate, forecast, or generate impulse responses
from a vector error-correction
(VEC) model using `simulate`

, `forecast`

,
or `armairf`

, respectively, convert the VEC model
to its equivalent VAR model representation.

returns
the coefficient matrices (`VAR`

= vec2var(`VEC`

,`C`

)`VAR`

) of the vector autoregressive
model equivalent to the vector error-correction model with coefficient
matrices (`VEC`

). If the number of lags in the input
vector error-correction model is *q*, then the number
of lags in the output vector error-correction model is *p* = *q* +
1.

## Examples

### Convert VEC Model to VAR Model Using Cell Arrays

Consider converting the following VEC(2) model to a VAR(3) model.

$$\begin{array}{rcl}\Delta {y}_{t}& =& \left[\begin{array}{c}0.5\\ 1\\ -2\end{array}\right]+\left[\begin{array}{ccc}-0.14& 0.12& -0.05\\ -0.14& -0.07& -0.10\\ -0.07& -0.16& -0.07\end{array}\right]\Delta {y}_{t-1}+\left[\begin{array}{ccc}-0.14& 0.12& -0.05\\ -0.14& -0.07& -0.10\\ -0.07& -0.16& -0.07\end{array}\right]\Delta {y}_{t-2}\\ & +& \left[\begin{array}{ccc}-0.32& 0.74& -0.38\\ 1.97& -0.61& 0.44\\ -2.19& -1.15& 2.65\end{array}\right]{y}_{t-1}+{\epsilon}_{t}\end{array}.$$

Specify the coefficient matrices ($${B}_{1}$$ and $${B}_{2}$$) of $$\Delta {y}_{t-1}$$ and $$\Delta {y}_{t-2}$$, and the error-correction coefficient $$C$$.

B1 = [-0.14 0.12 -0.05; -0.14 -0.07 -0.10; -0.07 -0.16 -0.07]; B2 = [-0.14 0.12 -0.05; -0.14 -0.07 -0.10; -0.07 -0.16 -0.07]; C = [-0.32 0.74 -0.38; 1.97 -0.61 0.44; - 2.19 -1.15 2.65];

Pack the matrices into separate cells of a 2-dimensional cell vector. Put `B1`

into the first cell and `B2`

into the second cell.

VEC = {B1 B2};

Compute the coefficient matrices of the equivalent VAR(3) model.

VAR = vec2var(VEC,C); size(VAR)

`ans = `*1×2*
1 3

The specification of a cell array of matrices for the input argument indicates that the VEC(2) model is in reduced form, and `VEC{1}`

is the coefficient of $$\Delta {y}_{t-1}$$. Subsequent elements correspond to subsequent lags.

`VAR`

is a 1-by-3 cell vector of 3-by-3 coefficient matrices for the VAR(3) equivalent of the VEC(2) model. Because the VEC(2) model is in reduced form, the equivalent VAR(3) model is as well. That is, `VAR{1}`

is the coefficient of $${y}_{t-1}$$, and subsequent elements correspond to subsequent lags. The orientation of `VAR`

corresponds to the orientation of `VEC`

.

Display the VAR(3) model coefficients.

A1 = VAR{1}

`A1 = `*3×3*
0.5400 0.8600 -0.4300
1.8300 0.3200 0.3400
-2.2600 -1.3100 3.5800

A2 = VAR{2}

`A2 = `*3×3*
0 0 0
0 0 0
0 0 0

A3 = VAR{3}

`A3 = `*3×3*
0.1400 -0.1200 0.0500
0.1400 0.0700 0.1000
0.0700 0.1600 0.0700

Since the constant offsets between the models are equivalent, the resulting VAR(3) model is

$${y}_{t}=\left[\begin{array}{c}0.5\\ 1\\ -2\end{array}\right]+\left[\begin{array}{ccc}0.54& 0.86& -0.43\\ 1.83& 0.32& 0.34\\ -2.26& -1.31& 3.58\end{array}\right]{y}_{t-1}+\left[\begin{array}{ccc}0.14& -0.12& 0.05\\ 0.14& 0.07& 0.10\\ 0.07& 0.16& 0.07\end{array}\right]{y}_{t-3}+{\epsilon}_{t}.$$

### Convert Structural VEC Model to VAR Model Using Lag Operator Polynomials

Consider converting the following structural VEC(1) model to a structural VAR(2) model.

$$\left[\begin{array}{cc}0.54& -2.26\\ 1.83& 0.86\end{array}\right]\Delta {y}_{t}=\left[\begin{array}{cc}-0.07& -0.07\\ 0.01& 0.02\end{array}\right]\Delta {y}_{t-1}+\left[\begin{array}{cc}-0.15& 1.9\\ -3.15& -0.54\end{array}\right]{y}_{t-1}+{\epsilon}_{t}.$$

Specify the coefficient matrices $${B}_{0}$$ and $${B}_{1}$$, and the error-correction coefficient $$C$$.

B0 = [0.54 -2.26; 1.83 0.86]; B1 = [-0.07 -0.07 0.01 0.02]; C = [-0.15 1.9; -3.15 -0.54];

Pack the matrices into separate cells of a 3-dimensional cell vector. Put `B0`

into the first cell and `B1`

into the second cell. Negate the coefficients corresponding to all nonzero differenced lag terms.

VECCoeff = {B0; -B1};

Create a lag operator polynomial that encompasses the autoregressive terms in the VEC(2) model.

VEC = LagOp(VECCoeff)

VEC = 2-D Lag Operator Polynomial: ----------------------------- Coefficients: [Lag-Indexed Cell Array with 2 Non-Zero Coefficients] Lags: [0 1] Degree: 1 Dimension: 2

`VEC`

is a `LagOp`

lag operator polynomial, and specifies the autoregressive lag operator polynomial in this equation

$$({B}_{0}-{B}_{1}L)\Delta {y}_{t}=C{y}_{t-1}+{\epsilon}_{t}.$$

$$L$$ is the lag operator. If you expand the quantity and solve for $$\Delta {y}_{t}$$, then the result is the VAR(2) model in difference-equation notation.

Compute the coefficient matrices of the equivalent VAR(2) model.

VAR = vec2var(VEC,C)

VAR = 2-D Lag Operator Polynomial: ----------------------------- Coefficients: [Lag-Indexed Cell Array with 3 Non-Zero Coefficients] Lags: [0 1 2] Degree: 2 Dimension: 2

`VEC.Coefficients{0}`

is $${A}_{0}$$, the coefficient matrix of $${y}_{t}$$. Subsequent elements in `VAR.Coefficients`

correspond to subsequent lags in `VEC.Lags`

.

`VAR`

is the VAR(2) equivalent of the VEC(1) model. Because the VEC(1) model is structural, the equivalent VAR(2) is as well. That is, `VAR.Coefficients{0}`

is the coefficient of $${y}_{t}$$, and subsequent elements correspond to subsequent lags in `VAR.Lags`

.

Display the VAR(2) model coefficients in difference-equation notation.

A0 = VAR.Coefficients{0}

`A0 = `*2×2*
0.5400 -2.2600
1.8300 0.8600

A1 = -VAR.Coefficients{1}

`A1 = `*2×2*
0.3200 -0.4300
-1.3100 0.3400

A2 = -VAR.Coefficients{2}

`A2 = `*2×2*
0.0700 0.0700
-0.0100 -0.0200

The resulting VAR(3) model is

$$\left[\begin{array}{cc}0.54& -2.26\\ 1.83& 0.86\end{array}\right]{y}_{t}=\left[\begin{array}{cc}0.32& -0.43\\ -1.31& 0.34\end{array}\right]{y}_{t-1}+\left[\begin{array}{cc}0.07& 0.07\\ -0.01& -0.02\end{array}\right]{y}_{t-2}+{\epsilon}_{t}.$$

Alternatively, reflect the lag operator polynomial `VAR`

around lag 0 to obtain the difference-equation notation coefficients.

DiffEqnCoeffs = reflect(VAR); A = toCellArray(DiffEqnCoeffs); A{1} == A0

`ans = `*2x2 logical array*
1 1
1 1

A{2} == A1

`ans = `*2x2 logical array*
1 1
1 1

A{3} == A2

`ans = `*2x2 logical array*
1 1
1 1

Both methods produce the same coefficients.

### Convert Structural VEC model to VMA Model

Approximate the coefficients of the structural VMA model that represents the structural VEC(8) model

$$\begin{array}{l}\left\{\left[\begin{array}{ccc}1& 0.2& -0.1\\ 0.03& 1& -0.15\\ 0.9& -0.25& 1\end{array}\right]+\left[\begin{array}{ccc}0.5& -0.2& -0.1\\ -0.3& -0.1& 0.1\\ 0.4& -0.2& -0.05\end{array}\right]{L}^{4}+\left[\begin{array}{ccc}0.05& -0.02& -0.01\\ -0.1& -0.01& -0.001\\ 0.04& -0.02& -0.005\end{array}\right]{L}^{8}\right\}\Delta {y}_{t}=\\ \left[\begin{array}{ccc}-0.02& 0.03& 0.3\\ 0.05& 0.1& 0.01\\ 0.3& 0.01& 0.01\end{array}\right]{y}_{t-1}+{\epsilon}_{t}\end{array}$$

where $$\Delta {y}_{t}={\left[\Delta {y}_{t,1}\phantom{\rule{0.2777777777777778em}{0ex}}\phantom{\rule{0.2777777777777778em}{0ex}}\phantom{\rule{0.2777777777777778em}{0ex}}\Delta {y}_{t,2}\phantom{\rule{0.2777777777777778em}{0ex}}\phantom{\rule{0.2777777777777778em}{0ex}}\phantom{\rule{0.2777777777777778em}{0ex}}\Delta {y}_{t,3}\right]}^{\prime}$$, $${\epsilon}_{t}={\left[{\epsilon}_{1t}\phantom{\rule{0.2777777777777778em}{0ex}}\phantom{\rule{0.2777777777777778em}{0ex}}\phantom{\rule{0.2777777777777778em}{0ex}}{\epsilon}_{2t}\phantom{\rule{0.2777777777777778em}{0ex}}\phantom{\rule{0.2777777777777778em}{0ex}}\phantom{\rule{0.2777777777777778em}{0ex}}{\epsilon}_{3t}\right]}^{\prime}$$, and, for *j* = 1,2, and 3, $$\Delta {y}_{t,j}={y}_{t,j}-{y}_{t-1,j}$$.

Create a cell vector containing the VEC(8) model coefficient matrices. Start with the coefficient of $$\Delta {y}_{t}$$, and then enter the rest in order by lag. Construct a vector that indicates the degree of the lag term for the corresponding coefficients.

VEC0 = {[1 0.2 -0.1; 0.03 1 -0.15; 0.9 -0.25 1],... [0.5 -0.2 -0.1; -0.3 -0.1 0.1; 0.4 -0.2 -0.05],... [0.05 -0.02 -0.01; -0.1 -0.01 -0.001; 0.04 -0.02 -0.005]}; vec0Lags = [0 4 8]; C = [-0.02 0.03 0.3; 0.05 0.1 0.01; 0.3 0.01 0.01];

`vec2var`

requires a `LagOp`

lag operator polynomial for an input argument that comprises a structural VEC(8) model. Construct a `LagOp`

lag operator polynomial that describes the VEC(8) model autoregressive coefficient matrix component (i.e., the coefficients of $$\Delta {y}_{t}$$ and its lags).

`VECLag = LagOp(VEC0,'Lags',vec0Lags);`

`VECLag`

is a `LagOp`

lag operator polynomial that describes the autoregressive component of the VEC(8) model.

Compute the coefficients of the VAR(9) model equivalent to the VEC(8) model.

VAR = vec2var(VECLag,C)

VAR = 3-D Lag Operator Polynomial: ----------------------------- Coefficients: [Lag-Indexed Cell Array with 6 Non-Zero Coefficients] Lags: [0 1 4 5 8 9] Degree: 9 Dimension: 3

`VAR`

is a `LagOp`

lag operator polynomial. All coefficients except those corresponding to lags 0, 1, 4, 5, 8, and 9 are 3-by-3 matrices of zeros. The coefficients in `VAR`

comprise a stable, structural VAR(9) model equivalent to the original VEC(8) model. The model is stable because the error-correction coefficient has full rank.

Compute the coefficients of the VMA model approximation to the resulting VAR(9) model. Set `numLags`

to return at most 12 lags.

numLags = 12; VMA = arma2ma(VAR,[],numLags);

`VMA`

is a `LagOp`

lag operator polynomial containing the coefficient matrices of the resulting VMA(12) model in `VMA.Coefficients`

. `VMA{0}`

is the coefficient of $${\epsilon}_{t}$$, `VMA{1}`

is the coefficient of $${\epsilon}_{t-1}$$, and so on.

## Input Arguments

`VEC`

— VEC(*q*) model coefficients of differenced responses

numeric vector | cell vector of square, numeric matrices | `LagOp`

lag operator polynomial object

VEC(*q*) model coefficients of differenced
responses, specified as a numeric vector, a cell vector of *n*-by-*n* numeric
matrices, or a `LagOp`

lag
operator polynomial object.

For a numeric vector specification:

The VEC(

*q*) is a univariate time series.`VEC`

must be a length*q*numeric vector.`VEC(j)`

contains the scalar*B*, the coefficient of the lagged difference_{j}*Δy*_{t–j}.The coefficient of

*Δy*(_{t}*B*_{0}) is`1`

.

For a cell vector specification:

`VEC`

must have length*q*, and each cell contains an*n*-by-*n*numeric matrix (*n*> 1).`VEC{`

`j`

`}`

must contain*B*, the coefficient matrix of the lag term_{j}*Δy*_{t–j}.`vec2var`

assumes that the coefficient of*Δy*(_{t}*B*_{0}) is the*n*-by-*n*identity.

For a

`LagOp`

lag operator polynomial specification:`VEC.Degree`

must be*q*.`VEC.Coefficients{0}`

is*B*_{0}, the coefficient of*Δy*. All other elements correspond to the coefficients of the subsequent lagged, differenced terms. For example,_{t}`VEC.Coefficients{`

`j`

`}`

is the coefficient matrix of*Δy*_{t–j}.`VEC.Lags`

stores all nonzero lags.To construct a model in reduced form, set

`VEC.Coefficients{0}`

to`eye(VEC.Dimension)`

.

For example, consider converting

$$\left[\begin{array}{cc}1& 0\\ 0& 1\end{array}\right]\Delta {y}_{t}=\left[\begin{array}{cc}0.1& 0.2\\ 1& 0.1\end{array}\right]\Delta {y}_{t-1}+\left[\begin{array}{cc}-0.1& 0.01\\ 0.2& -0.3\end{array}\right]\Delta {y}_{t-2}+\left[\begin{array}{cc}0.5& 0\\ -0.1& 1\end{array}\right]{y}_{t-1}+{\epsilon}_{t}$$

to a VAR(3) model. The model is in difference-equation notation. You can convert the model by entering

```
VAR = vec2var({[0.1 0.2; 1 0.1],...
-[-0.1 0.01; 0.2 -0.3]},[0.5 0; -0.1 1]);
```

$$\left(\left[\begin{array}{cc}1& 0\\ 0& 1\end{array}\right]-\left[\begin{array}{cc}0.1& 0.2\\ 1& 0.1\end{array}\right]L-\left[\begin{array}{cc}-0.1& 0.01\\ 0.2& -0.3\end{array}\right]{L}^{2}\right)\Delta {y}_{t}=\left[\begin{array}{cc}0.5& 0\\ -0.1& 1\end{array}\right]{y}_{t-1}+{\epsilon}_{t}$$

The AR coefficient matrices of the lagged responses
appear negated compared to the corresponding coefficients in
difference-equation notation. To obtain the same result using
`LagOP`

lag operator polynomials,
enter

VEC = LagOp({eye(2), -[0.1 0.2; 1 0.1], -[-0.1 0.01; 0.2 -0.3]}); C = [0.5 0; -0.1 1]; VAR = vec2var(VEC,C);

`C`

— Error-correction coefficient

numeric matrix

Error-correction coefficient, specified as an *n*-by-*n* numeric
matrix. *n* is the number of time series in the VEC
model. The dimensions of `C`

and the matrices composing `VEC`

must
be equivalent.

**Data Types: **`double`

## Output Arguments

`VAR`

— VAR(*p*) model coefficients

cell vector of square, numeric matrices | `LagOp`

lag operator polynomial object | numeric vector

VAR(*p*) model coefficients, returned as a
a numeric vector, cell vector of *n*-by-*n* numeric
matrices, or a `LagOp`

lag
operator polynomial object. *n* is the number of
time series in the VEC model.

`VEC`

and `VAR`

share the
same data type and orientation.

`vec2var`

converts VEC(*q*)
models to VAR(*q* + 1) models. That is:

If

`VEC`

is a cell or numeric vector, then`numel(VAR)`

is`numel(VEC) + 1`

.If

`VEC`

is a`LagOp`

lag operator polynomial, then`VAR.Degree`

is`VEC.Degree + 1`

.

## More About

### Difference-Equation Notation

A VAR(*p*) or VEC(*q*)
model written in *difference-equation notation* isolates
the present value of the response vector and its structural coefficient
matrix on the left side of the equation. The right side of the equation
contains the sum of the lagged responses, their coefficient matrices,
the present innovation vector, and, for VEC models, the error-correction
term.

That is, a VAR(*p*) model written in difference-equation
notation is

$${A}_{0}{y}_{t}=a+{A}_{1}{y}_{t-1}+{A}_{2}{y}_{t-2}+\mathrm{...}+{A}_{p}{y}_{t-p}+{\epsilon}_{t}.$$

A VEC(*q*) model written in difference equation
notation is

$${B}_{0}\Delta {y}_{t}=b+{B}_{1}\Delta {y}_{t-1}+{B}_{2}\Delta {y}_{t-2}+\mathrm{...}+{B}_{q}\Delta {y}_{t-q}+C{y}_{t-1}+{\epsilon}_{t}.$$

For the variable and parameter definitions, see VAR(p) Model and VEC(q) Model.

### Lag Operator Notation

A VAR(*p*) or VEC(*q*)
model written in *lag-operator notation* positions
all response terms to the left side of the equation. The right side
of the equation contains the model constant offset vector, the present
innovation, and, for VEC models, the error-correction term.

That is, a VAR(*p*) model written in lag-operator
notation is

$$A(L){y}_{t}=a+{\epsilon}_{t}$$

where $$A(L)={A}_{0}-{A}_{1}L-{A}_{2}{L}^{2}-\mathrm{...}-{A}_{p}{L}^{p}$$ and $${L}^{j}{y}_{t}={y}_{t-j}$$.

A VEC(*q*) model written in difference equation
notation is

$$B(L)\Delta {y}_{t}=b+C{y}_{t-1}+{\epsilon}_{t}$$

where $$B(L)={B}_{0}-{B}_{1}L-{B}_{2}{L}^{2}-\mathrm{...}-{B}_{q}{L}^{q}$$.

For the variable and parameter definitions, see VAR(p) Model and VEC(q) Model.

When comparing lag operator notation to difference-equation notation, the signs of the lag terms are opposites. For more details, see Lag Operator Notation.

### VAR(*p*) Model

A *VAR(p) model* is a
multivariate, autoregressive time series model that has this general
form:

$${A}_{0}{y}_{t}=a+{A}_{1}{y}_{t-1}+{A}_{2}{y}_{t-2}+\mathrm{...}+{A}_{p}{y}_{t-p}+{\epsilon}_{t}.$$

*y*is an_{t}*n*-dimensional time series.*A*_{0}is the*n*-by-*n*invertible structural coefficient matrix. For models in*reduced form*,*A*_{0}=*I*, which is the_{n}*n*-dimensional identity matrix.*a*is an*n*-dimensional vector of constant offsets.*A*is the_{j}*n*-by-*n*coefficient matrix of*y*,_{t–j}*j*= 1,...,*p*.*ε*is an_{t}*n*-dimensional innovations series. The innovations are serially uncorrelated, and have a multivariate normal distribution with mean 0 and*n*-by-*n*covariance matrix*Σ*.

### VEC(*q*) Model

A *VEC(q) model* is a
multivariate, autoregressive time series model that has this general
form:

$${B}_{0}\Delta {y}_{t}=b+{B}_{1}\Delta {y}_{t-1}+{B}_{2}\Delta {y}_{t-2}+\mathrm{...}+{B}_{q}\Delta {y}_{t-q}+C{y}_{t-1}+{\epsilon}_{t}.$$

*y*is an_{t}*n*-dimensional time series.*Δ*is the first difference operator, that is,*Δy*=_{t}*y*–_{t}*y*_{t–1}.*B*_{0}is the*n*-by-*n*invertible structural coefficient matrix. For models in*reduced form*,*B*_{0}=*I*, which is the_{n}*n*-dimensional identity matrix.*b*is an*n*-dimensional vector of constant offsets.*B*is the_{j}*n*-by-*n*coefficient matrix of*Δy*,_{t–j}*j*= 1,...,*q*.*ε*is an_{t}*n*-dimensional innovations series. The innovations are serially uncorrelated, and have a multivariate normal distribution with mean 0 and*n*-by-*n*covariance matrix*Σ*.*C*is the*n*-by-*n*error-correction or impact coefficient matrix.

## Tips

To accommodate structural VEC models, specify the input argument

`VEC`

as a`LagOp`

lag operator polynomial.To access the cell vector of the lag operator polynomial coefficients of the output argument

`VAR`

, enter`toCellArray(VAR)`

.To convert the model coefficients of the output argument from lag operator notation to the model coefficients in difference-equation notation, enter

VARDEN = toCellArray(reflect(VAR));

`VARDEN`

is a cell vector containing*q*+ 1 coefficients corresponding to the response terms in`VAR.Lags`

in difference-equation notation. The first element is the coefficient of*y*, the second element is the coefficient of_{t}*y*_{t–1}, and so on.The constant offset of the converted VAR model is the same as the constant offset of the VEC model.

## Algorithms

`vec2var`

does not impose stability requirements on the coefficients. To check for stability, use`isStable`

.`isStable`

requires a`LagOp`

lag operator polynomial as input. For example, to check whether`VAR`

, the cell array of-by`n`

numeric matrices, composes a stable time series, enter`n`

varLagOp = LagOp([eye(

*n*) var]); isStable(varLagOp)A

`0`

indicates that the polynomial is not stable. If`VAR`

is a`LagOp`

lag operator polynomial, then pass it to`isStable`

.

## References

[1] Hamilton, J. D. *Time Series Analysis*.
Princeton, NJ: Princeton University Press, 1994.

[2] Lutkepohl, H. "New Introduction to Multiple Time Series Analysis." Springer-Verlag, 2007.

## Version History

**Introduced in R2015b**

## Open Example

You have a modified version of this example. Do you want to open this example with your edits?

## MATLAB Command

You clicked a link that corresponds to this MATLAB command:

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

## How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

### Americas

- América Latina (Español)
- Canada (English)
- United States (English)

### Europe

- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)

- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)