MC2Pack
While working on diverse projects, I found myself rewriting simulation
code over and over again. After a while, I started collecting chunks,
which came to be MC2Pack, an Ox package for using
MCMC sampling methods to construct a sample from a posterior density.
An earlier version of this package bore the name MCMCPack, though it was
developped entirely independently from the
work by Andrew Martin
and Kevin Quinn
on MCMCpack on R.
To avoid confusion, the name of the Ox package was changed from MCMCPack
to MC2Pack.
Implemented sampling methods
Implemented in the package are
- Metropolis-Hastings (MH), with an independent candidate density. Either
a normal, a student-t or a user-provided candidate density
can be used.
- (Griddy) Gibbs (GG), where the user can but does not have to provide
the conditional densities of the model. When the densities are not
provided, numerical inversion of the empirical distribution function
is used for sampling from this conditional density.
- Importance sampling (IS), with a candidate density as with MH.
- Adaptive Polar sampling, a method where MH is used for sampling a
direction, with the distance added through numerical inversion of the
true conditional density of the distance given the direction. See e.g.
the article on Adaptive Radial-based
Direction Sampling by Bauwens, Bos, Van Dijk and Van Oest, forthcoming in
the Journal
of Econometrics (2004).
- Adaptive Polar Importance Sampling, a method like APS but with the
MH step replaced by an importance step. See the aforementioned
article.
Apart from sampling, the package can also provide estimates of the
(logarithm of) the marginal likelihood of
the model, a building block for the Bayes factor which contrasts
models according to their fit to the data.
Documentation
The documentation of the package is available on the web, and also
in PDF format in the article Markov Chain Monte Carlo
methods: Implementation and comparison. This latter article is also
included within the installation file.
As an example, the file mcstack.ox
samples from a mixture model on stackloss data.
Download and installation instructions
Download the packages
and unzip them from your Ox main directory. MC2Pack depends on some
files in the other packages, hence the larger installation procedure. If
you want to use GnuDraw fully, also to view the graphs on screen instead
of using GiveWin, finish off the installation
by getting a working version of GnuPlot; see also the installation
instructions at the GnuDraw page.
To install the documentation on your computer, add the following lines
<tr><td><a href="../packages/gnudraw/doc/gnudraw.html">Gnudraw Graphics</a></td></tr>
<tr><td><a href="../packages/oxutils/doc/oxutils.html">OxUtils</a></td></tr>
<tr><td><a href="../packages/mc2pack/doc/mc2pack.html">MC2Pack</a></td></tr>
to the file <ox-home>/doc/oxmenu.html, e.g. after the
line pointing to the graphics reference.
The present version 2.05 works for me, though probably contains some
bugs. Please let me know if you find any.
MC2Pack change log
Below a list of the changes in MC2Pack. The latest version is available
as mc2pack.zip.
- 09/7/2009
- Updated this page to refer to version 5 of GnuDraw.
- 05/11/2007
- Updated the example files to work with the latest version of OxUtils.
- 04/01/2005
- Included a check to see if opening the output file succeeded, thanks
to Gao Feng.