This website contains Matlab code for carrying out Bayesian inference in the models discussed in Koop, G. and Korobilis, D. (2010), Bayesian Multivariate Time Series Methods for Empirical Macroeconomics. Foundations and Trends in Econometrics, Vol.3, No.4, 267-358. A working paper version of that monograph is available here. Please cite this paper when using or referring to the MATLAB code.
A manual which provides complete technical details (posterior conditionals used in MCMC algorithms, data, etc) is available here.
The programs are set-up so as to produce the empirical illustrations in the monograph. Minor alterations are required (as indicated in the code) for different prior choices, data sets, etc.
Note that code for each model is organized so that the main program is capitalized (e.g. BVAR_GIBBS.m) and functions and scripts called by the main program are in small letters. The easiest thing to do is download the main program and all scripts into one folder.
Note also that most programs are set up to either load in a data set (which is provided) or generate artificial data.
MATLAB Code for Bayesian VARs
MATLAB Code for TVP-VARs
MATLAB Code for Factor Models
Miscellaneous MATLAB Code
Here are other various scripts and subroutines which do useful things (basically these are Gauss subroutines with no precise MATLAB equivalent for which we have written the MATLAB equivalent). You do not need them to run the programs above, but some programmers may find them useful.
* UPDATE 2013:
Note that code which allows estimation of stochastic volatility as in Primiceri (2005) has been amended to take into account the corrigendum of Del Negro and Primiceri (2013) which can be found here. Note that according to this corrigendum, sampling of the states of the mixture components approximation to a log chi-square density should precede sampling of the stochastic volatilities. In theory, the order of sampling should not matter in an MCMC algorithm if the blocks are independent, however, here the two blocks of parameters are dependent and the order plays a role. Kim, Shephard and Chib (1998, REStud) have proposed a correction to the log chi-square approximations involved in the stochastic volatility estimation algorithm, and the reader might also want to take such correction into account (it is not done in the code provided).
Health warnings:
The programs are reasonably easy to use and follow the empirical examples in our monograph. There is, however, a need for caution. A knowledge of Bayesian econometrics is assumed, including recognition of the potential importance of prior distributions, and MCMC methods are inherently less robust than analytic econometric methods. There is no built-in protection against misuse.
These programs can be freely downloaded for academic purposes. Although every effort has been made to ensure that these programs are error free, we cannot guarantee this. If you find any errors, please let us know (Gary.Koop@strath.ac.uk or dikorobilis@googlemail.com).
We do not offer any support or user help facilities for these programs. These programs were written in MATLAB release 2008 and there may be minor incompatibilities with earlier versions. Note in particular that our programs use cell arrays which were not included in very old versions of MATLAB.