# Vector error correction model is

## An Introduction to Vector Error Correction Models (VECMs)

One of the prerequisits for the estimation of a vector autoregressive (VAR) model is that the analysed time series are stationary. However, economic theory suggests that there exist equilibrium relations between economic variables in their levels, which can render these variables stationary without taking differences. This is called cointegration. Since knowing the size of such relationships can improve the results of an analysis, it would be desireable to have an econometric model, which is able to capture them. So-called vector error correction models (VECMs) belong to this class of models. The following text presents the basic concept of VECMs and guides through the estimation of such a model in R.

## Model and data

Vector error correction models are very similar to VAR models and can have the following form:

$\Delta x_t = \Pi x_ + \sum_^ \Gamma_l \Delta x_ + C d_t + \epsilon_t,$ where $$\Delta x$$ is the first difference of the variables in vector $$x$$ , $$Pi$$ is a coefficient matrix of cointegrating relationships, $$\Gamma$$ is a coefficient matrix of the lags of differenced variables of $$x$$ , $$d$$ is a vector of deterministic terms and $$C$$ its corresponding coefficient matrix. $$p$$ is the lag order of the model in its VAR form and $$\epsilon$$ is an error term with zero mean and variance-covariance matrix $$\Sigma$$ .

The above equation shows that the only difference to a VAR model is the error correction term $$\Pi x_$$ , which captures the effect of how the growth rate of a variable in $$x$$ changes, if one of the variables departs from its equilibrium value. The coefficient matrix $$\Pi$$ can be written as the matrix product $$\Pi = \alpha \beta^<\prime>$$ so that the error correction term becomes $$\alpha \beta^ <\prime>x_$$ . The cointegration matrix $$\beta$$ contains information on the equilibrium relationships between the variables in levels. The vector described by $$\beta^ <\prime>x_$$ can be interpreted as the distance of the variables form their equilibrium values. $$\alpha$$ is a so-called loading matrix describing the speed at which a dependent variable converges back to its equilibrium value.

Note that $$\Pi$$ is assumed to be of reduced rank, which means that $$\alpha$$ is a $$K \times r$$ matrix and $$\beta$$ is a $$K^ \times r$$ matrix, where $$K$$ is the number of endogenous variables, $$K^$$ is the number of variables in the cointegration term and $$r$$ is the rank of $$\Pi$$ , which describes the number of cointegrating relationships that exist between the variables. Note that if $$r = 0$$ , there is no cointegration between the variables so that $$\Pi = 0$$ .

To illustrate the estimation of VECMs in R, we use dataset E6 from Lütkepohl (2007), which contains quarterly, seasonally unadjusted time series for German long-term interest and inflation rates from 1972Q2 to 1998Q4. It comes with the bvartools package.

## Estimation

There are multiple ways to estimate VEC models. A first approach would be to use ordinary least squares, which yields accurate result, but does not allow to estimate the cointegrating relations among the variables. The estimated generalised least squares (EGLS) approach would be an alternative. However, the most popular estimator for VECMs seems to be the maximum likelihood estimator of Johansen (1995), which is implemented in R by the ca.jo function of the urca package of Pfaff (2008a). Alternatively, function VECM of the tsDyn package of Di Narzo et al. (2020) can be used as well. 1

But before the VEC model can be estimated, the lag order $$p$$ , the rank of the cointegration matrix $$r$$ and deterministic terms have to be specified. A valid strategy to choose the lag order is to estimated the VAR in levels and choose the lag specification that minimises an Information criterion. Since the time series show strong seasonal pattern, we control for this by specifying season = 4 , where 4 is the frequency of the data.

According to the AIC, a lag order of 4 can be used, which is the same value used in Lütkepohl (2007). This means the VEC model corresponding to the VAR in levels has 3 lags. Since the ca.jo function requires the lag order of the VAR model we set K = 4 . 2

The inclusion of deterministic terms in a VECM is a delicate issue. Without going into detail a common strategy is to add a linear trend to the error correction term and a constant to the non-cointegration part of the equation. For this example we follow Lütkepohl (2007) and add a constant term and seasonal dummies to the non-cointegration part of the equation.

The ca.jo function does not just estimate the VECM. It also calculates the test statistics for different specificaions of $$r$$ and the user can choose between two alternative approaches, the trace and the eigenvalue test. For this example the trace test is used, i.e. type = «trace» .

By default, the ca.jo function sets spec = «longrun» This specification would mean that the error correction term does not refer to the first lag of the variables in levels as decribed above, but to the $$p-1$$ th lag instead. By setting spec = «transitory» the first lag will be used instead. Further information on the interpretation the two alternatives can be found in the function’s documentation ?ca.jo .

For further details on VEC modelling I recommend Lütkepohl (2006, Chapters 6, 7 and 8).

The trace test suggests that $$r=1$$ and the first columns of the estimates of the cointegration relations $$\beta$$ and the loading matrix $$\alpha$$ correspond to the results of the ML estimator in Lütkepohl (2007, Ch. 7):

However, the estimated coefficients of the non-cointegration part of the model correspond to the results of the EGLS estimator.

The deterministic terms are different from the results in Lütkepohl (2006), because different reference dates are used.

Using the the tsDyn package, estimates of the coefficients can be obtained in the following way:

### Impulse response analyis

The impulse response function of a VECM is usually obtained from its VAR form. The function vec2var of the vars package can be used to transform the output of the ca.jo function into an object that can be handled by the irf function of the vars package. Note that since ur.jo does not set the rank $$r$$ of the cointegration matrix automatically, it has to be specified manually.

The impulse response function is then calculated in the usual manner by using the irf function.

Note that an important difference to stationary VAR models is that the impulse response of a cointegrated VAR model does not neccessarily approach zero, because the variables are not stationary.

### References

Lütkepohl, H. (2006). New introduction to multiple time series analysis (2nd ed.). Berlin: Springer.

Di Narzo, A. F., Aznarte, J. L., Stigler, M., &and Tsung-wu, H. (2020). tsDyn: Nonlinear Time Series Models with Regime Switching. R package version 10-1.2. https://CRAN.R-project.org/package=tsDyn

Pfaff, B. (2008a). Analysis of Integrated and Cointegrated Time Series with R. Second Edition. New York: Springer.

Pfaff, B. (2008b). VAR, SVAR and SVEC Models: Implementation Within R Package vars. Journal of Statistical Software 27(4).

See Lütkepohl (2006) for more details.↩

Not that if some variables in the model are known to be integrated, the VAR order must be at least one.↩

Источник

## Vector Error Correction Model (VECM) using R

Posted on December 24, 2021 by sang-heon lee in R bloggers | 0 Comments

Читайте также:  Как убрать кастомную прошивку андроид

This post explains how to estimate and forecast a Vector Error Correction Model (VECM) model using R. The VECM model consists of VAR model (short-term dynamics) and cointegration (long-term comovement). We use the Johansen cointegration test. The coverage of this post is just a small island of the vast VECM modeling world.

## Vector Error Correction Model

### Key Takeaways for Cointegration, VECM, VAR

In general, when variables are non stationary, a VAR model in levels is not appropriate since it is a spurious regression which is a non-interpretable regression. However, although variables are non stationary but when cointegrations exist, a VAR model in levels can be estimated which has a long-term interpretation. In other words, the cointegration indicates one or more long-run equilibriums or stationary relationships among non-stationary variables.

To determine whether VAR model in levels is possible or not, we need to transform VAR model in levels to a VECM model in differences (with error correction terms), to which the Johansen test for cointegration is applied.

In other words, we take the following 4 steps

 construct a VECM model in differences (with error correction terms) apply the Johansen test to the VECM model in differences to find out the number of cointegration (r) if r = 0, estimate VAR in differences if r > 0, estimate VECM model in differences or VAR in levels

in case of 4), the VAR in differences is equal to the VECM model in differences (with no error correction term) since error correction terms does not exist.

In R package, the above steps are implemented in the following way.

 run ca.jo() function with level data for the Johansen cointegration test determine the number of cointegrations (r) if r = 0, estimate VAR in differences → period. if r > 0, apply the cajorls() function to the ca.jo() output to get estimated parameters of the VECM model in differences apply vec2var() function to the ca.jo() output to transform the VECM model in differences (with error correction terms) to VAR in levels apply predict() function to the transformed VAR model in levels for forecasting

While 4) provides the estimated parameters of VECM model, urca R package provides no function regarding prediction or forecasting. Instead, we use the predict() function in vars R package like 5) and 6). Indeed, for the forecasting purpose, we don’t have to use the cajorls() function since the vec2var() function can take the ca.jo() output as its argument.

Of course, 4), 5), 6) can also be implemented by using the following VECM() function in the tsDyn R package alternatively.

 if r > 0, call VECM() function with level data with the number of cointegrations (r) argument apply predict() function to the VECM() output for forecasting

### Cointegration

When $$x_t$$ and $$y_t$$ are nonstationary ($$I(1)$$) and if there is a $$\theta$$ such that $$y_t – \theta x_t$$ is stationary ($$I(0)$$), $$x_t$$ and $$y_t$$ are cointegrated. In other words, although each time series is nonstationary but its linear combination may be stationary. In this case, the cointegration is help the model estimation by augmenting short-run dynamics with long-run equilibriums.

Cointegration test is done by the ca.jo() function in the urca library.

### VECM Model

As explained in the previous post, when all variables are non-stationary in level ($$X_t$$) and there are some cointegrations in level($$\Pi X_$$), we use a VECM model which consists of a VAR with stationary growth variables ($$\Delta X_t$$) and error correcting equations with non-stationary level variables ($$X_t$$).

VECM describes a short-run dynamics by vector autoregression (VAR) as well as a long-run equilibrium by error correcting equations.

$\begin \Delta X_t = \Pi X_ + \sum_^\Gamma_i \Delta X_ + CD_t + \epsilon_t \end$
where $$\Delta x$$ is the first difference of $$x$$, $$\Pi$$ is a coefficient matrix of cointegrating relationships. $$\Gamma_i$$ is a coefficient matrix of $$\Delta x_$$, C is a coefficient matrix of a vector of deterministic terms $$d_t$$. $$\epsilon_t$$ is an error term with mean zero and variance-covariance matrix $$\Sigma$$.

Читайте также:  Error 017 undefined symbol idx

$$\Pi X_$$ is the first lag of linear combinations of non-stationary level variables or error correction terms (ECT) which represent long-term relationships among non-stationary level variables.

For example, a tri-variate VECM(2) model is represented in the following way.

$\begin \begin \Delta x_t \\ \Delta y_t \\ \Delta z_t \end &= \begin \pi_ <11>& \pi_ <12>& \pi_ <13>\\ \pi_ <21>& \pi_ <22>& \pi_ <23>\\ \pi_ <31>& \pi_ <32>& \pi_ <33>\end \begin x_ \\ y_ \\ z_ \end \\ &+\begin \gamma_<11>^1 & \gamma_<12>^1 & \gamma_<13>^1 \\ \gamma_<21>^1 & \gamma_<22>^1 & \gamma_<23>^1 \\ \gamma_<31>^1 & \gamma_<32>^1 & \gamma_<33>^1 \end \begin \Delta x_ \\ \Delta y_ \\ \Delta z_ \end \\ &+\begin \gamma_<11>^2 & \gamma_<12>^2 & \gamma_<13>^2 \\ \gamma_<21>^2 & \gamma_<22>^2 & \gamma_<23>^2 \\ \gamma_<31>^2 & \gamma_<32>^2 & \gamma_<33>^2 \end \begin \Delta x_ \\ \Delta y_ \\ \Delta z_ \end \\ &+\begin c_ <11>& c_ <12>\\ c_ <21>& c_ <22>\\ c_ <31>& c_ <32>\end \begin 1 \\ d_ \end +\begin \epsilon_ \\ \epsilon_ \\ \epsilon_ \end \end$
$$\Pi X_$$ is the first lag of linear combinations of non-stationary level variables or error correction terms (ECT) which represent long-term relationships among non-stationary level variables.

In particular, the above cointegrating vector ($$\Pi$$) is not unique and is interpreted as a kind of combined coefficient, it is decomposed into 1) a cointegration or equilibrium matrix ($$\beta$$) and 2) a loading or speed matrix ($$\alpha$$) as follows. $\begin \Pi = \alpha \beta^ <‘>\end$ Its identification depends on the number of cointegration in the following way.

#### 0) r = 0 (no cointegration)

In the case of no cointegration, since all variables are non-stationary in level, the above VECM model reduces to a VAR model with growth variables.

#### 1) r = 1 (one cointegrating vector)

$\begin \Pi X_ &= \begin \pi_ <11>& \pi_ <12>& \pi_ <13>\\ \pi_ <21>& \pi_ <22>& \pi_ <23>\\ \pi_ <31>& \pi_ <32>& \pi_ <33>\end \begin x_ \\ y_ \\ z_ \end \\ &= \begin \alpha_ <11>\\ \alpha_ <21>\\ \alpha_ <31>\end \begin 1 & – \beta_ <11>& – \beta_ <12>\end \begin x_t \\ y_t \\ z_t \end \\ &= \begin \alpha_ <11>\\ \alpha_ <21>\\ \alpha_ <31>\end \begin 1 \\ – \beta_ <11>\\ – \beta_ <12>\end^ <‘>\begin x_t \\ y_t \\ z_t \end = \alpha \beta^ <‘>X_t \\ &= \begin \alpha_ <11>\\ \alpha_ <21>\\ \alpha_ <31>\end \begin x_ – \beta_ <11>y_ – \beta_ <12>z_ \end = \alpha EC_t \end$

#### 2) r = 2 (two cointegrating vectors)

$\begin \Pi X_ &= \begin \pi_ <11>& \pi_ <12>& \pi_ <13>\\ \pi_ <21>& \pi_ <22>& \pi_ <23>\\ \pi_ <31>& \pi_ <32>& \pi_ <33>\end \begin x_ \\ y_ \\ z_ \end \\ &= \begin \alpha_ <11>& \alpha_ <12>\\ \alpha_ <21>& \alpha_ <22>\\ \alpha_ <31>& \alpha_ <32>\end \begin 1 & – \beta_ <11>& – \beta_ <12>\\ 1 & – \beta_ <21>& – \beta_ <22>\end \begin x_t \\ y_t \\ z_t \end \\ &= \begin \alpha_ <11>& \alpha_ <12>\\ \alpha_ <21>& \alpha_ <22>\\ \alpha_ <31>& \alpha_ <32>\end \begin 1 & 1 \\ – \beta_ <11>& – \beta_ <21>\\ – \beta_ <12>& – \beta_ <22>\end^ <‘>X_t = \alpha \beta^ <‘>X_t \\ &= \begin \alpha_ <11>& \alpha_ <12>\\ \alpha_ <21>& \alpha_ <22>\\ \alpha_ <31>& \alpha_ <32>\end \begin x_ – \beta_ <11>y_ – \beta_ <12>z_ \\ x_ – \beta_ <21>y_ – \beta_ <22>z_ \end = \alpha EC_t \end$

#### 3) r = 3 (full cointegration)

In the case of full cointegration, since all variables are stationary, the above VECM model reduces to a VAR model with level variables.

### Johansen Test for Cointegration

The rank of $$\Pi$$ equals the number of its non-zero eigenvalues and the Johansen test provides inference on this number. There are two tests for the number of co-integration relationships.

The first test is the trace test whose test statistic is

Источник