article Omne trium perfectum: JMP add-in for WinBUGS in JMP Blog
https://community.jmp.com/t5/JMP-Blog/Omne-trium-perfectum-JMP-add-in-for-WinBUGS/ba-p/30298
<P>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 <A href="http://blogs.sas.com/content/jmp/tag/mcmc/">Markov Chain Monte Carlo</A> (MCMC), but sometimes the stars align in such a way that the story continues to write itself.</P><P></P><P>But first, a joke:</P><P></P><P><EM>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."</EM></P><P></P><P>This post is actually the result of some feedback we received from one of our <A href="http://jmp.com/software">JMP</A> users who frequently fits models using WinBUGS. While he found the <A href="https://community.jmp.com/docs/DOC-6103">MCMC Diagnostics</A> 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 <A href="http://www.jstor.org/stable/1269233" target="_blank">Vangel (1992)</A>) 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:</P><P></P><P>a[1] 1 11000</P><P></P><P>a[2] 11001 22000</P><P></P><P>a[3] 22001 33000</P><P></P><P>a[4] 33001 44000</P><P></P><P>a[5] 44001 55000</P><P></P><P>mu 55001 66000</P><P></P><P>sigma2.a 66001 77000</P><P></P><P>sigma2.e 77001 88000</P><P></P><P>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 <A href="https://community.jmp.com/docs/DOC-6104">WinBUGS to JMP Conversion add-in</A>! (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.</P><P></P><P><A href="https://community.jmp.com/legacyfs/online/wp_images/2013/05/WinBUGS.jpg"><IMG class="size-medium wp-image-8955" src="https://community.jmp.com/legacyfs/online/wp_images/2013/05/WinBUGS-264x300.jpg" alt="" width="264" height="300" /></A></P><P class="wp-caption-text"><STRONG> Figure 1. JMP Table of MCMC Samples Converted from WinBUGS Output Files</STRONG></P><P></P><P></P><P>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<I> 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.</I></P><P></P><P><STRONG>Reference</STRONG></P><P>Wolfinger RD. (1998). Tolerance intervals for variance component models using Bayesian simulation. <EM>Journal of Quality Technology</EM> 30: 18-32.</P>Tue, 28 May 2013 20:37:51 GMTRichard_Zink2013-05-28T20:37:51ZOmne trium perfectum: JMP add-in for WinBUGS
https://community.jmp.com/t5/JMP-Blog/Omne-trium-perfectum-JMP-add-in-for-WinBUGS/ba-p/30298
<P>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 <A href="http://blogs.sas.com/content/jmp/tag/mcmc/">Markov Chain Monte Carlo</A> (MCMC), but sometimes the stars align in such a way that the story continues to write itself.</P><P></P><P>But first, a joke:</P><P></P><P><EM>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."</EM></P><P></P><P>This post is actually the result of some feedback we received from one of our <A href="http://jmp.com/software">JMP</A> users who frequently fits models using WinBUGS. While he found the <A href="https://community.jmp.com/docs/DOC-6103">MCMC Diagnostics</A> 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 <A href="http://www.jstor.org/stable/1269233" target="_blank">Vangel (1992)</A>) 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:</P><P></P><P>a[1] 1 11000</P><P></P><P>a[2] 11001 22000</P><P></P><P>a[3] 22001 33000</P><P></P><P>a[4] 33001 44000</P><P></P><P>a[5] 44001 55000</P><P></P><P>mu 55001 66000</P><P></P><P>sigma2.a 66001 77000</P><P></P><P>sigma2.e 77001 88000</P><P></P><P>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 <A href="https://community.jmp.com/docs/DOC-6104">WinBUGS to JMP Conversion add-in</A>! (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.</P><P></P><P><A href="https://community.jmp.com/legacyfs/online/wp_images/2013/05/WinBUGS.jpg"><IMG class="size-medium wp-image-8955" src="https://community.jmp.com/legacyfs/online/wp_images/2013/05/WinBUGS-264x300.jpg" alt="" width="264" height="300" /></A></P><P class="wp-caption-text"><STRONG> Figure 1. JMP Table of MCMC Samples Converted from WinBUGS Output Files</STRONG></P><P></P><P></P><P>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<I> 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.</I></P><P></P><P><STRONG>Reference</STRONG></P><P>Wolfinger RD. (1998). Tolerance intervals for variance component models using Bayesian simulation. <EM>Journal of Quality Technology</EM> 30: 18-32.</P>Tue, 28 May 2013 20:37:51 GMThttps://community.jmp.com/t5/JMP-Blog/Omne-trium-perfectum-JMP-add-in-for-WinBUGS/ba-p/30298Richard_Zink2013-05-28T20:37:51Z