# Determine Cointegration Rank of VEC Model

This example shows how to convert an n-dimensional VAR model to a VEC model, and then compute and interpret the cointegration rank of the resulting VEC model.

The rank of the error-correction coefficient matrix, C, determines the cointegration rank. If rank(C) is:

• Zero, then the converted VEC(p) model is a stationary VAR(p - 1) model in terms of $\Delta {y}_{t}$, without any cointegration relations.

• n, then the VAR(p) model is stable in terms of ${y}_{t}$.

• The integer r such that $0, then there are $r$ cointegrating relations. That is, there are $r$ linear combinations that comprise stationary series. You can factor the error-correction term into the two n-by- r matrices $C=\alpha {\beta }^{\prime }$. $\alpha$ contains the adjustment speeds, and $\beta$ the cointegration matrix. This factorization is not unique.

For more details, see Cointegration and Error Correction and [135], Chapter 6.3.

Consider the following VAR(2) model.

`${y}_{t}=\left[\begin{array}{ccc}1& 0.26& 0\\ -0.1& 1& 0.35\\ 0.12& -0.05& 1.15\end{array}\right]{y}_{t-1}+\left[\begin{array}{ccc}-0.2& -0.1& -0.1\\ 0.6& -0.4& -0.1\\ -0.02& -0.03& -0.1\end{array}\right]{y}_{t-2}+{\epsilon }_{t}.$`

Create the variables `A1` and `A2` for the autoregressive coefficients. Pack the matrices into a cell vector.

```A1 = [1 0.26 0; -0.1 1 0.35; 0.12 -0.5 1.15]; A2 = [-0.2 -0.1 -0.1; 0.6 -0.4 -0.1; -0.02 -0.03 -0.1]; Var = {A1 A2};```

Compute the autoregressive and error-correction coefficient matrices of the equivalent VEC model.

`[Vec,C] = var2vec(Var);`

Because the degree of the VAR model is 2, the resulting VEC model has degree $q=2-1$. Hence, `Vec` is a one-dimensional cell array containing the autoregressive coefficient matrix.

Determine the cointegration rank by computing the rank of the error-correction coefficient matrix `C`.

`r = rank(C)`
```r = 2 ```

The cointegrating rank is `2`. This result suggests that there are two independent linear combinations of the three variables that are stationary.