Skip to main content
v2026.11,986 entries · CC-BY 4.0

Vector Autoregression (VAR): Formula, Example and Python

Vector autoregression (VAR) explained: formula, a worked two-variable example, VAR vs VECM, Python, R and Excel, and how to report results.

Written and maintained by CASRAI Editorial Board

Published · Last updated

On this page

A vector autoregression (VAR) is a multivariate time-series model in which each of K variables is regressed on its own past values and the past values of every other variable in the system. It is used when several series influence each other over time and you want to describe their dynamics, forecast them jointly, or test whether one series helps predict another. This guide gives the formula, a fully computed two-variable example, how to choose between VAR and VECM, code for Python, R and Excel, and how to report results.

What is a vector autoregression?

A VAR treats every variable in the system symmetrically: there is no pre-declared dependent or independent variable. Each variable gets its own equation, and every equation has the same right-hand side, namely lagged values of all K variables (plus a constant). Because the equations share regressors, a VAR can be estimated equation by equation with ordinary least squares. Stock and Watson (2001) review VARs for four uses, data description, forecasting, structural inference and policy analysis, and conclude that they work well for description and forecasting but are less useful for structural inference and policy analysis. For the wider discipline, see what is econometrics.

Vector autoregression formula

A VAR of order p, written VAR(p), is (notation as in the Python statsmodels documentation):

Yt = ν + A1 Yt−1 + A2 Yt−2 + … + Ap Yt−p + ut, with ut ~ Normal(0, Σu).

  • Yt: a K × 1 vector holding the K variables at time t.
  • ν: a K × 1 vector of intercepts.
  • Ai: a K × K coefficient matrix for lag i. Entry (j, k) says how much variable k at lag i moves variable j today.
  • p: the lag order, the number of past periods included.
  • ut: a K × 1 vector of errors with covariance matrix Σu, which may have nonzero off-diagonal terms (shocks to different variables can occur together).
  • T: the number of observations.

Each equation has 1 + pK coefficients, so the whole system has K(1 + pK). With K = 3 variables and p = 4 lags that is 3 × (1 + 12) = 39 coefficients, which is why VARs need long series and why lag length matters.

Vector autoregression example: a worked VAR(1)

The numbers below are hypothetical, chosen so the arithmetic is easy to follow; they are not estimates from real data. Take two series, y1 and y2, with ν = (1, 2)′, A1 = [[0.5, 0.2], [0.1, 0.4]], and last observed values YT = (10, 8)′.

Step 1: one-step forecast

  • y1: 1 + 0.5 × 10 + 0.2 × 8 = 1 + 5 + 1.6 = 7.6
  • y2: 2 + 0.1 × 10 + 0.4 × 8 = 2 + 1 + 3.2 = 6.2

Step 2: two-step forecast (feed the forecast back in)

  • y1: 1 + 0.5 × 7.6 + 0.2 × 6.2 = 1 + 3.8 + 1.24 = 6.04
  • y2: 2 + 0.1 × 7.6 + 0.4 × 6.2 = 2 + 0.76 + 2.48 = 5.24

Step 3: stability check

A VAR(1) is stable (stationary) when every eigenvalue of A1 has modulus below 1. For a 2 × 2 matrix the eigenvalues solve λ² − trace·λ + det = 0. Here trace = 0.5 + 0.4 = 0.9 and det = 0.5 × 0.4 − 0.2 × 0.1 = 0.18. So λ = (0.9 ± √(0.81 − 0.72)) / 2 = (0.9 ± 0.3) / 2, giving λ = 0.6 and 0.3. Both are below 1, so shocks die out and the forecasts converge.

Step 4: double-check against the long-run mean

For a stable VAR(1) the mean is μ = (I − A1)−1 ν. I − A1 = [[0.5, −0.2], [−0.1, 0.6]], whose determinant is 0.3 − 0.02 = 0.28, so the inverse is (1/0.28) × [[0.6, 0.2], [0.1, 0.5]]. Multiplying by ν = (1, 2)′ gives ((0.6 + 0.4)/0.28, (0.1 + 1.0)/0.28) = (3.571, 3.929). Verification: 1 + 0.5 × 3.571 + 0.2 × 3.929 = 3.571, which matches. The forecasts (7.6, 6.2) and then (6.04, 5.24) are moving steadily toward this mean.

Interpretation: how to read a VAR

Individual VAR coefficients are rarely interpreted one by one. The usual outputs are:

Output What it tells you
Coefficient matrices Ai Direction and size of lagged effects between variables; estimates are often correlated, so read them jointly.
Granger-causality test Whether lags of one set of variables improve prediction of another. The null in statsmodels is that the causing variables do not Granger-cause the remaining variables. See Granger causality; it is predictive, not structural, causation.
Impulse response function (IRF) The path of each variable after a one-time shock to one variable. Orthogonalized IRFs use a Cholesky factor of Σu, so results depend on the order in which you list the variables.
Forecasts Multi-step predictions made by iterating the system, as in the worked example.

VAR assumptions and common mistakes

  • Stationary input. The statsmodels VAR class assumes stationary data; difference or otherwise transform trending series first.
  • Variable ordering in IRFs. Because of the Cholesky decomposition, reordering variables changes orthogonalized impulse responses. State and justify your ordering.
  • Too many lags. Coefficients grow as K(1 + pK); choose p with an information criterion rather than by habit.
  • Reading Granger results as causation. They test predictive content only.
  • Ignoring cointegration. Non-stationary series that share a stochastic trend call for a different model (next section).

VAR vs VECM

Situation (per statsmodels documentation) Model
Stationary series VAR in levels
Trending series: transform or difference first VAR on the transformed series
Series sharing stochastic trends VECM, a vector error correction model; the Johansen test is available as coint_johansen in statsmodels.tsa.vector_ar.vecm

Vector autoregression in Python, R and Excel

Python (statsmodels)

from statsmodels.tsa.api import VAR
model = VAR(data)                       # data: stationary DataFrame
print(model.select_order(15).summary()) # compare information criteria
results = model.fit(maxlags=15, ic='aic')
lag_order = results.k_ar
fc = results.forecast(data.values[-lag_order:], 5)
irf = results.irf(10); irf.plot(orth=False)
results.test_causality('y1', ['y2'], kind='f')

These calls follow the statsmodels vector autoregression documentation (checked 7 November 2026). test_causality(caused, causing, kind, signif) follows Lütkepohl (2005), section 7.6.3.

R

The vars package provides VARselect() for lag choice and VAR() for estimation.

Excel

Excel has no built-in VAR command. Because every equation has identical regressors, you can estimate each equation separately with LINEST, regressing one variable on the lagged columns of all variables, then iterate forecasts by hand as in the worked example.

How to report a VAR (APA-style example)

Template (replace bracketed values with your own results): “A VAR([p]) model was estimated on [K] stationary series ([list]; T = [n]). The lag order was selected by [AIC/BIC]. Granger-causality tests indicated that [x] [did/did not] help predict [y], F([df1], [df2]) = [value], p = [value]. Orthogonalized impulse responses used a Cholesky ordering of [order], chosen because [reason].” Report the stationarity checks, the lag-selection criterion and the ordering, since readers cannot reproduce IRFs without them.

FAQ

What is the difference between VAR and VECM?

A VAR models stationary (or transformed) series directly. A VECM is the model the statsmodels documentation points to for series that share stochastic trends.

What is a VAR model in econometrics used for?

Data description, forecasting, structural inference and policy analysis, with the strongest record in description and forecasting (Stock and Watson, 2001).

How many lags should a VAR have?

Fit candidate orders and compare information criteria; statsmodels’ select_order and fit(ic=...) do this.

Does a VAR need stationary data?

The statsmodels VAR class assumes it; difference or transform trending data first.

Sources

  • statsmodels documentation, Vector Autoregressions tsa.vector_ar, checked 7 November 2026.
  • statsmodels documentation, VARResults.test_causality, checked 7 November 2026.
  • Stock, J. H., and Watson, M. W. (2001). Vector autoregressions. Journal of Economic Perspectives, 15(4), 101-115. Abstract record.
  • Lütkepohl, H. (2005). New Introduction to Multiple Time Series Analysis. Springer (cited by statsmodels for the causality test). Related tooling: statsmodels API.

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · free to try

Ask about Vector Autoregression (VAR): Formula, Example and Python

Ask your first 2 questions free below. Subscribers get 150 a day for $29 a month.

An AI assistant specialized in research administration. It cites the sources behind every answer, labels web answers and says when it can't answer.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays free to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →