What is VAR,??? In very Simple term VAR is like trying to predict what will happen next in a story by looking at the past actions of multiple characters, instead of just one. It uses the history of several related things to forecast their future. Imagine you're trying to predict tomorrow's weather. Instead of just using today's temperature, you also consider today's humidity, wind speed, and other factors. So, you're using multiple variables to make your prediction. That's a bit like what VAR does, but for time series data. Answer from Tavishi Jaglan on linkedin.com
๐ŸŒ
Otexts
otexts.com โ€บ fpp2 โ€บ VAR.html
11.2 Vector autoregressions | Forecasting: Principles and Practice (2nd ed)
A VAR model is a generalisation of the univariate autoregressive model for forecasting a vector of time series.25 It comprises one equation per variable in the system. The right hand side of each equation includes a constant and lags of all ...
๐ŸŒ
Medium
medium.com โ€บ @Alidotab โ€บ mastering-forecasting-unveiling-the-power-of-var-modeling-for-dynamic-time-series-prediction-1b87a7d63b4b
Mastering Forecasting: Unveiling the Power of VAR Modeling for Dynamic Time Series Prediction | by Ali | Medium
January 14, 2024 - Estimation of a VAR model provides us with the coefficients that describe the relationships between each pair of time series in the system. These coefficients are essential for understanding how changes in one variable affect others and for ...
Discussions

What are the advantages and disadvantages of using vector autoregression for forecasting?
Learn how to use vector autoregression (VAR) for forecasting multiple time series variables, what are the benefits and drawbacks, and where to find more resources. More on linkedin.com
๐ŸŒ linkedin.com
10
8
April 12, 2023
Forecasting using vector autoregression
I donโ€™t know if you check out the best book on forecasting ever! But I recommend it. More on reddit.com
๐ŸŒ r/econometrics
14
5
March 29, 2021
๐ŸŒ
Machine Learning Plus
machinelearningplus.com โ€บ blog โ€บ vector autoregression (var) โ€“ comprehensive guide with examples in python
Vector Autoregression (VAR) - Comprehensive Guide with Examples in Python - machinelearningplus
August 30, 2022 - ... Vector Autoregression (VAR) is a forecasting algorithm that can be used when two or more time series influence each other. That is, the relationship between the time series involved is bi-directional.
๐ŸŒ
MathWorks
mathworks.com โ€บ econometrics toolbox โ€บ multivariate models โ€บ vector autoregression models
VAR Model Forecasting, Simulation, and Analysis - MATLAB & Simulink
Given a fully specified varm model, you must supply the autoregression coefficients to armairf. By default, armairf sends a unit shock through the system, which results in the forecast error impulse response. You can optionally supply the innovations covariance matrix and choose whether to generate generalized or orthogonalized impulse responses.
๐ŸŒ
University of Washington
faculty.washington.edu โ€บ ezivot โ€บ econ584 โ€บ notes โ€บ varModels.pdf pdf
This is page 383 Printer: Opaque this 11 Vector Autoregressive Models for
VAR model provides information about a variableโ€™s or a group of variablesโ€™ ยท forecasting ability for other variables.
๐ŸŒ
MathWorks
mathworks.com โ€บ econometrics toolbox โ€บ multivariate models โ€บ vector autoregression models
Forecast VAR Model - MATLAB & Simulink
The number of periods for the forecast (for example, numperiods in what follows) A presample time series (e.g., Y(end-3:end,:) in what follows) ... Load the Data_USEconModel data set. This example uses two time series: the logarithm of real GDP, and the real 3-month T-bill rate, both differenced to be approximately stationary. Suppose that a VAR(4) model is appropriate to describe the time series.
Find elsewhere
๐ŸŒ
Wikipedia
en.wikipedia.org โ€บ wiki โ€บ Vector_autoregression
Vector autoregression - Wikipedia
July 25, 2026 - For example, with seven variables and four lags, each matrix of coefficients for a given lag length is 7 by 7, and the vector of constants has 7 elements, so a total of 49ร—4 + 7 = 203 parameters are estimated, substantially lowering the degrees of freedom of the regression (the number of data points minus the number of parameters to be estimated). This can hurt the accuracy of the parameter estimates and hence of the forecasts ...
๐ŸŒ
Medium
medium.com โ€บ @swetha994r โ€บ time-series-forecasting-using-vector-auto-regressive-var-model-1ecd4a564ee0
Time Series Forecasting using Vector Auto Regressive(VAR)Model | by Swetha Ramanadham | Medium
June 7, 2022 - In a VAR model, each variable is a linear function of the past values of itself and the past values of all the other variables and an error term.In VAR model, forecast variable is influenced by the predictor variables and vice versa.
Top answer
1 of 2
31

I think you got it pretty right, but when building a VAR model, I usually make sure I follow these steps:

1. Select the variables

This is the most important part of building your model. If you want to forecast the price of an asset, you need to include variables that are related with the mechanism of price formation. The best way to do this is through a theoretical model. Since you did not mention what is the asset and what are the other variables you included in your model I really cannot say much about this item, but you can find a summary of asset pricing models in here.

2. Check the data and make the proper adjustments

Once you select the variables, you can make some adjustments to the data that will improve the estimation and interpretation of the model. It is useful to use summary statistics and see a plot of the series to detect outliers, missing data and other strange behaviors. When working with price data, people usually take natural logs, which is a variance-stabilizing transformation and also has a good interpretation (price difference in logs become continuously compound returns). I'm not sure if you have taken logs before estimating the model, but it is a good idea to do so if you are working with asset prices.

3. Check if data contains non-stationary components

Now you can use unit root tests to check if your series are stationary. If you are only interested in forecasting, as noted by @JacobH, you can run VAR in levels even when your series are non-stationary, but then your standard errors cannot be trusted, meaning that you can't make inference about the value of the coefficients. You've tested stationary using the ADF test, which is very commonly used in these applications, but note that you should specify if you want to run the test with i) no constant and no trend; ii) a constant and no trend; and iii) a constant and a trend. Usually price series have stochastic trends, so a linear trend will not be accurate. In this case you may choose the specification ii. In your code you used the ndiffs function of the forecast package. I am not sure which of those three alternatives this function implements in order to calculate the number of differences (I couldn't find it in the documentation). To check your result you may want to use the ur.df function in the "urca" package:

adf <- ur.df(x[, "VAR1"], type = "drift", lags = 10, selectlags = "AIC")

Note that this command will run the ADF test with a constant and the lags selected by the AIC command, with maximum lag of 10. If you have problems interpreting the results just look at this question. If the series are I(1) just use the difference, which will be equal to the continuously compounded returns. If the test indicates that the series are I(2) and you are in doubt about that you can use other tests, e.g. Phillips-Perron test (PP.test function in R). If all tests confirm that your series are I(2) (remember to use the log of the series before running the tests) then take the second difference, but note that your interpretation of the results will change, since now you are working with the difference of the continuously compounded returns. Prices of assets are usually I(1) since they are close to a random walk, which is a white noise when applying the first difference.

4. Select the order of the model

This can be done with commonly used criteria such as Akaike, Schwarz (BIC) and Hannan-Quinn. You've done that with the VARselect function and that is right, but remember what is the criterion that you used to make your decision. Usually different criteria indicate different orders for the VAR.

5. Check if there are cointegrating relationships

If all your series are I(1) or I(2), before running a VAR model, it is usually a good idea to check if there is no cointegration relationships between the series, specially if you want to make impulse response analysis with the residuals. You can do that using the Johansenn test or the Engle-Granger (only for bivariate models). In R you can run the Johansen test with the ca.jo function of the "urca" package. Note that this test also has different specifications. For price series I usually use the following code (where p is the lag length of item 4, performed with the series in levels):

jo_eigen <- ca.jo(x, type = "eigen", ecdet = "const", K = p)
jo_trace <- ca.jo(x, type = "trace", ecdet = "const", K = p)

6. Estimate the model

If your series are not cointegrated, you can easily estimate the model with the VAR command, as done in your code. In case the series are cointegrated you need to consider the long run relationship by estimating a Vector Error Correction model with the following code (where k is the order of cointegration):

vecm <- cajorls(joeigen, r = k)

7. Run diagnostics tests

To test if your model is well specified you can run a test of serial correlation on the residuals. In your code you used a Portmanteau test with the serial.test function. I've never used this function but I think it is OK. There is also a multivariate version of the Ljung-Box test implemented in the package MTS which you can run with the function mq.

8. Make predictions

After you are sure your model is well specified you can use the predict function as you did in your code. You can even plot impulse response functions to check how the variables respond to a particular shock using the irf function.

9. Evaluate predictions

Once you made your predictions you must evaluate them and compare against other models. Some methods to evaluate accuracy of forecasts can be found here, but to do that it is crucial that you divide your series in a training and a test set, as explained in the link.

2 of 2
12

I thought I would add to Regis A Ely very nice answer. His answer is not wrong, but using a VAR to forecast is different than using a VAR to do other VAR type things (i.e. IRF, FEVD, Historical Decomp. etc...). Consequently, some of the steps outlined by Regis A Ely will negatively effect your forecast in some cases.

Disclaimer:

When I refer to non-stationary data, I mean that the series contains a stochastic trend. If the data has a time/seasonal trend it must be filter appropriately.

First

Generally speaking, in an unrestricted VAR there is no need to worry about a spurious relationship. A spurious regression occurs when you regress a non-stationary series (Y) on another non-stationary series (X) and both series are not cointegrated. However, if you regress Y on X as well as lags of Y then the regression will not be spurious as the inclusion of the lag Y insures that the errors will be stationary. Said another way, lags of Y pick up the variation which was previous wrongly assigned to X. Since an unrestricted VAR is essentially a system of ARDL regressions where each equation contains the same number of lags and regressors, it should be clear that spurious regression are therefore not likely to be a problem. Said another way if your data is all I(1), regardless of whether of not it is co-integrated, you can run a VAR. VECM are only necessary when you want to both model and identify the short and long run/co-integration relationship between variables. The question now is, should you run the VAR in levels or in first differences.

Second

When forecasting, it is not necessary to first difference I(1) data. You can if you like, thought a surprisingly amount of practitioner don't. Remember when we have a non-stationary series, we can still obtain a consistent estimator. For a regression with a single lag of the dependent variable this is intuitive. If a series is following a random walk (i.e. non-stationary) we know the best estimate of where it will be next period is exactly were it was last period (i.e. beta is 1). The standard errors of estimates derived from models with non-stationary data, however, is different because strictly speaking the variance of the estimate approaches infinity as T approaches infinity. This, however, is not a problem for forecasting. Forecasting is essentially a conditional expectation and therefore only relies on the parameters estimates of your model and not standard errors. Further, prediction intervals of your forecast will either be obtained directly from your errors, by bootstrapping errors, or if you have a lot of data via empirical prediction intervals (my favorite!), all three of these approaches are unaffected by non-stationary data because again your errors will be stationary as per our spurious regression discussion above.

Why do I care?

The ADF test has low power, especially when the series is close to being unit root, but is not. Said another the ADF test will tend to mistakenly assert that a series is non-stationary when it in fact is not.

Assume that your ADF test wrongly assures that the series is non-stationary. If you make all the necessary transformation and estimate a VECM, your forecast is going to be wrong, because your model is wrong. This is why people forecast in levels.

What about Granger Causality???

You can even test GC with a VAR in levels when data is I(1). I know that sounds crazy. We know that inference is usually not possible with non-stationary data. It is however possible to test joint hypotheses, e.g. GC. This is shown in Toda and Yamamoto (1995) which draws on Sims, Stock and Watson (1990). For an application see http://davegiles.blogspot.com/2011/04/testing-for-granger-causality.html.

Last thing

If however, you want to use your VAR for things other than forecasting, be careful. A VAR in levels with non-stationary and co-integrated series can yield some weird results. For example, strictly speaking, the Moving Average representation of the VAR does not exist as the parameter matrix will not be invertible. Despite this fact IRF can still be obtained. Inference is also not feasible (thought joint hypotheses can be tested as discussed above).

Also be worry of small samples. Everything I've discussed works well in large sample, but things can get wacky in small samples. This is especially true for GC with I(1) data.

๐ŸŒ
SWARCH
aptech.com โ€บ blog โ€บ introduction-to-the-fundamentals-of-vector-autoregressive-models
Introduction to the Fundamentals of Vector Autoregressive Models | Aptech
April 15, 2021 - Structural VAR models include restrictions that allow us to identify causal relationships beyond those that can be identified with reduced form or recursive models. These causal relationships can be used to model and forecast impacts of individual shocks, such as policy decisions
๐ŸŒ
Analytics Vidhya
analyticsvidhya.com โ€บ home โ€บ developing vector autoregressive model in python!
Developing Vector AutoRegressive Model in Python! - Analytics Vidhya
April 4, 2025 - Vector AutoRegressive (VAR) is a multivariate forecasting algorithm that is used when two or more time series influence each other.
๐ŸŒ
MathWorks
mathworks.com โ€บ econometrics toolbox โ€บ multivariate models โ€บ vector autoregression models
forecast - Forecast vector autoregression (VAR) model responses - MATLAB
For example, forecast(Mdl,10,Tbl1,PresampleResponseVariables=["GDP" "CPI"]) returns a timetable of response variables containing their unconditional forecasts from the VAR model Mdl, initialized by the data in the GDP and CPI variables of the timetable of presample data in Tbl1.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ machine learning โ€บ vector-autoregression-var-for-multivariate-time-series
Vector Autoregression (VAR) for Multivariate Time Series - GeeksforGeeks
May 14, 2024 - Vector Autoregression (VAR) is a statistical tool used to investigate the dynamic relationships between multiple time series variables. Unlike univariate autoregressive models, which only forecast a single variable based on its previous values, ...
๐ŸŒ
ScienceDirect
sciencedirect.com โ€บ science โ€บ article โ€บ abs โ€บ pii โ€บ 0169207095006168
Forecasting with vector autoregressive (VAR) models subject to business cycle restrictions - ScienceDirect
November 16, 1999 - In the last decade VAR models have become a widely-used tool for forecasting macroeconomic time series. To improve the out-of-sample forecasting accuracy of these models, Bayesian random-walk prior restrictions are often imposed on VAR model ...
๐ŸŒ
CQF
cqf.com โ€บ blog โ€บ quant-finance-101 โ€บ what-is-the-vector-autoregression-model
What Is the Vector Autoregression (VAR) Model? | CQF
Learn how the Vector Autoregression (VAR) model captures relationships between multiple time series for forecasting.
๐ŸŒ
Number Analytics
numberanalytics.com โ€บ blog โ€บ 10-practical-var-strategies-enhanced-economic-forecasting
10 Practical VAR Strategies for Enhanced Economic Forecasting
March 18, 2025 - Before diving into the ten practical ... economic forecasting. Vector Autoregression (VAR) is a statistical model that generalizes the univariate autoregressive model by capturing the evolution of multiple variables over time....
๐ŸŒ
ResearchGate
researchgate.net โ€บ publication โ€บ 355929398_Forecasting_time_series_using_Vector_Autoregressive_Model
(PDF) Forecasting time series using Vector Autoregressive Model
September 18, 2021 - Forecasting time series using Vector Autoregressive Model 511 ยท Table 13: the global monthly oil and gold prices in dollars for the period from the ๏ฌrst month of 2015 to the sixth ... [18] struggles with the sparse, noisy nature of weekly PROs, its linearity assumptions fail to capture complex symptom interactions, and its static training requires full retraining for adaptation. Incremental VAR (VAR-Inc) addresses some limitations by dynamically integrating newly reported weekly PRO ground truth, enhancing adaptability to evolving health states and responsiveness to acute changes like side effects.
๐ŸŒ
Medium
subashpalvel.medium.com โ€บ time-series-forecasting-with-vector-autoregression-var-79c32079ace
Time Series Forecasting with Vector Autoregression (VAR) | by Subash Palvel | Medium
September 16, 2023 - One popular approach for time series forecasting is Vector Autoregression (VAR), which allows us to model the relationship between multiple time series variables.