Interface to the 'OpenBUGS' MCMC Software

Fully-interactive R interface to the 'OpenBUGS' software for Bayesian analysis using MCMC sampling. Runs natively and stably in 32-bit R under Windows. Versions running on Linux and on 64-bit R under Windows are in "beta" status and less efficient.


News

Changes to BRugs:

Version 0.9.0 (26 Jun 2017)

fixes for new Windows toolchain and GCC7

Version 0.8.6 (16 Dec 2015)

adapt tests for changes in file.copy() results

Version 0.8.5 (29 July 2015)

import from base packages, fix URLs

Version 0.8.4 (31 May 2015)

problem when Openbugs_PATH environment variable was set but version did not get propagated correctly

Version 0.8.2 (18 August 2013)

Bugfix: remove coda from"Depends:" as "Imports:" is sufficient. Bugfix: Remove ":::" constructs to access function from utils that are imported.

Version 0.8.1 (26 May 2013)

Bugfix: samplesStats(node) did not work on node vectors of length > 1

Version 0.8.0 (23 July 2012)

BRugs now works with an existing installation of OpenBUGS (>?)= 3.2.2.

modelSetWD is exported from the NAMESPACE

bugfixed to find examples on various Linux installations

Version 0.7.4, 0.7.5

bugfix releases

Version 0.7.3 (02 January 2012)

BRugs now supports 64-bit R on Windows, using the same helper program as Linux for calling the 32 bit OpenBUGS shared library. Thanks to Brian Ripley for the reports. This is typically slower than the more native interface used for 32-bit R on Windows.

On Linux, when the OpenBUGS library call terminates with a "trap" error, the trap message is now shown. Thanks to Alexandre Villers. Though on Windows, OpenBUGS "traps" still crash R.

modelSetWD() function added. This is simply an alias for setwd(), for compatibility with the OpenBUGS script function of the same name.

Just strip trailing spaces, not internal spaces, from updater names in infoUpdatersbyName(). Thanks to Bob O'Hara.

samplesSize() gives a warning, and samplesBgr() now gives an error, instead of crashing, when trying to use them when the sampler is in an adaptive phase.

Warning in manual that enabling/disabling updaters is not supported on Linux until the next version of OpenBUGS.

BugsCmd API function is now supported by BugsHelper, but this is not used.

Some minor bug and documentation fixes.

First CRAN version for OpenBUGS 3.2.1.

Version 0.7.1 (19 April 2011)

The configure script on Linux now automatically detects OpenBUGS installed by the RPM and DEB packages (to standards-compliant locations) as well as OpenBUGS installed by the source package.

Bug fix - bugsData should accept data as a list of variable names. Thanks to Brian Ripley for these reports.

handleRes() now explicitly labels internal OpenBUGS traps as bugs and asks the user to send a bug report to the package maintainer.

On Windows, if OpenBUGS installation is not detected in the registry, package loading continues with a warning instead of stopping with an error. If OpenBUGS was actually installed, the user can then load it from a specified directory with loadOpenBUGS(dir).

Version 0.7 (March 2011)

BRugs now works with an existing installation of OpenBUGS (3.2.1 or later) instead of being distributed with the OpenBUGS library.

On Windows, the OpenBUGS location is determined by a registry key which is installed by the OpenBUGS for Windows installation program.

On Linux, the OpenBUGS shared library and documentation are assumed to be installed together in a library directory. Using the new OpenBUGS for Linux source package OpenBUGS-3.2.1.tar.gz or later, this library directory is by default

/usr/local/lib/OpenBUGS

In most cases it should be detected automatically when installing, but it can be changed by running, for instance

R CMD INSTALL --configure-args='--with-openbugs=/usr/lib/OpenBUGS'

Version 0.61

Fix for crash in bugsData

Version 0.6

Forked from the version of BRugs (0.5.3) available on CRAN Extras. This new version supports Linux for the first time, as detailed below.

CHANGES MADE FOR LINUX PORT OF BRugs

  • A C program called BugsHelper is used to call the OpenBUGS shared library on Linux via a system() call. With one call of BugsHelper, any number of different OpenBUGS API commands can be run. The state of the model is "internalized" on entry from a file in the temporary directory, and "externalized" on exit. The source is in src/ and the binary is installed into exec/.

  • New function .OpenBUGS() to execute a sequence of OpenBUGS API commands of possibly differing types (e.g. CmdInterpreter, RealArray, Integer) with given arguments. On Windows, this is a wrapper for the old method of calling C functions from the dyn.load()-ed library. On Linux, this calls BugsHelper once. The old .CmdInterpreter and related functions still have the same interfaces, but work by calling .OpenBUGS().

  • Input and output from the OpenBUGS API on Linux is performed through files input1.txt, output1.txt, input2.txt, output2.txt, ... in the same /tmp/R*** directory as the buffer.txt file. The buffer.txt file is used as before for messages from OpenBUGS.

  • A set of global variables is stored in the options() list containing the begin and end iterations, first and last chains, thin interval and precision to calculate sample statistics. This is required because the OpenBUGS Internalize / Externalize facility used by BugsHelper does not save these variables, which are normally stored in the OpenBUGS internal module SamplesEmbed. They are not saved because OpenBUGS considers them to be part of the GUI state (equivalent to the values typed in Inference->Samples...) rather than the model state. These variables are reset when a new model is checked and compiled.

  • As a result, all functions which compute sample statistics must first call an API command which is returned by .SamplesGlobalsCmd(node). This command updates the values stored in SamplesEmbed using the values stored in options(). This ensures that OpenBUGS knows about them before calculating sample statistics. (Note this is still done on Windows where it is not necessary, but there should be negligible overhead). The directly affected functions are samplesCoda(), samplesSize(), samplesSample(), samplesStats(), samplesCorrel(), plotBgr().

  • .onLoad() in zzz.R initialises these global variables on Linux and Windows.

  • The corresponding set/get functions are changed to read and write these global variables instead of updating the values in SamplesEmbed.

  • plotBGR() modified to use a single .OpenBUGS() call to return a list of samples for each required iteration on the grid. bgrPoint() takes a sample instead of a node and iteration. Using one .OpenBUGS() call for each sample would be an order of magnitude slower using the Linux helper program. Assume the extra memory overhead, compared to the old method, is not a problem on Windows.

  • infoNodeValues() and SetValues() now read and write the values from multiple chains, and work on scalars as well as vectors.

  • modelNames() modified to use a single .OpenBUGS call instead of looping API commands over names in the model.

  • useDynLib(BRugs) removed from NAMESPACE. This is done in .OnLoad() instead, to ensure that it is only used on Windows.

  • modelGetRN() removed, as the initial random number preset is not saved by the Externalize facility. The random number state however is saved and restored properly during the model run. There is no need for the initial preset to be read by the user, as it does not change as the model runs.

  • samplesCorrel() wasn't setting begin/end/thin etc. properly, since the CorrelEmbed module doesn't use the values in SamplesEmbed. These are now read from the variables in options().

Update 0.5-3

  • fix writeModel() again by going through parse tree now
  • fix buildMCMC() to report right thinning parameters and keep all samples

Update 0.5-2

  • added seed argument to BRugsFit()
  • fix writeModel() to work for separatly specified function body
  • fix writeModel() to make larger numeric (particularly integer) values in scientific notation work

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("BRugs")

0.9-0 by Uwe Ligges, 3 years ago


Browse source code at https://github.com/cran/BRugs


Authors: OpenBUGS was developed by Andrew Thomas , Dave Lunn , David Spiegelhalter and Nicky Best. R interface developed by Uwe Ligges , Sibylle Sturtz , Andrew Gelman , Gregor Gorjanc and Chris Jackson. Linux port and most recent developments by Chris Jackson.


Documentation:   PDF Manual  


Task views: gRaphical Models in R


GPL-2 license


Imports utils, coda, grDevices, graphics, stats

System requirements: OpenBUGS (>= 3.2.2), hence Windows or Linux


Suggested by ISEtools, R2WinBUGS, bcrm, dclone, miscF.


See at CRAN