[logo]
The BUGS Project
The BUGS Project
Calling WinBUGS1.4 remotely
((((
Welcome Page
Latest News
Contact us/BUGS list
WinBUGS
New WinBUGS examples
FAQs
DIC
GeoBUGS
PKBUGS
Running from other software
BUGS resources online
WinBUGS development site
OpenBUGS site

Calling WinBUGS 1.4 from other programs

One of the most useful new 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 new 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-library on the Cran site. This is a packaged up version of Andrew Gelman's bugs.R()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. Recent updates make the software compatible with the new OpenBUGS releases.
  • You can also run OpenBUGS directly from R using the BRugs function.
  • For Stata, Darren Greenwood has extended Adrian Mander's original code to export data from Stata to BUGS, to run a BUGS script file in batch mode, and to import results or coda back into Stata. This can be looped round for simulation work. His webpage contains full instructions.
  • Again for Stata and R, Susumu Shikano has made available his presentation and materials "Stata goes BUGS (via R)" which demonstrates how to run WinBUGS from Stata using R as an interface.
  • A full discusion of running BUGS 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.
  • Simon Frost has developed PyBugs, an example of how Python can be used to generate WinBUGS scripts and distribute them across a cluster of computers, to run in parallel.
  • Phil Woodward has developed BugsXLA v2.1, an Excel Ad-in GUI for WinBUGS. No knowledge of WinBUGS required!
  • Kevin Murphy is hosting MATBUGS, which is a Matlab interface for WinBUGS and OpenBUGS. This has many satisfied customers, some of whom have contributed extensions.
  • Using their helper functions, Jouko Lampinen and Aki Vehtari have provided a generic example showing how to call Classic BUGS or WinBUGS from Matlab in Linux. They also give a specific example (with all the necessary code, files, and references) showing how to estimate expected utilities via cross-validation, for the stack loss data used in Spiegelhalter et al. (2002)
  • Ken Rice's EmBedBUGS package for R/S writes datafiles and scripts, runs the scripts in WinBUGS, and returns the output to R/S. It is primarily intended for simulations studies although other applications are possible. Note: this package is no longer being updated.

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.


© 1996-2008 BUGS
Hosted by the MRC Biostatistics Unit, Cambridge, UK
Site designed by Alastair Stevens
TOP