Markov Chain Monte Carlo methods: Implementation and comparison Charles S. Bos * Tinbergen Institute & Vrije Universiteit Amsterdam June 21, 2004 WORK IN PROGRESS Updated versions may appear on http://www.tinbergen.nl/~cbos/ Abstract The paper and presentation will focus on MCMC methods, implemented together in MCM- CPack, an ox package which allows you to run a range of sampling algorithm (MH, Gibbs, Griddy Gibbs, Adaptive Polar Importance Sampling, Adaptive Polar Sampling, and Adaptive Rejection Metropolis Sampling) on a given posterior. Computation of the marginal likelihood for the model is also done automatically, allowing for quick and thorough comparison of models and methods. 1 Introduction In a Bayesian analysis, a hurdle for many researchers is the need to implement the sampling method to derive the posterior density of the parameters in a model. For that purpose, this paper describes the MCMCPack package, an add-on for the Ox programming language of Doornik (1999). In this package, a range of sampling methods are implemented, together with algorithms to compute marginal likelihoods and convergence statistics. The setup of the paper is as follows. First, Section 2 describes the sampling methods. Section 3 presents a small data set, on which a normal mixture regression model is fitted. As the data set is small, a standard classical maximum likelihood procedure is not well able to characterise the parameters. A Bayesian procedure can depict the uncertainty and correlation structure between the parameters with more detail, but needs to be implemented. Using MCMCPack, 6 different sampling procedures are easily ran, and the results shown, and some concluding remarks are made in Section 4 In the appendices, the ox code necessary to implement the model in a Bayesian framework is discussed in Section A, followed by an overview of the functions in the package in part B. All code in this paper is available from the website http://www.tinbergen.nl/~cbos/. 2 Sampling methods revisited Most of the scientific or more practical research question posed can be be written in the format “What is the expected value of g(θ)?”, where g(θ) may be an inflation figure, precipi- tation, maximum loss for a large investor, or percentage of votes for a political party, possibly depending on a set of parameters θ. In mathematical terms, the object of interest is E(g(θ)) = Z θ g(θ)p θ (θ)d θ. (1) This paper is largely based on the thesis Bos (2001). Many thanks go to Herman K. van Dijk and Luc Bauwens for fruitful discussion. All remaining mistakes are my own. 1