MATLAB Examples

Estimate VEC Model Parameters Using egcitest

This example shows how to estimate the parameters of a vector error-correction (VEC) model. Before estimating VEC model parameters, you must determine whether there are any cointegrating relations (see docid:econ_ug.buwhxjg-1). You can estimate the remaining VEC model coefficients using ordinary least squares (OLS).

Following from docid:econ_ug.buwhxjg-1, load the Data_Canada data set. Run the Engle-Granger cointegration test on the small-term, medium-term, and long-term interest rate series.

load Data_Canada
Y = Data(:,3:end); % Interest rate data
[~,~,~,~,reg] = egcitest(Y,'test','t2');
c0 = reg.coeff(1);
b = reg.coeff(2:3);
beta = [1;-b];

Suppose that a model selection procedure indicates the adequacy of q = 2 lags in a VEC(q) model. Subsequently, the model is

$$\Delta y_t = \alpha(\beta^\prime y_{t-1}+c_0)+\displaystyle\sum_{i=1}^2B_i\Delta y_{t-i}+c_1+\varepsilon_t.$$

Because you estimated c0 and $\beta$ = [1; -b] previously, you can conditionally estimate $\alpha$, B1, B2, and c1 by:

  1. Forming the required lagged differences
  2. Regress the first difference of the series onto the q lagged differences and the estimated cointegration term.

Form the lagged difference series.

q = 2;
[numObs,numDims] = size(Y);
tBase = (q+2):numObs;                    % Commensurate time base, all lags
T = length(tBase);                       % Effective sample size
YLags = lagmatrix(Y,0:(q+1));            % Y(t-k) on observed time base
LY = YLags(tBase,(numDims+1):2*numDims); % Y(t-1) on commensurate time base

Form multidimensional differences so that the $k^{th}$ numDims-wide block of columns in DelatYLags contains (1-L)Y(t-k+1).

DeltaYLags = zeros(T,(q+1)*numDims);
for k = 1:(q+1)
    DeltaYLags(:,((k-1)*numDims+1):k*numDims) = ...
               YLags(tBase,((k-1)*numDims+1):k*numDims) ...
             - YLags(tBase,(k*numDims+1):(k+1)*numDims);
end

DY = DeltaYLags(:,1:numDims);        % (1-L)Y(t)
DLY = DeltaYLags(:,(numDims+1):end); % [(1-L)Y(t-1),...,(1-L)Y(t-q)]

Regress the first difference of the series onto the q lagged differences and the estimated cointegration term. Include an intercept in the regression.

X = [(LY*beta-c0),DLY,ones(T,1)];
P = (X\DY)'; % [alpha,B1,...,Bq,c1]
alpha = P(:,1);
B1 = P(:,2:4);
B2 = P(:,5:7);
c1 = P(:,end);

Display the VEC model coefficients.

alpha,b,c0,B1,B2,c1
alpha =

   -0.6336
    0.0595
    0.0269


b =

    2.2209
   -1.0718


c0 =

   -1.2393


B1 =

    0.1649   -0.1465   -0.0416
   -0.0024    0.3816   -0.3716
    0.0815    0.1790   -0.1528


B2 =

   -0.3205    0.9506   -0.9514
   -0.1996    0.5169   -0.5211
   -0.1751    0.6061   -0.5419


c1 =

    0.1516
    0.1508
    0.1503