VAR Models: How to Produce out of sample Forecasts with Confidence Bands

How to Produce out of sample Forecasts with Confidence Bands: 

By the end of this tutorial, you will be able to produce a forecast with bands like this.

Produce VAR Model Forecast with Confidence Bands in Stata

Vector Autoregressive (VAR) models are a powerful method for analyzing and forecasting multivariate time series. In this article, we will go through the process of producing out of sample forecasts with confidence bands in Stata for VAR models. This is an invaluable tool for practitioners wishing to interpret their results with greater accuracy and confidence. Forecasts can be used for predicting future trends or for evaluating policy outcomes.

In this article, we will be exploring the use of a Vector Autoregression (VAR) model to analyze how the Consumer Price Index (CPI) in the United States is affected by variations in money supply. We will begin by estimating a VAR model, and then discuss its ability to forecast out-of-sample results. Our goal is to provide readers with an understanding of how VAR models can be used to study economic relationships and make effective policy decisions.

By the end of the article, you will be able to produce a forecast like the one below. You will be able to predict CPI variation for 2023, 2024 and 2025. As we can see, with a tighter monetary policy, prices will keep decreasing in the coming years. In case that you are interested, you can buy the material for this tutorial which includes DO File, dataset and Slides with step by step instructions.

The Model

We estimate a VAR model with 3 lags (as suggested by the lag-length criteria).

The command in stata is:

var p ms, lags(1/3)

Where

p = cpi in logs and differences. Next we multiply it x100.

ms = M2 in logs and differences. Next, we multiply it x100.

Identification Strategy: Choleski Decomposition

Money supply and its relationship with inflation is an important topic that has been studied by economists over the last century. When discussing money supply, it is important to recognize the difference between long run and short run effects. In the long run, money supply is neutral and can only cause inflation; however, in the short run, prices are rigid (nominal rigidity) and may not always respond to shocks in money supply.

Impulse Response Functions

The impulse response functions indicate that prices increase whenever there is a shock in money supply. Yet, the effect is not very significant and it vanishes after 4 quarters.

On the other hand, shocks in CPI have a negative effect on money supply. Whenever prices increase, the monetary entity tightens monetary policy to mitigate increases in prices. Money supply will decrease, and its effects vanish after 8 quarters.

Out of sample forecast with confidence bands

To produce the out of sample forecast, we use the following command:

fcast compute f, step(10)

Stata will compute the forecast 10 steps ahead, and produce the upper bound and lower bound of the forecast too.

You can graph everything together typing:

tsline p fp fp_LB fp_UB

By adding some format to the graph, you should get something like the graph below.

Note: You can buy the material of this tutorial and get the complete slides and codes to produce the graphs like the one below.

Next, you can just produce the graph of the forecast using the following command:

fcast graph gp

You will get the following graph:

Watch the video tutorial

Enjoy a step-by-step explanation. If you find the content helpful, please don't forget to hit the like button, share it with your friends, and leave a comment below. For more exciting content, make sure to subscribe to my channel and turn on notifications to stay updated whenever I post new videos. Thank you for watching!  

Purchase the Material - Download the Dataset

Upgrade your learning experience and gain a deeper understanding of the concepts and techniques presented in the video by purchasing the material. With comprehensive slides, datasets, and detailed DO files, you can work through the material at your own pace and apply what you learn to your own projects. Buying the material also shows appreciation for the instructor's efforts and supports further content creation. Take advantage of this opportunity to enhance your learning and support educational resources for all learners.