Subscribe Bookmark



May 27, 2014

Omne trium perfectum: JMP add-in for WinBUGS

There's a bit of Latin that states "omne trium perfectum" or "everything that comes in threes is perfect." I had not set out to write three posts in a row on Markov Chain Monte Carlo (MCMC), but sometimes the stars align in such a way that the story continues to write itself.

But first, a joke:

A Bayesian and Frequentist apply for the same job. The interviewer tells the Frequentist, "Sorry to tell you this. You're a great candidate, but we decided to go with the Bayesian." The Frequentist is disappointed but says, "I understand, but can you tell me what tipped the balance in her favor?" The interviewer says, " On paper, you both have the same qualifications. However, the Bayesian has prior experience."

This post is actually the result of some feedback we received from one of our JMP users who frequently fits models using WinBUGS. While he found the MCMC Diagnostics add-in useful to explore posterior samples, he found it difficult to get WinBUGS output into the appropriate form. He sent me the following example to work with:  Wolfinger (1998)  analyzes tensile strength measurements for a composite material used in aircraft components (data in Table 4 in Vangel (1992)) using a model with 8 parameters. Requesting 11,000 posterior samples (assuming the first 1,000 are burn-in samples that will be tossed) for a single chain generates two output files in WinBUGS. The first, index.txt, is a list of parameters with the starting and stopping observation numbers. For this example, the contents of index.txt look like so:

a[1] 1 11000

a[2] 11001 22000

a[3] 22001 33000

a[4] 33001 44000

a[5] 44001 55000

mu 55001 66000

sigma2.a 66001 77000

sigma2.e 77001 88000

The second file called chain 1.txt contains 2 columns. The first column is the iteration number 1 to 11,000 repeated 8 times, while the second column contains the sampled values for the 8 parameters; essentially an 88,000 x 2 matrix. How can these output files be used by the JMP MCMC Diagnostic add-in (which assumes rows are samples within chains and columns are parameters)? Just apply the freely available WinBUGS to JMP Conversion add-in! (Download requires free SAS profile.) The add-in asks for the directory location of WinBUGS output files (index.txt and chain 1.txt, chain 2.txt etc) and creates a JMP table called MCMC Samples (which can be saved with a new name). See Figure 1.

Figure 1. JMP Table of MCMC Samples Converted from WinBUGS Output Files

A few points to consider. First, the data table in Figure 1 includes the first 1,000 samples that were intended as burn-in. I can either delete the rows from the table, or exclude the rows from analysis by selecting the first 1000 rows, right-clicking and choosing "Exclude/Unexclude." This causes the MCMC Diagnostics add-in to ignore these rows as if they were not present. I can always Unexclude later if I would like to examine the burn-in samples in further detail, say, to assess the speed of convergence in trace plots. Second, notice how the parameters a were renamed as a_i.  This was intentional so that variable names were not interpreted as an array by the conversion process. Make note of this as you name your parameters within WinBugs,  since the conversion may result in columns with duplicated names.


Wolfinger RD. (1998). Tolerance intervals for variance component models using Bayesian simulation. Journal of Quality Technology 30: 18-32.