Main Content

var2vec

Convert VAR model to VEC model

Description

[VEC,C] = var2vec(VAR) returns the coefficient matrices and the error-correction coefficient matrix of the vector error-correction model equivalent to the vector autoregressive model with input coefficient matrices. If the number of lags in the input vector autoregressive model is p, then the number of lags in the output vector error-correction model is q = p – 1.

example

Examples

collapse all

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

yt=[0.51-2]+[0.540.86-0.431.830.320.34-2.26-1.313.58]yt-1+[0.14-0.120.050.140.070.100.070.160.07]yt-3+εt.

Specify the coefficient matrices (A1, A2, and A3) of the VAR(3) model terms yt-1, yt-2, and yt-3.

A1 = [0.54  0.86 -0.43;
      1.83  0.32  0.34;
     -2.26 -1.31  3.58];
A2 = zeros(3); 
A3 = [0.14 -0.12 0.05;
      0.14  0.07 0.10;
      0.07  0.16 0.07];

Pack the matrices into separate cells of a 3 dimensional cell vector. Put A1 into the first cell, A2 into the second cell, and A3 into the third cell.

VAR = {A1 A2 A3};

Compute the coefficient matrices of Δyt-1 and Δyt-2, and error-correction coefficient matrix of the equivalent VEC(2) model.

[VEC,C] = var2vec(VAR);
size(VEC)
ans = 1×2

     1     2

The specification of a cell array of matrices for the input argument indicates that the VAR(3) model is a reduced-form model expressed as a difference equation. VAR{1} is the coefficient of yt-1, and subsequent elements correspond to subsequent lags.

VEC is a 1-by-2 cell vector of 3-by-3 coefficient matrices for the VEC(2) equivalent of the VAR(3) model. Because the VAR(3) model is in reduced form, the equivalent VEC model is also. That is, VEC{1} is the coefficient of Δyt-1, and subsequent elements correspond to subsequent lags. The orientation of VEC corresponds to the orientation of VAR.

Display the VEC(2) model coefficients.

B1 = VEC{1}
B1 = 3×3

   -0.1400    0.1200   -0.0500
   -0.1400   -0.0700   -0.1000
   -0.0700   -0.1600   -0.0700

B2 = VEC{2}
B2 = 3×3

   -0.1400    0.1200   -0.0500
   -0.1400   -0.0700   -0.1000
   -0.0700   -0.1600   -0.0700

C
C = 3×3

   -0.3200    0.7400   -0.3800
    1.9700   -0.6100    0.4400
   -2.1900   -1.1500    2.6500

Since the constant offsets between the models are equivalent, the resulting VEC(2) model is

Δyt=[0.51-2]+[-0.140.12-0.05-0.14-0.07-0.10-0.07-0.16-0.07]Δyt-1+[-0.140.12-0.05-0.14-0.07-0.10-0.07-0.16-0.07]Δyt-2+[-0.320.74-0.381.97-0.610.44-2.19-1.152.65]yt-1+εt.

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

[0.54-2.261.830.86]yt=[0.32-0.43-1.310.34]yt-1+[0.070.07-0.01-0.02]yt-2+εt.

Specify the autoregressive coefficient matrices A0, A1, and A2.

A0 = [0.54 -2.26;
      1.83  0.86];
A1 = [0.32 -0.43
     -1.31  0.34];
A2 = [0.07  0.07
     -0.01 -0.02];

Pack the matrices into separate cells of a 3 dimensional cell vector. Put A0 into the first cell, A1 into the second cell, and A2 into the third cell. Negate the coefficients corresponding to all nonzero lag terms.

VARCoeff = {A0; -A1; -A2};

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

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

VAR is a LagOp lag operator polynomial. VAR specifies the VAR(2) model in lag operator notation, as in this equation

(A0-A1L-A2L2)yt=εt.

L is the lag operator. If you expand the quantity and solve for yt, then the result is the VAR(2) model in difference-equation notation.

Compute the coefficient matrices of Δyt and Δyt, and the error-correction coefficient matrix of the equivalent VEC(1) model.

[VEC,C] = var2vec(VAR)
VEC = 
    2-D Lag Operator Polynomial:
    -----------------------------
        Coefficients: [Lag-Indexed Cell Array with 2 Non-Zero Coefficients]
                Lags: [0 1]
              Degree: 1
           Dimension: 2
C = 2×2

   -0.1500    1.9000
   -3.1500   -0.5400

VAR.Coefficients{0} is A0, the coefficient matrix of yt. Subsequent elements in VAR.Coefficients correspond to subsequent lags in VAR.Lags.

VEC is the VEC(1) equivalent of the VAR(2) model. Because the VAR(2) model is structural, the equivalent VEC(1) model is as well. That is, VEC.Coefficients{0} is the coefficient of Δyt, and subsequent elements correspond to subsequent lags in VEC.Lags.

Display the VEC model coefficients in difference-equation notation.

B0 = VEC.Coefficients{0}
B0 = 2×2

    0.5400   -2.2600
    1.8300    0.8600

B1 = -VEC.Coefficients{1}
B1 = 2×2

   -0.0700   -0.0700
    0.0100    0.0200

C
C = 2×2

   -0.1500    1.9000
   -3.1500   -0.5400

The resulting VEC(1) model is

[0.54-2.261.830.86]Δyt=[-0.07-0.070.010.02]Δyt-1+[-0.151.9-3.15-0.54]yt-1+εt.

Alternatively, reflect the lag operator polynomial VEC around lag 0 to obtain the difference-equation notation coefficients.

DiffEqnCoeffs = reflect(VEC);
B = toCellArray(DiffEqnCoeffs);
B{1} == B0
ans = 2x2 logical array

   1   1
   1   1

B{2} == B1
ans = 2x2 logical array

   1   1
   1   1

Both methods produce the same coefficients.

Approximate the coefficients of the VEC model that represents this stationary and invertible VARMA(8,4) model that is in lag operator form

{[10.2-0.10.031-0.150.9-0.251]+[0.5-0.2-0.1-0.3-0.10.10.4-0.2-0.05]L4+[0.05-0.02-0.01-0.1-0.01-0.0010.04-0.02-0.005]L8}yt={[100010001]+[-0.020.030.30.0030.0010.010.30.010.01]L4}εt

where yt=[y1ty2ty3t] and εt=[ε1tε2tε3t].

Create a cell vector containing the VAR coefficient matrices. Start with the coefficient of yt, and then enter the rest in order by lag. Construct a vector that indicates the degree of the lag term for the corresponding coefficients.

VAR0 = {[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]};
var0Lags = [0 4 8];

Create a cell vector containing the VMA coefficient matrices. Start with the coefficient of ε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.

VMA0 = {eye(3),...
    [-0.02 0.03 0.3; 0.003 0.001 0.01; 0.3 0.01 0.01]};
vma0Lags = [0 4];

arma2ma requires LagOp lag operator polynomials for input arguments that comprise structural VAR or VMA models. Construct separate LagOp polynomials that describe the VAR(8) and VMA(4) components of the VARMA(8,4) model.

VARLag = LagOp(VAR0,'Lags',var0Lags);
VMALag = LagOp(VMA0,'Lags',vma0Lags);

VARLag and VMALag are LagOp lag operator polynomials that describe the VAR and VMA components of the VARMA model.

Convert the VARMA(8,4) model to a VAR(p) model by obtaining the coefficients of the truncated approximation of the infinite-lag polynomial. Set numLags to return at most 12 lagged terms.

numLags = 12;
VAR = arma2ar(VARLag,VMALag,numLags)
VAR = 
    3-D Lag Operator Polynomial:
    -----------------------------
        Coefficients: [Lag-Indexed Cell Array with 4 Non-Zero Coefficients]
                Lags: [0 4 8 12]
              Degree: 12
           Dimension: 3

VAR is a LagOP lag operator polynomial. All coefficients except those corresponding to lags 0, 4, 8, and 12 are 3-by-3 matrices of zeros. The coefficients in VAR.Coefficients comprise a structural VAR(12) model approximation of the original VARMA(8,4) model.

Compute the coefficients of the VEC(11) model equivalent to the resulting VAR(12) model.

[VEC,C] = var2vec(VAR)
VEC = 
    3-D Lag Operator Polynomial:
    -----------------------------
        Coefficients: [Lag-Indexed Cell Array with 12 Non-Zero Coefficients]
                Lags: [0 1 2 3 4 5 6 7 8 9 10 11]
              Degree: 11
           Dimension: 3
C = 3×3

   -1.2998   -0.1019    0.5440
    0.3831   -0.8937    0.0603
   -0.9484    0.5068   -1.0876

VEC is a LagOp lag operator polynomial containing the coefficient matrices of the resulting VEC(11) model in VEC.Coefficients. VEC.Coefficients{0} is the coefficient of Δyt, Vec{1} is the coefficient of Δyt-1, and so on.

Display the nonzero coefficients of the resulting VEC model.

lag2Idx = VEC.Lags + 1; % Lags start at 0.  Add 1 to convert to indices.
VecCoeff = toCellArray(VEC);

for j = 1:numel(lag2Idx)
    fprintf('___________Lag %d__________\n',lag2Idx(j) - 1)
    fprintf('%8.3f %8.3f %8.3f \n',VecCoeff{lag2Idx(j)})
    fprintf    ('__________________________\n')
end
___________Lag 0__________
   1.000    0.030    0.900 
   0.200    1.000   -0.250 
  -0.100   -0.150    1.000 
__________________________
___________Lag 1__________
  -0.300    0.413   -0.048 
   0.098    0.106    0.257 
   0.444   -0.090   -0.088 
__________________________
___________Lag 2__________
  -0.300    0.413   -0.048 
   0.098    0.106    0.257 
   0.444   -0.090   -0.088 
__________________________
___________Lag 3__________
  -0.300    0.413   -0.048 
   0.098    0.106    0.257 
   0.444   -0.090   -0.088 
__________________________
___________Lag 4__________
  -0.051    0.101    0.042 
  -0.053    0.007   -0.011 
   0.046    0.001   -0.116 
__________________________
___________Lag 5__________
  -0.051    0.101    0.042 
  -0.053    0.007   -0.011 
   0.046    0.001   -0.116 
__________________________
___________Lag 6__________
  -0.051    0.101    0.042 
  -0.053    0.007   -0.011 
   0.046    0.001   -0.116 
__________________________
___________Lag 7__________
  -0.051    0.101    0.042 
  -0.053    0.007   -0.011 
   0.046    0.001   -0.116 
__________________________
___________Lag 8__________
  -0.014   -0.000    0.010 
   0.007    0.000    0.018 
   0.034    0.001   -0.002 
__________________________
___________Lag 9__________
  -0.014   -0.000    0.010 
   0.007    0.000    0.018 
   0.034    0.001   -0.002 
__________________________
___________Lag 10__________
  -0.014   -0.000    0.010 
   0.007    0.000    0.018 
   0.034    0.001   -0.002 
__________________________
___________Lag 11__________
  -0.014   -0.000    0.010 
   0.007    0.000    0.018 
   0.034    0.001   -0.002 
__________________________

Input Arguments

collapse all

VAR(p) model coefficients, 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 VAR(p) is a univariate time series.

    • VAR must be a length p numeric vector.

    • VAR(j) contains the scalar Aj, the coefficient of the lagged response ytj.

    • The coefficient of yt (A0) is 1.

  • For a cell vector specification:

    • VAR must have length p, and each cell contains an n-by-n numeric matrix (n > 1).

    • VAR{j} must contain Aj, the coefficient matrix of the lag term ytj.

    • var2vec assumes that the coefficient of yt (A0) is the n-by-n identity.

  • For a LagOp lag operator polynomial specification:

    • VAR.Degree must be p.

    • VAR.Coefficients{0} is A0, the coefficient of yt. All other elements correspond to the coefficients of the subsequent lag terms. For example, VAR.Coefficients{j} is the coefficient matrix of ytj. VAR.Lags stores all nonzero lags.

    • To construct a model in reduced form, set VAR.Coefficients{0} to eye(VAR.Dimension).

For example, consider converting

[1001]yt=[0.10.210.1]yt1+[0.10.010.20.3]yt2+εt

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

VEC = var2vec({[0.1 0.2; 1 0.1], [-0.1 0.01; 0.2 -0.3]});
The VAR(2) model in lag operator notation is

([1001][0.10.210.1][0.10.010.20.3]L)yt=εt.

The 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

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

Output Arguments

collapse all

VEC(q) model coefficients of differenced responses, returned as a numeric vector, a cell vector of n-by-n numeric matrices, or a LagOp lag operator polynomial object. n is the number of time series in the VAR(p) model.

VAR and VEC share the same data type and orientation.

var2vec converts VAR(p) models to VEC(p – 1) models. That is:

  • If VAR is a cell or numeric vector, then numel(VEC) is numel(VAR) - 1.

  • If VAR is a LagOp lag operator polynomial, then VEC.Degree is VAR.Degree - 1.

Error-correction coefficient, returned as an n-by-n numeric matrix. n is the number of time series in the VAR model.

More About

collapse all

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

A0yt=a+A1yt1+A2yt2+...+Apytp+εt.

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

B0Δyt=b+B1Δyt1+B2Δyt2+...+BqΔytq+Cyt1+ε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)yt=a+εt

where A(L)=A0A1LA2L2...ApLp and Ljyt=ytj.

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

B(L)Δyt=b+Cyt1+εt

where B(L)=B0B1LB2L2...BqLq.

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:

A0yt=a+A1yt1+A2yt2+...+Apytp+εt.

  • yt is an n-dimensional time series.

  • A0 is the n-by-n invertible structural coefficient matrix. For models in reduced form, A0 = In, which is the n-dimensional identity matrix.

  • a is an n-dimensional vector of constant offsets.

  • Aj is the n-by-n coefficient matrix of yt–j, j = 1,...,p.

  • εt is an 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:

B0Δyt=b+B1Δyt1+B2Δyt2+...+BqΔytq+Cyt1+εt.

  • yt is an n-dimensional time series.

  • Δ is the first difference operator, that is, Δyt = ytyt–1.

  • B0 is the n-by-n invertible structural coefficient matrix. For models in reduced form, B0 = In, which is the n-dimensional identity matrix.

  • b is an n-dimensional vector of constant offsets.

  • Bj is the n-by-n coefficient matrix of Δyt–j, j = 1,...,q.

  • εt is an 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

  • If any of the time series in a vector autoregression (VAR) model are cointegrated, then the VAR model is nonstationary. You can determine the error-correction coefficient by converting the VAR model to a vector error-correction (VEC) model. The error-correction coefficient matrix determines, on average, how the time series react to deviations from their long-run averages. The rank of the error-correction coefficient determines how many cointegrating relations there exist in the model.

    Because estimate is suitable for estimating VAR models in reduced form, you can convert an estimated VAR model to its VEC model equivalent using var2vec.

  • To accommodate structural VAR models, specify the input argument VAR as a LagOp lag operator polynomial.

  • To access the cell vector of the lag operator polynomial coefficients of the output argument VEC, enter toCellArray(VEC).

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

    VECDEN = toCellArray(reflect(VEC));
    VECDEN is a cell vector containing p coefficients corresponding to the differenced response terms in VEC.Lags in difference-equation notation. The first element is the coefficient of Δyt, the second element is the coefficient of Δyt–1, and so on.

  • Consider converting a VAR(p) model to a VEC(q) model. If the error-correction coefficient matrix (C) has:

    • Rank zero, then the converted VEC model is a stable VAR(p – 1) model in terms of Δyt.

    • Full rank, then the VAR(p) model is stable (i.e., has no unit roots) [2].

    • Rank r, such that 0 < r < n, then the stable VEC model has r cointegrating relations.

  • The constant offset of the converted VEC model is the same as the constant offset of the VAR model.

Algorithms

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

    isStable requires a LagOp lag operator polynomial as an input argument. For example, to check whether VAR, the cell array of n-by-n numeric matrices, composes a stable time series, enter

    varLagOp = LagOp([eye(n) VAR]);
    isStable(varLagOp)

    A 0 indicates that the polynomial is not stable.

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