WinBugs & R
· The R project for statistical computing. (you can download R from here)
CODA & R
To use CODA (Convergence Diagnostic and Output Analysis) in R, you need to have version 1.09 or later of R installed. Then, click on coda_0.7-1.zip to download the R-CODA package, save it, say, in C:\Temp or wherever you prefer. Open R, and from the menu bar select Packages, then select Install package(s) from local zip files, and direct R to the directory where you saved coda_0.7-1.zip, highlight the zip file and click on Open.
After R-CODA is installed you can load it with Load packages or by typing library(coda) at the R prompt. For help on how to use R-CODA type library(help=coda) at the R prompt.
The following link contains information on how to save WinBugs output to be analyzed by CODA:
The following link is an article by the original author of CODA
Cowles, MK and Carlin, BP (1995) Markov Chain Monte Carlo diagnostics: A comparative review, J Amer Stat Soc, 91, 883-904.
You may want to try Bayesian Output Analysis (BOA) instead of CODA. It is based on CODA but it handles better machine resources. You can download either the S-plus or R version from here: http://www.public-health.uiowa.edu/boa/
FROM R TO WinBugs
writeDatafileR.txt is a function for outputting data from R to WinBUGS written by Terry Elrod. You have to save it to disk, say, to C:\Temp, and then read it into R with the command:
To use it, type in the R command prompt
where x is either a data.frame or else a list (which contains no lists), and file1 is the name of the file where you want the data in WinBugs format be stored.
For example the code
CPO = 1:21
will create a file in D:/gabe/ called forWB.txt that will contain this:
list( x = c( 15, 26, 10, 9, 15, 20, 18, 11, 8, 20, 7, 9, 10, 11, 11, 10, 12,
42, 17, 11, 10) , y = c( 95, 71, 83, 91, 102, 87, 93, 100, 104, 94, 113, 96,
83, 84, 102, 100, 105, 57, 121, 86, 100) , CPO = c( 1, 2, 3, 4, 5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21) )
Then you can copy and paste the above into your WinBugs code.
If you use S-plus instead of R you can download from here the same function written for S-plus: