Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Chapter 24 — Vector Error Correction Models (VECM)

In earlier chapters, we studied:

We also introduced:

VAR models allow economic variables to interact dynamically through time.

But an important problem arises when variables are:

Many macroeconomic and financial variables display precisely this behavior.

Examples include:

These variables may drift individually through time, yet still maintain stable long-run relationships.

This raises an important question.

The answer is the:

VECMs combine:

within a unified framework.

Throughout this chapter, we use Thai macroeconomic data as a running example.


Learning Objectives

By the end of this chapter, you should be able to:


24.1 Why Standard VAR Models Become Problematic

Standard VAR models usually require stationary variables.

But many macroeconomic variables are:

Examples include:


The Problem

Suppose we estimate a VAR using nonstationary variables.

Several problems may arise:

One common solution is:

Differencing often restores stationarity.

But differencing introduces another important problem.

For example:

Pure differencing may destroy this information.


24.2 Cointegration and Long-Run Equilibrium

Suppose two variables:

Then they may be:

Cointegration implies that long-run equilibrium forces exist even when short-run fluctuations are substantial.


Intuition

Cointegrated variables may temporarily drift apart.

But equilibrium forces gradually pull them back together.

This creates a distinction between:


24.3 Rubber-Band Analogy

A useful analogy is:

Short-run shocks may pull the variables apart temporarily.

But the rubber band creates pressure toward equilibrium.

This is precisely the role of the:


24.4 From ECM to VECM

Earlier in the book, we studied single-equation ECMs.

For example:

Δyt=α+βΔxt+λ(yt1γxt1)+ut\Delta y_t = \alpha + \beta \Delta x_t + \lambda (y_{t-1}-\gamma x_{t-1}) + u_t

The term:

(yt1γxt1)(y_{t-1}-\gamma x_{t-1})

measures deviation from long-run equilibrium.


Extending to Multiple Variables

A VECM generalizes this idea to:


24.5 Short-Run versus Long-Run Dynamics

One of the most important features of a VECM is the separation between:


Short-Run Dynamics

Short-run fluctuations capture:

These effects may generate temporary deviations from equilibrium.


Long-Run Dynamics

Long-run dynamics capture:


24.6 Thai Macroeconomic Example

We now examine Thai macroeconomic variables.

Our dataset contains:

These variables are useful because:


24.7 Loading the Data

import pandas as pd
from io import StringIO

data_text = """
year,cpi,BM_,gdp_r
1991,50.70,204654.4084,38.23977231
1992,52.80,237852.2993,41.58407966
1993,54.50,272926.6351,43.40940123
1994,57.30,302096.2673,46.88149708
1995,60.60,355694.6742,50.68815184
1996,64.10,393470.4887,53.55329227
1997,67.70,470396.7099,52.07872106
1998,73.10,517768.2452,48.10357948
1999,73.30,537431.8537,50.30235946
2000,74.50,563808.6622,52.54366163
2001,75.70,594569.9039,54.3535078
2002,76.20,617075.0830,57.69600000
2003,77.60,707867.6497,61.84370042
2004,79.80,747291.5105,65.73352411
2005,83.40,792795.6350,68.48596905
2006,87.30,857454.6312,71.88876509
2007,89.20,911063.5572,75.79552154
2008,94.10,994546.5100,77.10330582
2009,93.30,1061828.8660,76.53419316
2010,96.33,1178006.9540,82.27951477
2011,100.00,1356089.1230,82.96559013
2012,103.02,1496760.9480,88.96449269
2013,105.27,1606334.2890,91.36862416
2014,107.26,1681035.3120,92.11543151
"""

thai = pd.read_csv(
    StringIO(data_text)
)

thai.head()

24.8 Plotting the Variables

import matplotlib.pyplot as plt

fig, ax1 = plt.subplots(figsize=(10,5))

# Left axis: CPI
ax1.plot(
    thai["year"],
    thai["cpi"],
    linewidth=2,
    label="CPI"
)

ax1.set_xlabel("Year")
ax1.set_ylabel("CPI")

# Right axis: Broad Money
ax2 = ax1.twinx()

ax2.plot(
    thai["year"],
    thai["BM_"],
    linewidth=2,
    linestyle="--",
    label="Broad Money"
)

ax2.set_ylabel("Broad Money")

plt.title("Thailand: CPI and Broad Money")

lines1, labels1 = ax1.get_legend_handles_labels()
lines2, labels2 = ax2.get_legend_handles_labels()

ax1.legend(
    lines1 + lines2,
    labels1 + labels2,
    loc="upper left"
)

plt.savefig(
    "figs/ch24/cpiBM.png",
    dpi=300,
    bbox_inches="tight"
)

plt.close()
CPI BM

This immediately raises important questions:


24.9 A Simple VECM Representation

A simple VECM may be written as:

Δyt=α+β1Δyt1+β2Δxt1+λ(yt1γxt1)+ut\Delta y_t = \alpha + \beta_1 \Delta y_{t-1} + \beta_2 \Delta x_{t-1} + \lambda (y_{t-1} - \gamma x_{t-1}) + u_t

This model combines:


Short-Run Dynamics

The differenced variables:

Δyt1andΔxt1\Delta y_{t-1} \quad \text{and} \quad \Delta x_{t-1}

capture:

These effects describe how variables move from period to period.


Long-Run Equilibrium Correction

The term:

(yt1γxt1)(y_{t-1} - \gamma x_{t-1})

measures deviation from long-run equilibrium.

If the variables drift too far apart, the system gradually adjusts.


Adjustment Speed

The coefficient:

λ\lambda

measures how strongly the system reacts to disequilibrium.


24.10 Extending to Multivariate Systems

In larger systems involving several variables, the same ideas continue to apply.

A multivariate VECM contains:

Economists often write these systems compactly using matrix notation.

ΔYt=ΠYt1+Γ1ΔYt1++ut\Delta Y_t = \Pi Y_{t-1} + \Gamma_1 \Delta Y_{t-1} + \cdots + u_t

You do not need to focus heavily on the matrix algebra.

Conceptually, the interpretation remains the same:


24.11 Cointegration and Adjustment

The long-run equilibrium structure of a VECM is often summarized using:

Π=αβ\Pi = \alpha \beta'

Conceptually:


Intuition

Suppose prices rise much faster than money supply.

The system may become temporarily unbalanced.

Adjustment mechanisms may then generate:

This gradual return toward equilibrium is the essence of error correction dynamics.


24.12 Cointegration Rank

An important concept in VECMs is the:

The rank determines how many long-run equilibrium relationships exist in the system.

RankInterpretation
0no cointegration
1one equilibrium relationship
multipleseveral equilibrium relationships

24.13 Johansen Cointegration Test

The Johansen procedure is the standard approach for testing cointegration in multivariate systems.

Unlike the Engle–Granger approach, Johansen testing allows:


24.14 Trace and Maximum Eigenvalue Tests

Johansen procedures commonly report:

These help answer the question:


24.15 Johansen Test in Python

from statsmodels.tsa.vector_ar.vecm import coint_johansen

data = thai[["cpi","BM_"]].dropna()

johansen_test = coint_johansen(
    data,
    det_order=0,
    k_ar_diff=2
)

print(johansen_test.lr1)
[7.30400737e+00 1.97612579e-03]

24.16 Estimating a VECM in Python

from statsmodels.tsa.vector_ar.vecm import VECM

model = VECM(
    data,
    k_ar_diff=2,
    coint_rank=1
)

results = model.fit()

print(results.summary())

24.17 Interpreting the VECM Results

The VECM combines:

A crucial component is the:

This measures deviation from long-run equilibrium.


Example

Suppose money supply rises much faster than prices.

The VECM captures pressure for future adjustment.

Possible responses include:


24.18 Adjustment Speeds

Adjustment coefficients measure:


Large Adjustment Coefficients

Large coefficients suggest:


Small Adjustment Coefficients

Small coefficients suggest:


24.19 VECMs versus VARs in Differences

A differenced VAR removes long-run equilibrium information.

A VECM preserves it.

FeatureVAR in DifferencesVECM
stationary dynamics
long-run equilibrium
cointegrationignoredincorporated
equilibrium adjustment

24.20 Forecasting with VECMs

VECMs are often superior to differenced VARs when cointegration exists.

Why?

Because they preserve:


24.22 Financial Applications of VECMs

VECMs are widely used in finance.

Examples include:


Example: Pairs Trading

If two stock prices are cointegrated:

This idea underlies many statistical arbitrage strategies.


24.22 Macroeconomic Applications

VECMs are also widely used in macroeconomics.

Examples include:


24.23 Gretl Example: Johansen Test and VECM

Gretl provides built-in tools for cointegration testing and VECM estimation.


Step 1

Load multiple nonstationary variables.


Step 2

Menu:

Model → Time Series → VECM

Step 3

Choose:


[GRETL Screenshot Placeholder: Johansen test output]

Step 4

Estimate the VECM.

GRETL reports:


[GRETL Screenshot Placeholder: VECM estimation output]

24.24 Common Mistakes


24.25 Looking Ahead

This concludes our introduction to multivariate time series systems.

We have now studied:

The next part of the book turns toward:

We shift from modeling:

toward modeling:

of financial time series.


Key Takeaways

Concept Check

Basic

  1. What is a Vector Error Correction Model (VECM)?

  2. How does a VECM differ from a standard VAR model?

  3. When should a VECM be used instead of a VAR?


Intuition

  1. Why is differencing alone not sufficient when variables are cointegrated?

  2. What is the economic meaning of cointegration in a multivariate system?

  3. Explain the “rubber band” analogy in the context of VECM.


Structure

  1. What are the two main components of a VECM?

  2. What does the term ΠYt1\Pi Y_{t-1} represent?

  3. What do the Γi\Gamma_i terms capture?


α and β

  1. What does the matrix β\beta represent?

  2. What does the matrix α\alpha represent?

  3. Why is the decomposition Π=αβ\Pi = \alpha \beta' important?


Challenge

  1. Why is it not enough to estimate a VAR in differences when variables are cointegrated?


Interpretation & Practice

  1. A system shows strong cointegration.


  1. The cointegration rank is zero.


  1. The cointegration rank is one.


  1. Adjustment coefficients are large in magnitude.


  1. Adjustment coefficients are close to zero.


Error Correction

  1. The error correction term is significant in one equation but not the other.


  1. A variable does not respond to disequilibrium.


Economic Interpretation

  1. CPI and money supply are cointegrated.

  1. You estimate a system with:

You find:



Challenge

  1. Why is VECM considered a “restricted VAR”?


Numerical Practice

Cointegration Logic

  1. Suppose:



Rank Interpretation

  1. Suppose a system of 3 variables has:



Adjustment Coefficients

  1. Suppose:

α=(0.30.0)\alpha = \begin{pmatrix} -0.3 \\ 0.0 \end{pmatrix}


Interpretation

  1. Suppose:

βYt1=yt12xt1\beta' Y_{t-1} = y_{t-1} - 2x_{t-1}


Short vs Long Run

  1. Why is it important to include both:


Diagnostics

  1. Suppose cointegration is ignored and a VAR in differences is estimated.


Challenge

  1. Suppose cointegration rank is incorrectly specified.


Johansen Test Interpretation

  1. What does the Johansen test estimate?

  2. What is the difference between:


Interpretation

  1. Suppose the test suggests rank = 1.


  1. Suppose test statistics are small.


Challenge

  1. Why is determining the correct cointegration rank important?


IRF & Forecasting in VECM

  1. How do impulse responses differ in VECM vs VAR?

  2. Why do long-run relationships affect IRFs?


Interpretation

  1. A shock causes variables to deviate, then gradually return.


  1. Why might VECM forecasts outperform differenced VAR forecasts?


Challenge

  1. Why is long-run information valuable in forecasting?

Appendix 24A — Relationship Between VAR and VECM

A VECM can be derived algebraically from a VAR expressed in levels.

Suppose:

Yt=A1Yt1++ApYtp+utY_t = A_1 Y_{t-1} + \cdots + A_p Y_{t-p} + u_t

Rewriting the system in differences produces:

This decomposition leads directly to the VECM representation.



Appendix 24B — Why Cointegration Matters Economically

Cointegration matters because many economic variables are tied together by long-run equilibrium forces.

Examples include:

Without equilibrium adjustment:

Cointegration formalizes the idea that: