- An Introduction to Vector Error Correction Models (VECMs)
- Model and data
- Estimation
- Impulse response analyis
- References
- R-bloggers
- R news and tutorials contributed by hundreds of R bloggers
- Vector Error Correction Model (VECM) using R
- Vector Error Correction Model
- Key Takeaways for Cointegration, VECM, VAR
- Cointegration
- VECM Model
- 0) r = 0 (no cointegration)
- 1) r = 1 (one cointegrating vector)
- 2) r = 2 (two cointegrating vectors)
- 3) r = 3 (full cointegration)
- Johansen Test for Cointegration
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_
The above equation shows that the only difference to a VAR model is the error correction term \(\Pi x_
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^
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.↩
R-bloggers
R news and tutorials contributed by hundreds of R bloggers
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
|
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.
|
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.
|
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_
VECM describes a short-run dynamics by vector autoregression (VAR) as well as a long-run equilibrium by error correcting equations.
\[\begin
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_
\(\Pi X_
For example, a tri-variate VECM(2) model is represented in the following way.
\[\begin
\(\Pi X_
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
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
2) r = 2 (two cointegrating vectors)
\[\begin
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