One of the most useful features in WinBUGS 1.4 is scripting – the ability to run WinBUGS programs without having to point and click your way through the commands. The manual for WinBUGS 1.4 comes with a dedicated section (Batch mode: scripts) describing their operation.
Using this feature, it is possible to call WinBUGS from within other programs, and several users have written code to do this;
- For R, Sibylle Sturtz and Uwe Ligges have provided R2WinBUGS as an R package on the CRAN site. This is a packaged up version of Andrew Gelman’s bugs.R() function, which writes a data file, input file, and a script, runs the script in WinBUGS, and returns the output simulations to R. It runs multiple chains and performs convergence checks.
- The R2OpenBUGS package allows OpenBUGS to be called from R in the same manner as R2WinBUGS.
- You can also run OpenBUGS directly from R using the BRugs package. Unlike R2WinBUGS, this is fully interactive. This makes it possible, for example, to set additional monitors, run more updates, check convergence, and so on, in the middle of a run without needing to exit and restart WinBUGS.
- Phil Woodward has developed BugsXLA, an Excel Add-in GUI for WinBUGS. This can be used to apply a wide class of Bayesian models without any knowledge of WinBUGS. This is described in detail in his book, Bayesian Analysis Made Simple.
- For Stata and R, Susumu Shikano has made available his presentation “Stata goes BUGS (via R)” which demonstrates how to run WinBUGS from Stata using R as an interface.
- A full discusion of running WinBUGS with Stata is contained in Thompson JT, Palmer T and Moreno S. Bayesian Analysis in Stata with WinBUGS. The Stata Journal (2006); 6 (4): 530-549.
- Niels Peter Baadsgaard has helpfully pointed out that the following code in SAS8e will start up WinBUGS with txt-files produced by SAS;
data a; x '"C:\Program Files\WinBUGS14Beta\WinBUGS14.exe" /PAR "Script.txt"'; run;
- A complete worked example for remote execution using SAS has been developed by Niels Peter Baadsgaard and reported by Jeng Mah.
- Mike Smith has written a SAS macro, primarily for use in simualtions, which automatically produces script and data files, runs the MCMC, and reads in the WinBUGS output. A full specification and the code itself can be found here.
- For SAS, Samuel Mwalili has put a SASBUGS macro to run WinBUGS from a remote location on his website.
- Kevin Murphy and Maryam Mahdaviani have developed MATBUGS, which is a Matlab interface for WinBUGS and OpenBUGS. This has many satisfied customers, some of whom have contributed extensions.
- WinBUGS and OpenBUGS can now be run from GenStat (Edition 10 onwards) using the command BGXGENSTAT. More information is available from http://www.vsni.co.uk/products/genstat/htmlhelp/winbugs/WinBUGS.htm.
- Patrick Bélisle has created a series of WinBUGS related macros, including Perl programs that automatically write and run WinBUGS scripts, and create nice summary output from the program’s run. There is also a macro to convert multi-dimensional SAS data sets to WinBUGS format.
Further contributions are very welcome! Please mail us to let us know of any other software you’re aware of, as we would like to expand this page more and more. As with other WinBUGS resources, please also remember to thank the authors of these sites for generously sharing their hard-won expertise.