Solved – Understanding vec2var conversion in R

econometricsrtime seriesvector-autoregressionvector-error-correction-model

I'm using Bernhard Pfaff's packages {urca} and {vars} to analyze 3 time series. Each is I(1) and cointegrated with $r =2$ cointegrating relationships.

The vec2var() command should make the conversion from the ca.jo object (my VECM) to its VAR representation in levels. But I do not understand the output from vec2var(), nor how to perform VAR analyses on this output (i.e., send the data to the VAR() function to get a varest object).

That is, after converting from VECM to VAR what do I send to the VAR() function (which performs the standard VAR estimates)?
Should it be:

var.form$A%*%var.form$datamat[ , c(6:11)] + var.form$deterministic%*%var.form$datamat[ , c(4:5)]

where dimensions in the code above are because I have $K=3$ variables, $p=2$ lags, a constant term and a deterministic trend.

But the formulation from vec2var() [on which I've based the above R code] is something like
\begin{equation}
Y_t = A_1 Y_{t-1} + A_2 Y_{t-2} + \Phi D_t + \mu + \epsilon_t
\end{equation}
That is, a basic VAR(2) with a deterministic time trend and constant.

But this is what I'm confused about: The VAR form of the long-run VECM (equation 4.8a, in Pfaff's Analysis of Integrated and Co-Integrated Time Series with R. useR!, and elsewhere e.g. Lütkepohl eq'n 7.1.1) is:

\begin{equation}
\Delta y_t = \Gamma_1 \cdot \Delta y_{t-1} + \Gamma_2 \cdot \Delta y_{t-2} + \Pi \cdot y_{t-2} + \Phi \cdot D_t + \mu + \epsilon_t
\end{equation}

To get the proper VAR level representation do I have to take the data from vec2var() and manipulate it myself? (i.e. find the difference series and then multiply by the appropriate cointegration matrix)? If this is the case then which [in R code please!] coefficient matrices should multiply which vectors?

I feel like there's a disconnect from the theory and mathematical formalism and these R packages… but more likely I'm missing something pretty basic.

Here's the basic R code set up:

library(urca) 
library(vars) 

vecm <- ca.jo(mydata, ecdet = "trend", type = "trace",  spec = "longrun") 
var.form <- vec2var(vecm, r= 2) 
# The output data I get can be seen from names(var.form), but the key parts are: 

var.form$y          # my original data 
var.form$datamat    # original data organized with the three variables (starting at t = 2), the constant term, trend term and then six columns with two lagged levels at t=1 and t=0. 

# the coefficients for the regressors on the endogenous variables (A) and deterministic components are:
     var.form$A             # lagged variable coefficients (levels only, I think) 
     var.form$deterministic     # constant and time trend coefficients

Best Answer

The vec2var() function will provide an object of class vec2var. You cannot convert it further to the class varest for standard VAR, but there are still many methods that will work on it, check it with:

methods(class = "vec2var")

Will return:

[1] fevd fitted irf logLik Phi plot predict print Psi residuals

So you can run irf(), fevd() and so on, to "perform VAR analyses on this output" as you want. For exampe, if you want to run the IRF, do:

plot(irf(vec2var(x)))

The only thing you cannot get easily are standard errors for the coefficients of the (constrained) VAR representation.

Related Question