Objective
An AR model asks how a series depends on its own past. A vector autoregression asks how several series depend on each other's past: does order flow lead returns, do futures lead the cash index, do rates lead credit spreads? You should be able to check a VAR for stationarity, compute its mean and impulse responses by hand for two variables, run and interpret a Granger causality test, and say what a VAR cannot tell you.
The model
A VAR() for a -vector :
Each equation is an ordinary regression of one variable on lags of all variables, so OLS equation by equation is efficient (all equations share the same regressors). Element is the effect of yesterday's on today's . Contemporaneous links live only in , the covariance of the shocks.
The parameter count is the main practical constraint: coefficients plus in . Ten variables with five lags is 510 coefficients, which daily data cannot pin down. Keep VARs small, or shrink (Bayesian VARs with Minnesota priors, or factor-augmented VARs).
Stationarity, mean and covariance
Any VAR() is a VAR(1) in the stacked state , with the companion matrix from the state-space lesson. So it suffices to study :
- Stationary iff every eigenvalue of has modulus below 1. Small entries are not enough: feedback between variables can push an eigenvalue past 1.
- Mean: .
- Covariance: (Lyapunov again), and for the lag- cross-covariances .
- Persistence: deviations from the mean decay like .
If an eigenvalue equals 1 the series have unit roots. Differencing every series is wrong if they are cointegrated; the right model is then the vector error-correction model , with the rank of equal to the number of cointegrating relations (the Johansen test).
Granger causality
Granger-causes if past improves forecasts of given past . In a VAR it is a test that the lag coefficients of in the equation are jointly zero, an F (or Wald) test with restrictions.
It is a statement about predictive content, not causation. It goes wrong in predictable ways:
- Omitted common drivers. If drives both with different delays, appears to cause .
- Stale prices and asynchronous trading. An illiquid asset's last trade price lags the liquid one mechanically; the "lead–lag" is measurement, not information flow, and is not tradable once costs are included.
- Expectations. Prices Granger-cause the events they anticipate (the futures price "causes" the harvest).
- Sampling frequency. A lead of minutes looks like contemporaneous correlation (in , not ) in daily data.
- Non-stationary levels make the test statistics non-standard; test on stationary transformations, or use the Toda–Yamamoto approach in levels.
Impulse responses
The impulse response of to a unit shock in is the entry of (for a VAR(1); in general the MA() coefficients ). The cumulative long-run response is .
Shocks are usually correlated, so "a shock to holding 's shock fixed" is not a realistic experiment. The standard fix orthogonalises with the Cholesky factor and reports . This imposes a recursive ordering: the first variable's shock may move every variable on impact, the last variable's shock moves only itself. Different orderings give different answers whenever the shocks are correlated, so the ordering is an identifying assumption you must justify (fast-moving market variables last, slow macro variables first, is the usual convention). Forecast-error variance decompositions inherit the same assumption.
Worked example
a two-variable VAR by hand
with
(a) Is it stationary? (b) Find the mean. (c) Trace the response of both variables to a unit shock in for , and the cumulative long-run response. (d) What is the impact response of to a one-standard-deviation orthogonalised shock in , with ordered first and with ordered last?
Show solutionHide solution
(a) The characteristic polynomial is , so and . Both inside the unit circle: stationary, with deviations decaying roughly like .
(b) has determinant , so
(c) The response is the first column of :
| 0 | 1 | 2 | 3 | |
|---|---|---|---|---|
| 1 | 0.5 | 0.29 | 0.185 | |
| 0 | 0.4 | 0.40 | 0.316 |
For example, : . The response of is hump-shaped: it builds for two periods before decaying, something a univariate AR(1) cannot produce. The cumulative response is the first column of : . Since and , each variable Granger-causes the other.
(d) The Cholesky factor with first is , so a one-s.d. shock to moves by on impact. With last, 's shock absorbs all the common component, the orthogonalised shock has s.d. , and its impact on is by construction. Same data, opposite stories: the ordering decides.
Estimating a small VAR
Simulate a system where leads but not the reverse, then see whether the tools recover it.
import numpy as np
import pandas as pd
from statsmodels.tsa.api import VAR
# Simulate a VAR(1) in which x leads y but y does not feed back into x
rng = np.random.default_rng(1)
A = np.array([[0.6, 0.0], # x_t = 0.6 x_{t-1} + e1
[0.4, 0.3]]) # y_t = 0.4 x_{t-1} + 0.3 y_{t-1} + e2
n = 1000
z = np.zeros((n, 2))
for t in range(1, n):
z[t] = A @ z[t - 1] + rng.normal(size=2)
data = pd.DataFrame(z, columns=["x", "y"])
model = VAR(data)
print("lag order by AIC:", model.select_order(maxlags=6).aic)
res = model.fit(1)
print("A_hat:\n", np.round(res.coefs[0], 3))
print("eigenvalue moduli:", np.round(np.abs(np.linalg.eigvals(res.coefs[0])), 3))
for causing, caused in [("x", "y"), ("y", "x")]:
test = res.test_causality(caused, [causing], kind="f")
print(f"{causing} -> {caused}: F = {test.test_statistic:.1f}, p = {test.pvalue:.3g}")
irf = res.irf(5).irfs[:, 1, 0] # response of y to a unit shock in x
print("IRF of y to x shock:", np.round(irf, 3))
print("true IRF: ", np.round([np.linalg.matrix_power(A, h)[1, 0] for h in range(6)], 3))
Output:
lag order by AIC: 1
A_hat:
[[0.58 0.039]
[0.393 0.294]]
eigenvalue moduli: [0.626 0.248]
x -> y: F = 211.0, p = 1.59e-45
y -> x: F = 2.1, p = 0.148
IRF of y to x shock: [0. 0.393 0.343 0.239 0.155 0.099]
true IRF: [0. 0.4 0.36 0.252 0.162 0.1 ]
How to read it, in the order you would say it in an interview:
- Lag order. AIC picks 1, matching the truth. BIC is stricter and is the safer default for forecasting; AIC is fine for testing.
- Coefficients. Row of is the equation for variable . The estimated for "lagged in the equation" is noise around the true zero (standard error about here).
- Stability. Eigenvalue moduli and are inside the unit circle, close to the true and .
- Granger. is overwhelming; has , so no evidence of feedback. With one lag each test has one restriction, so is the squared t-statistic of that single coefficient.
- Impulse response.
irfsare the non-orthogonalised responses ();orth_irfsapply the Cholesky ordering of the columns in the DataFrame. Here the estimated shock covariance is close to the identity, so the two nearly coincide, but on real data check which one you are reading.
Before trusting a VAR on real data: check the residuals for remaining autocorrelation (res.test_whiteness()), make sure the series are stationary or handle cointegration, and test stability of the coefficients across sub-samples. Lead–lag relations in markets are often strong in-sample and arbitraged away out of sample.
Knowledge check
A VAR(1) has . Is it stationary?
Knowledge check
A VAR shows that an illiquid small-cap index Granger-causes nothing, but a liquid large-cap index strongly Granger-causes the small-cap index at a one-day lag. What is the most likely explanation?
Knowledge check
Two VAR shocks have correlation 0.6. You compute orthogonalised impulse responses with the Cholesky factor. What happens if you swap the order of the two variables?
Knowledge check
How many slope and intercept coefficients does a VAR with 10 variables and 5 lags have (excluding the error covariance)?
Key takeaways
- A VAR() regresses each variable on lags of all variables; OLS equation by equation; coefficients, so keep it small or shrink.
- Stationary iff the companion matrix's eigenvalues are inside the unit circle; mean ; covariance from . With unit roots and cointegration, use a VECM.
- Granger causality is predictive content, vulnerable to omitted drivers, stale prices, expectations and sampling frequency.
- Impulse responses are ; orthogonalised ones depend on the Cholesky ordering, which is an assumption to state and defend.
- Read a fitted VAR in order: lag choice, coefficients, stability, Granger tests, impulse responses, residual whiteness.
Practice problems
Finished reading?
Answer the 4 knowledge checks to complete this lesson (0 done).