How to Simulate Data from an Estimated VAR
Guide 1 of 4 in the series Forecasting with a VAR
Based on Bayesian Macroeconometrics (Chan, 2027)
[ Full guide on GitHub | Python version ]
The guides of this series show how to set up a VAR for forecasting, using simulated data. Simulated data come from a known model, so every forecast can be compared with the forecast made with the true parameters. In this guide we build the true model of the series, a VAR(4) fitted by least squares to US real GDP growth, PCE inflation and the unemployment rate from 1960 to 2019. We check that it is stable, compute its stationary distribution, simulate a sample with bvar.util.simulate_var, and compare it with the data.
The steps
- Fit the VAR
- Check Stability and Compute the Stationary Distribution
- Simulate a Sample
- Measure the Variation across Samples

Figure 1: Left, US real GDP growth, PCE inflation and the unemployment rate from 1960Q1 to 2019Q4, against the year. Right, a sample of 240 quarters simulated from the VAR(4) fitted to these data, against the quarter. The two panels of each row share one vertical scale.
Try it
The script guide.m prints every number and draws every figure of the guide. In a copy of bvar-toolkit, open it in MATLAB and click Run, or type in the Command Window from the root of the repository:
run guides/var_simulation/guide.m