Using this package, it is possible to call a BUGS model, summarize inferences and convergence in a table and graph, and save the simulations in arrays for easy access in R.
Update 3.2-3.2
Update 3.2-3
Update 3.2-2.1
Update 3.2-1.4
Update 3.2-1.3
Update 3.2-1.2
Update 3.2-1
Update 3.1-2.1
Update 3.1-2
Update 3.0-1
Update 2.1-17
Update 2.1-16
Update 2.1-15
Update 2.1-14
Update 2.1-13
Update 2.1-12
Update 2.1-11
Update 2.1-10
Update 2.1-9
Update 2.1-7
Update 2.1-6 (23 August 2007):
Update 2.1-5 (12 June 2007):
Update 2.1-4 (20 May 2007):
Update 2.1-3 (13 May 2007):
Update 2.0-4 (01 November 2006):
Update 2.0-3 (06 October 2006):
Update 2.0-2 (26 July 2006):
Update 2.0-1 (26 May 2006):
Update 2.0-0 (08 May 2006):
Update 1.1-1 (17 Feb 2006):
Update 1.1-0 (14 Dec 2005):
Update 1.0-1 (14 Nov 2005):
Update 1.0-0 (05 Aug 2005):
Update 0.2-9 (26 July 2005):
Update 0.2-8 (30 May 2005):
Update 0.2-6 (18 May 2005):
Update 0.2-5 (20 Oct 2004):
Update 0.2-4 (05 Oct 2004):
Update 0.2-3 (10 Sept 2004):
Update 0.2-2 (28 Apr 2004):
During the process of packaging R2WinBUGS_0.1 - R2WinBUGS_0.2-1, quite a lot of changes had been made. Those changes are not documented anywhere ...
During the process of packaging R2WinBUGS_0.1, quite a lot of changes had been made. Those changes are not documented anywhere ...
Update 30 Oct 2003:
Minor change to a return() statement to be compatible with R 1.8
Just a warning (from Ben Goodrich): if you are running Bugs.R inside a loop, you have to be careful with the data() and the inits() functions since they will not necessarily recognize locally-defined variables. One workaround is to define the variables used in data() and inits() using global assignments (<<-), but this can sometimes make the program run slower. Update 29 Aug 2003:
Fixed "bugs.data.inits" function so you can use data that have the same names as R functions.
Changed T and F to TRUE and FALSE everywhere in case the variables T and F are used as data in the main program
Caution: if you are entering the data as a list of variable names (see 10 Apr 2003 update, item 1), the data to be input into must be global variables. This can be relevant if you are running bugs() inside an R function.
Caution: bugs() has difficulty processing ragged arrays. It is better to save a whole matrix (e.g., "theta") rather than parts (e.g., "theta[1:10,1]", "theta[1:5,2]"). If you want to save part of a vector, you should do it as "theta[1:2]", not "theta[1]", "theta[2]". Update 30 Apr 2003: added time monitoring Update 29 Apr 2003:
The "attach.all" function (no longer called "attach2") overwrites so that all components of a list or data frame get attached.
Program now looks in the directory /winbug~1/ rather than /winbug~2/
Graphics parameters for margins are returned to their original state at the end of the program.
Added "digits.summary" option to the numerical display.
Added "last.values" output: a list that can be input as "inits" if you want to run the simulations longer. Update 13 Apr 2003: fixed new bug in round.bugs(). Now all numbers are saved in scientific notation. Update 10 Apr 2003:
It is now possible to enter the data as a list of variable names. For example, before you had to enter data as, data <- list (n=8, y=c(28,8,-3,7,-1,1,18,12)) or n <- 8 y <- c(28,8,-3,7,-1,1,18,12) data <- list (n=n, y=y) Now you can enter the data as, n <- 8 y <- c(28,8,-3,7,-1,1,18,12) data <- list ("n", "y") The bugs() function will figure out which method you are using (based on whether "data" is a list of numbers or a vector of character strings). This doesn't look like much, but it's convenient when you're entering lots of data!
It is now possible to enter the initial values as a function, so as to automatically a random list of inits for each of the chains. For example, in the 8-schools example below, we can do: inits <- function() list (theta=rnorm(J,0,1), mu.theta=rnorm(1,0,100), sigma.theta=runif(1,0,100))
to set up the inits as a function (rather than setting up n.chains sets of specific initial values). Then, the function call, schools.sim <- bugs (data, inits, parameters, "schools.txt", n.chains=3, n.iter=1000) automatically sets up 3 sets of initial values (each a list of theta, mu.theta, sigma.theta).
Bug in the initial rounding (the function round.bugs()) has been fixed. Thanks for Mark Clements for finding the bug and fixing it! Also, we have set the default rounding to 5 digits instead of 2. Update 01 Apr 2003: use layout() rather than split.screen() for graphical display Update 18 Mar 2003:
Get the Bugs configuration information from the original file (Registry_default.odc) rather than overwriting each time. (Fixes a bug that occurred when R was interrupted in the middle of a Bugs run.)
Display different colored dots in the right panel of the graphical display, to show the medians from each chain. Update 13 Mar 2003: fix minor bug in monitor() Update 10 Mar 2003: fix bug in pD and DIC calculations Update 7 Mar 2003:
Fix display.parallel=T option by adding min.width so that very intervals are still visible.
Compute pD separately for each sequence (which gives much more reasonable estimates before convergence). Update 8 Feb 2003: minor fixes in graphical display Update 6 Feb 2003:
Approximate "effective sample size" n.eff given for each parameter.
More explanatory material displayed.
Use bringToTop() to automatically bring up the graphics window. Update 4 Feb 2003:
Automatically compute the deviance, DIC, and pD. Bugs will not always compute DIC and pD, so we do so using the definition, DIC = E(deviance) + pD, using var(deviance)/2 as an estimate of pD. (This is derived from the chi^2 distribution. We can't use the Spiegelhalter et al. definition of DIC because we don't have access to the deviance function.)
Set default for n.thin so that, after thinning, the total number saved iterations, n.sims, is approximately 1000. Update 14 Jan 2003 to run with the new WinBugs1.4. You may see an error message and need to fix the dos.location assignment in bugs(). Update 6 Jan 2003:
Fix of bug that occurred with uppercase and lowercase variable names
Set default for n.thin so that no more than about 500 iterations will be saved from each sequence
New option "display.parallel" added to show 80% inferences from parallel sequences on the right panel of the graphical display. This can be useful to understand what is going on when there are convergence problems. Update 26 Dec 2002: fix of minwidth in bugs.plot.summary Update 11 Dec 2002:
Automatic fixing of adaptive phases. Now you no longer need to run for thousands of iterations when slice or Metropolis sampling is used.
Various minor fixes Update 10 Dec 2002:
Cool graphical display of convergence and inferences!
New "attach2" function that overwrites so that all components of the list are attached Update 29 Nov 2002:
Fix of bug in 24 Nov update.
Fix of bug in 16 Nov update.
Length of chains is now pecified in terms of "n.iter" rather than "n.keep". Update 24 Nov 2002: improved treatment of "parameters.to.save". For example, you can now use "alpha" to indicate an entire array of parameters, whereas before you had to save "alpha[]" or "alpha[,]" or whatever. Update 16 Nov 2002: mean, sd, median added to outputs Update 4 Nov 2002: more error-flagging added Update 26 Oct 2002:
Parameters saved in order of the "parameters.to.save" vector (not alphabetical order).
Output saved in both matrix and list form.
With the attach.sims=T setting (which is the default), the simulations for all the saved parameters are saved as R objects. This is convenient for later use of the simulations. Updates to 16 Oct 2002: more error-flagging added, mean/sd added to summary, fixing scientific notation so Bugs can always read data and inits Update 21 Sept 2002: "quit=F" option changed to "debug=T" First version written 18 Sept 2002 by Andrew Gelman, adapted from the EmBedBugs package by Kenneth Rice