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.
fixes for new Windows toolchain and GCC7
adapt tests for changes in file.copy() results
import from base packages, fix URLs
problem when Openbugs_PATH environment variable was set but version did not get propagated correctly
Bugfix: remove coda from"Depends:" as "Imports:" is sufficient. Bugfix: Remove ":::" constructs to access function from utils that are imported.
Bugfix: samplesStats(node) did not work on node vectors of length > 1
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
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.
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).
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
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'
Fix for crash in bugsData
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().