You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(11) |
Dec
(20) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
|
Feb
|
Mar
|
Apr
(7) |
May
(24) |
Jun
(15) |
Jul
(5) |
Aug
(21) |
Sep
(85) |
Oct
(9) |
Nov
|
Dec
|
2008 |
Jan
(15) |
Feb
(11) |
Mar
|
Apr
(2) |
May
(3) |
Jun
|
Jul
|
Aug
|
Sep
(29) |
Oct
(47) |
Nov
(1) |
Dec
(1) |
2009 |
Jan
(8) |
Feb
(12) |
Mar
(14) |
Apr
(4) |
May
(1) |
Jun
|
Jul
(5) |
Aug
|
Sep
|
Oct
(11) |
Nov
(18) |
Dec
|
2010 |
Jan
|
Feb
|
Mar
(1) |
Apr
(3) |
May
(24) |
Jun
|
Jul
(1) |
Aug
(7) |
Sep
(5) |
Oct
(3) |
Nov
(4) |
Dec
|
2011 |
Jan
|
Feb
|
Mar
(13) |
Apr
(3) |
May
(2) |
Jun
|
Jul
(1) |
Aug
(24) |
Sep
(3) |
Oct
|
Nov
|
Dec
(29) |
2012 |
Jan
(5) |
Feb
(5) |
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
(3) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
|
Apr
(9) |
May
(1) |
Jun
|
Jul
|
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
(1) |
Jun
|
Jul
(3) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2017 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(5) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <li...@us...> - 2017-06-26 15:27:59
|
Revision: 278 http://sourceforge.net/p/bugs-r/code/278 Author: ligges Date: 2017-06-26 15:27:57 +0000 (Mon, 26 Jun 2017) Log Message: ----------- try to make GCC7 happy Modified Paths: -------------- trunk/BRugs/NEWS trunk/BRugs/src/BugsHelper.c Modified: trunk/BRugs/NEWS =================================================================== --- trunk/BRugs/NEWS 2017-06-26 14:59:17 UTC (rev 277) +++ trunk/BRugs/NEWS 2017-06-26 15:27:57 UTC (rev 278) @@ -3,7 +3,7 @@ Version 0.9.0 (26 Jun 2017) ------------- -fixes for new Windows toolchain +fixes for new Windows toolchain and GCC7 Version 0.8.6 (16 Dec 2015) ------------- Modified: trunk/BRugs/src/BugsHelper.c =================================================================== --- trunk/BRugs/src/BugsHelper.c 2017-06-26 14:59:17 UTC (rev 277) +++ trunk/BRugs/src/BugsHelper.c 2017-06-26 15:27:57 UTC (rev 278) @@ -89,7 +89,7 @@ void read_input_real(char *tmpdir, double **out, int *len, int cmdno) { char *fname; - struct stat buf; + struct stat buf={.st_dev = 0}; FILE *ifp; double tmp; fname = (char *) malloc(strlen(tmpdir) + 16); @@ -115,7 +115,7 @@ void read_input_char(char *tmpdir, char **out, int *len, int cmdno) { char *fname; - struct stat buf; + struct stat buf={.st_dev = 0}; FILE *ifp; fname = (char *) malloc(strlen(tmpdir) + 16); sprintf(fname, "%s/input%d.txt", tmpdir, cmdno); @@ -252,7 +252,7 @@ int do_Internalize(char *tmpdir, char *extfile){ char *extpath, *int_cmd; - struct stat buf; + struct stat buf={.st_dev = 0}; int res; extpath = (char *) malloc(strlen(tmpdir) + 2 + strlen(extfile)); sprintf(extpath, "%s/%s", tmpdir, extfile); @@ -289,7 +289,7 @@ char *cmd, cmd_type; char *output_to_buffer_cmd = "BugsMappers.SetDest(2)"; FILE *ifp; - struct stat buf; + struct stat buf={.st_dev = 0}; do_Cmd(output_to_buffer_cmd); do_TempDir(trashdir); do_Internalize(tmpdir, extfile); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2017-06-26 14:59:18
|
Revision: 277 http://sourceforge.net/p/bugs-r/code/277 Author: ligges Date: 2017-06-26 14:59:17 +0000 (Mon, 26 Jun 2017) Log Message: ----------- prepare new version and remove openbugs.net link for now given it does not work for weeks now. Modified Paths: -------------- trunk/BRugs/DESCRIPTION Modified: trunk/BRugs/DESCRIPTION =================================================================== --- trunk/BRugs/DESCRIPTION 2017-06-26 14:57:56 UTC (rev 276) +++ trunk/BRugs/DESCRIPTION 2017-06-26 14:59:17 UTC (rev 277) @@ -1,7 +1,7 @@ Package: BRugs Title: Interface to the 'OpenBUGS' MCMC Software -Version: 0.8-6 -Date: 2015-12-16 +Version: 0.9-0 +Date: 2017-06-26 Author: 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. Description: 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. Maintainer: Uwe Ligges <li...@st...> @@ -9,4 +9,3 @@ Imports: utils, coda, grDevices, graphics, stats SystemRequirements: OpenBUGS (>= 3.2.2), hence Windows or Linux License: GPL-2 -URL: http://www.openbugs.net/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2017-06-26 14:57:58
|
Revision: 276 http://sourceforge.net/p/bugs-r/code/276 Author: ligges Date: 2017-06-26 14:57:56 +0000 (Mon, 26 Jun 2017) Log Message: ----------- adapt for new toolchain (we have to compile with 32-bit compiler / linker) Modified Paths: -------------- trunk/BRugs/DESCRIPTION trunk/BRugs/NEWS trunk/BRugs/src/Makefile.win Modified: trunk/BRugs/DESCRIPTION =================================================================== --- trunk/BRugs/DESCRIPTION 2017-06-26 13:59:22 UTC (rev 275) +++ trunk/BRugs/DESCRIPTION 2017-06-26 14:57:56 UTC (rev 276) @@ -5,7 +5,7 @@ Author: 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. Description: 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. Maintainer: Uwe Ligges <li...@st...> -Depends: R (>= 2.11.0) +Depends: R (>= 3.3.0) Imports: utils, coda, grDevices, graphics, stats SystemRequirements: OpenBUGS (>= 3.2.2), hence Windows or Linux License: GPL-2 Modified: trunk/BRugs/NEWS =================================================================== --- trunk/BRugs/NEWS 2017-06-26 13:59:22 UTC (rev 275) +++ trunk/BRugs/NEWS 2017-06-26 14:57:56 UTC (rev 276) @@ -1,6 +1,10 @@ Changes to BRugs: ===================== +Version 0.9.0 (26 Jun 2017) +------------- +fixes for new Windows toolchain + Version 0.8.6 (16 Dec 2015) ------------- adapt tests for changes in file.copy() results Modified: trunk/BRugs/src/Makefile.win =================================================================== --- trunk/BRugs/src/Makefile.win 2017-06-26 13:59:22 UTC (rev 275) +++ trunk/BRugs/src/Makefile.win 2017-06-26 14:57:56 UTC (rev 276) @@ -1,3 +1,4 @@ +include $(R_HOME)/etc/i386/Makeconf BUGS_PATH = `"${R_HOME}/bin${R_ARCH_BIN}/Rscript" -e "source('../R/windows/findOpenBUGS.R');cat(findOpenBUGS()[['dir']])"` BUGS_LIBS = "$(BUGS_PATH)/libOpenBUGS.dll" BUGS_LDFLAGS = -m32 -Wl,-rpath="$(BUGS_PATH)" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2017-06-26 13:59:25
|
Revision: 275 http://sourceforge.net/p/bugs-r/code/275 Author: ligges Date: 2017-06-26 13:59:22 +0000 (Mon, 26 Jun 2017) Log Message: ----------- changes were forgotten in commit for r273 Modified Paths: -------------- trunk/BRugs/tests/examples.Rout.save Modified: trunk/BRugs/tests/examples.Rout.save =================================================================== --- trunk/BRugs/tests/examples.Rout.save 2017-06-26 13:52:36 UTC (rev 274) +++ trunk/BRugs/tests/examples.Rout.save 2017-06-26 13:59:22 UTC (rev 275) @@ -53,11 +53,13 @@ + ### Test for posterior means within 10 percent of previously saved values + + res.true <- dget(file="examples.stats.R") ++ ++ exfiles <- unlist(lapply(test.pattern, function(tp) dir(options()$OpenBUGSExamples, pattern=tp, full.names=TRUE))) ++ ok <- file.copy(unique(exfiles), tempdir()) ++ if(!all(ok)) ++ stop("Some files could not be copied from OpenBUGS examples to the temporary directory") ++ + for (i in seq(along=test.models)) { -+ exfiles <- dir(options()$OpenBUGSExamples, pattern=test.pattern[i], full.names=TRUE) -+ ok <- file.copy(exfiles, tempdir()) -+ if(!all(ok)) -+ stop("Some files could not be copied from OpenBUGS examples to the temporary directory") + fit <- BRugsFit(data=test.datafile[i], inits=test.inits[i], + modelFile=test.modelfile[i], para=test.params[[test.models[i]]], + nBurnin=5000, nIter=20000, nThin=1, numChains=1, seed=1, @@ -66,8 +68,6 @@ + } + + } -Loading required package: coda -Loading required package: lattice Welcome to BRugs connected to OpenBUGS version 3.2.2 model is syntactically correct data loaded This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2017-06-26 13:52:38
|
Revision: 274 http://sourceforge.net/p/bugs-r/code/274 Author: ligges Date: 2017-06-26 13:52:36 +0000 (Mon, 26 Jun 2017) Log Message: ----------- fix URL http -> https Modified Paths: -------------- trunk/BRugs/inst/CITATION Modified: trunk/BRugs/inst/CITATION =================================================================== --- trunk/BRugs/inst/CITATION 2015-12-16 08:11:09 UTC (rev 273) +++ trunk/BRugs/inst/CITATION 2017-06-26 13:52:36 UTC (rev 274) @@ -12,7 +12,7 @@ pages = "12--17", number = 1, volume = 6, - url = "http://cran.r-project.org/doc/Rnews/", + url = "https://cran.r-project.org/doc/Rnews/", textVersion = paste("Thomas, A., O'Hara, B., Ligges, U., and Sturtz, S. (2006).", "Making BUGS Open.", "R News 6 (1), 12-17.") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2015-12-16 08:11:10
|
Revision: 273 http://sourceforge.net/p/bugs-r/code/273 Author: ligges Date: 2015-12-16 08:11:09 +0000 (Wed, 16 Dec 2015) Log Message: ----------- adapt tests for changes in file.copy() results Modified Paths: -------------- trunk/BRugs/DESCRIPTION trunk/BRugs/NEWS trunk/BRugs/tests/examples.R Modified: trunk/BRugs/DESCRIPTION =================================================================== --- trunk/BRugs/DESCRIPTION 2015-07-29 21:47:51 UTC (rev 272) +++ trunk/BRugs/DESCRIPTION 2015-12-16 08:11:09 UTC (rev 273) @@ -1,7 +1,7 @@ Package: BRugs Title: Interface to the 'OpenBUGS' MCMC Software -Version: 0.8-5 -Date: 2015-07-29 +Version: 0.8-6 +Date: 2015-12-16 Author: 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. Description: 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. Maintainer: Uwe Ligges <li...@st...> Modified: trunk/BRugs/NEWS =================================================================== --- trunk/BRugs/NEWS 2015-07-29 21:47:51 UTC (rev 272) +++ trunk/BRugs/NEWS 2015-12-16 08:11:09 UTC (rev 273) @@ -1,6 +1,10 @@ Changes to BRugs: ===================== +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 Modified: trunk/BRugs/tests/examples.R =================================================================== --- trunk/BRugs/tests/examples.R 2015-07-29 21:47:51 UTC (rev 272) +++ trunk/BRugs/tests/examples.R 2015-12-16 08:11:09 UTC (rev 273) @@ -35,11 +35,13 @@ ### Test for posterior means within 10 percent of previously saved values res.true <- dget(file="examples.stats.R") + +exfiles <- unlist(lapply(test.pattern, function(tp) dir(options()$OpenBUGSExamples, pattern=tp, full.names=TRUE))) +ok <- file.copy(unique(exfiles), tempdir()) +if(!all(ok)) + stop("Some files could not be copied from OpenBUGS examples to the temporary directory") + for (i in seq(along=test.models)) { - exfiles <- dir(options()$OpenBUGSExamples, pattern=test.pattern[i], full.names=TRUE) - ok <- file.copy(exfiles, tempdir()) - if(!all(ok)) - stop("Some files could not be copied from OpenBUGS examples to the temporary directory") fit <- BRugsFit(data=test.datafile[i], inits=test.inits[i], modelFile=test.modelfile[i], para=test.params[[test.models[i]]], nBurnin=5000, nIter=20000, nThin=1, numChains=1, seed=1, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2015-07-29 21:47:53
|
Revision: 272 http://sourceforge.net/p/bugs-r/code/272 Author: ligges Date: 2015-07-29 21:47:51 +0000 (Wed, 29 Jul 2015) Log Message: ----------- import from base package, fix URLs, ... Modified Paths: -------------- trunk/BRugs/DESCRIPTION trunk/BRugs/NAMESPACE trunk/BRugs/NEWS trunk/BRugs/man/BRugs.Rd trunk/BRugs/man/model.factory.Rd Modified: trunk/BRugs/DESCRIPTION =================================================================== --- trunk/BRugs/DESCRIPTION 2015-07-29 21:13:08 UTC (rev 271) +++ trunk/BRugs/DESCRIPTION 2015-07-29 21:47:51 UTC (rev 272) @@ -1,12 +1,12 @@ Package: BRugs -Title: R interface to the OpenBUGS MCMC software -Version: 0.8-4 -Date: 2015-05-31 +Title: Interface to the 'OpenBUGS' MCMC Software +Version: 0.8-5 +Date: 2015-07-29 Author: 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. -Description: 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. +Description: 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. Maintainer: Uwe Ligges <li...@st...> Depends: R (>= 2.11.0) -Imports: utils, coda +Imports: utils, coda, grDevices, graphics, stats SystemRequirements: OpenBUGS (>= 3.2.2), hence Windows or Linux License: GPL-2 -URL: http://www.openbugs.info/ +URL: http://www.openbugs.net/ Modified: trunk/BRugs/NAMESPACE =================================================================== --- trunk/BRugs/NAMESPACE 2015-07-29 21:13:08 UTC (rev 271) +++ trunk/BRugs/NAMESPACE 2015-07-29 21:47:51 UTC (rev 272) @@ -1,6 +1,10 @@ importFrom(coda, mcmc, mcmc.list) -importFrom(utils, compareVersion, maintainer, packageDescription) +importFrom(utils, compareVersion, maintainer, packageDescription, browseURL, read.table) if(tools:::.OStype() == "windows") importFrom(utils, readRegistry) +importFrom("grDevices", "dev.cur", "dev.interactive") +importFrom("graphics", "lines", "par") +importFrom("stats", "acf", "density", "quantile", "sd") + export(BRugsFit, bugsData, bugsInits, buildMCMC, dicClear, dicSet, dicStats, getNumChains, help.BRugs, help.WinBUGS, Modified: trunk/BRugs/NEWS =================================================================== --- trunk/BRugs/NEWS 2015-07-29 21:13:08 UTC (rev 271) +++ trunk/BRugs/NEWS 2015-07-29 21:47:51 UTC (rev 272) @@ -1,6 +1,9 @@ Changes to BRugs: ===================== +Version 0.8.5 (29 July 2015) +------------- +import from base packages, fix URLs Version 0.8.4 (31 May 2015) ------------- Modified: trunk/BRugs/man/BRugs.Rd =================================================================== --- trunk/BRugs/man/BRugs.Rd 2015-07-29 21:13:08 UTC (rev 271) +++ trunk/BRugs/man/BRugs.Rd 2015-07-29 21:47:51 UTC (rev 272) @@ -28,7 +28,7 @@ } \section{Permission and Disclaimer}{ BRugs is released under the GNU GENERAL PUBLIC LICENSE. - For details see \url{http://openbugs.info/} or type \code{help.BRugs()}. + For details see \url{http://www.openbugs.net/} or type \code{help.BRugs()}. More informally, potential users are reminded to be extremely careful if using this program for serious statistical analysis. We have tested the program on quite a wide set of examples, but be particularly careful @@ -40,7 +40,7 @@ within the Windows interface to OpenBUGS. This should give a "Trap" window, which indicates an internal problem with OpenBUGS. See - \url{http://www.openbugs.info/Manuals/TipsTroubleshooting.html#TrapMessages} + \url{http://www.openbugs.net/Manuals/TipsTroubleshooting.html#TrapMessages} for suggestions for how to interpret these problematic error messages. Modified: trunk/BRugs/man/model.factory.Rd =================================================================== --- trunk/BRugs/man/model.factory.Rd 2015-07-29 21:13:08 UTC (rev 271) +++ trunk/BRugs/man/model.factory.Rd 2015-07-29 21:47:51 UTC (rev 272) @@ -14,7 +14,7 @@ \item{factory}{Character (length 1) name of the factory to be disabled/enabled, for example \code{"conjugate gamma"}. See - \url{http://www.openbugs.info/Manuals/ModelMenu.html#Updateroptions} + \url{http://www.openbugs.net/Manuals/ModelMenu.html#Updateroptions} for more information. A list of the currently-used updaters in a compiled model is given by \code{\link{infoUpdatersbyName}} or This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2015-07-29 21:13:11
|
Revision: 271 http://sourceforge.net/p/bugs-r/code/271 Author: ligges Date: 2015-07-29 21:13:08 +0000 (Wed, 29 Jul 2015) Log Message: ----------- import from base packages Modified Paths: -------------- trunk/R2WinBUGS/DESCRIPTION trunk/R2WinBUGS/NAMESPACE trunk/R2WinBUGS/R/attach.all.R trunk/R2WinBUGS/inst/NEWS Modified: trunk/R2WinBUGS/DESCRIPTION =================================================================== --- trunk/R2WinBUGS/DESCRIPTION 2015-07-29 17:09:35 UTC (rev 270) +++ trunk/R2WinBUGS/DESCRIPTION 2015-07-29 21:13:08 UTC (rev 271) @@ -1,7 +1,7 @@ Package: R2WinBUGS Title: Running 'WinBUGS' and 'OpenBUGS' from 'R' / 'S-PLUS' -Date: 2015-05-31 -Version: 2.1-20 +Date: 2015-07-29 +Version: 2.1-21 Author: originally written by Andrew Gelman <ge...@st...>; changes and packaged by Sibylle Sturtz <st...@st...> and Uwe Ligges <li...@st...>. @@ -13,6 +13,7 @@ Function write.model() allows a 'BUGS' model file to be written. The class and auxiliary functions could be used with other MCMC programs, including 'JAGS'. Depends: R (>= 2.13.0), coda (>= 0.11-0), boot +Imports: utils, stats, graphics Suggests: BRugs (>= 0.3-2) SystemRequirements: OpenBugs for functions bugs() and openbugs() or WinBUGS 1.4 for function bugs() Maintainer: Uwe Ligges <li...@st...> Modified: trunk/R2WinBUGS/NAMESPACE =================================================================== --- trunk/R2WinBUGS/NAMESPACE 2015-07-29 17:09:35 UTC (rev 270) +++ trunk/R2WinBUGS/NAMESPACE 2015-07-29 21:13:08 UTC (rev 271) @@ -1,6 +1,10 @@ importFrom(coda, mcmc, mcmc.list, as.mcmc.list, read.coda) importFrom(boot, logit) +importFrom("graphics", "layout", "lines", "mtext", "par", "plot", "points", "strheight", "strwidth", "text") +importFrom("stats", "median", "qf", "quantile", "sd", "var") +importFrom("utils", "flush.console", "menu", "read.table") + export(bugs, attach.all, detach.all, Modified: trunk/R2WinBUGS/R/attach.all.R =================================================================== --- trunk/R2WinBUGS/R/attach.all.R 2015-07-29 17:09:35 UTC (rev 270) +++ trunk/R2WinBUGS/R/attach.all.R 2015-07-29 21:13:08 UTC (rev 271) @@ -9,7 +9,7 @@ "\nRemove these objects from .GlobalEnv?", sep="") if(interactive()){ if(.Platform$OS.type == "windows") - overwrite <- "YES" == winDialog(type = "yesno", question) + overwrite <- "YES" == utils::winDialog(type = "yesno", question) else overwrite <- 1 == menu(c("YES", "NO"), graphics = FALSE, title = question) } Modified: trunk/R2WinBUGS/inst/NEWS =================================================================== --- trunk/R2WinBUGS/inst/NEWS 2015-07-29 17:09:35 UTC (rev 270) +++ trunk/R2WinBUGS/inst/NEWS 2015-07-29 21:13:08 UTC (rev 271) @@ -1,6 +1,10 @@ Changes to R2WinBUGS: ===================== +Update 2.1-20/21 +- various URL fixes, DESCRIPTION file updates +- import from base packages + Update 2.1-19 - fix outdated usage: .path.package -> system.file - move vignette files around This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2015-07-29 17:09:37
|
Revision: 270 http://sourceforge.net/p/bugs-r/code/270 Author: ligges Date: 2015-07-29 17:09:35 +0000 (Wed, 29 Jul 2015) Log Message: ----------- comit for last CRAN version Modified Paths: -------------- trunk/R2WinBUGS/DESCRIPTION trunk/R2WinBUGS/R/openbugs.R trunk/R2WinBUGS/R/read.bugs.R trunk/R2WinBUGS/man/bugs.Rd trunk/R2WinBUGS/man/openbugs.Rd trunk/R2WinBUGS/vignettes/R2WinBUGS.Rnw trunk/R2WinBUGS/vignettes/bugs.tex Modified: trunk/R2WinBUGS/DESCRIPTION =================================================================== --- trunk/R2WinBUGS/DESCRIPTION 2015-05-31 15:27:27 UTC (rev 269) +++ trunk/R2WinBUGS/DESCRIPTION 2015-07-29 17:09:35 UTC (rev 270) @@ -1,22 +1,20 @@ Package: R2WinBUGS -Title: Running WinBUGS and OpenBUGS from R / S-PLUS -Date: 2013-04-07 -Version: 2.1-19 +Title: Running 'WinBUGS' and 'OpenBUGS' from 'R' / 'S-PLUS' +Date: 2015-05-31 +Version: 2.1-20 Author: originally written by Andrew Gelman <ge...@st...>; changes and packaged by Sibylle Sturtz <st...@st...> and Uwe Ligges <li...@st...>. With considerable contributions by Gregor Gorjanc <gre...@bf...> and Jouni Kerman <ke...@st...>. Ported to S-PLUS by Insightful Corp. -Description: 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 / S-PLUS. In S-PLUS, the openbugs functionality and the windows emulation - functionality is not yet available. +Description: Invoke a 'BUGS' model in 'OpenBUGS' or 'WinBUGS', a class "bugs" for 'BUGS' + results and functions to work with that class. + Function write.model() allows a 'BUGS' model file to be written. + The class and auxiliary functions could be used with other MCMC programs, including 'JAGS'. Depends: R (>= 2.13.0), coda (>= 0.11-0), boot Suggests: BRugs (>= 0.3-2) -SystemRequirements: WinBUGS 1.4 -URL: http://www.stat.columbia.edu/~gelman/bugsR/ +SystemRequirements: OpenBugs for functions bugs() and openbugs() or WinBUGS 1.4 for function bugs() Maintainer: Uwe Ligges <li...@st...> License: GPL-2 Dialect: R, S-PLUS Modified: trunk/R2WinBUGS/R/openbugs.R =================================================================== --- trunk/R2WinBUGS/R/openbugs.R 2015-05-31 15:27:27 UTC (rev 269) +++ trunk/R2WinBUGS/R/openbugs.R 2015-07-29 17:09:35 UTC (rev 270) @@ -6,7 +6,7 @@ { if(!is.R()) stop("OpenBUGS is not yet available in S-PLUS") - if(!require("BRugs")) + if(!requireNamespace("BRugs")) stop("BRugs is required") ## switching from bugs() to BRugsFit() notation Modified: trunk/R2WinBUGS/R/read.bugs.R =================================================================== --- trunk/R2WinBUGS/R/read.bugs.R 2015-05-31 15:27:27 UTC (rev 269) +++ trunk/R2WinBUGS/R/read.bugs.R 2015-07-29 17:09:35 UTC (rev 270) @@ -1,5 +1,5 @@ read.bugs <- function(codafiles, ...){ - if(!is.R() && !require("coda")) + if(!is.R() && !requireNamespace("coda", quietly = TRUE)) stop("package 'coda' is required to use this function") mcmc.list(lapply(codafiles, read.coda, index.file = file.path(dirname(codafiles[1]), "codaIndex.txt"), Modified: trunk/R2WinBUGS/man/bugs.Rd =================================================================== --- trunk/R2WinBUGS/man/bugs.Rd 2015-05-31 15:27:27 UTC (rev 269) +++ trunk/R2WinBUGS/man/bugs.Rd 2015-07-29 17:09:35 UTC (rev 270) @@ -208,8 +208,7 @@ \emph{Journal of Statistical Software} 12(3), 1-16. } -\author{Andrew Gelman, \email{ge...@st...}, - \url{http:/www.stat.columbia.edu/~gelman/bugsR/}; modifications and +\author{Andrew Gelman, \email{ge...@st...}; modifications and packaged by Sibylle Sturtz, \email{st...@st...}, and Uwe Ligges.} Modified: trunk/R2WinBUGS/man/openbugs.Rd =================================================================== --- trunk/R2WinBUGS/man/openbugs.Rd 2015-05-31 15:27:27 UTC (rev 269) +++ trunk/R2WinBUGS/man/openbugs.Rd 2015-07-29 17:09:35 UTC (rev 270) @@ -63,8 +63,7 @@ \value{A \code{\link{bugs}} object.} -\author{Andrew Gelman, \email{ge...@st...}, - \url{http:/www.stat.columbia.edu/~gelman/bugsR/}; modifications and +\author{Andrew Gelman, \email{ge...@st...}; modifications and packaged by Sibylle Sturtz, \email{st...@st...}, and Uwe Ligges. } Modified: trunk/R2WinBUGS/vignettes/R2WinBUGS.Rnw =================================================================== --- trunk/R2WinBUGS/vignettes/R2WinBUGS.Rnw 2015-05-31 15:27:27 UTC (rev 269) +++ trunk/R2WinBUGS/vignettes/R2WinBUGS.Rnw 2015-07-29 17:09:35 UTC (rev 270) @@ -1,6 +1,6 @@ %\VignetteIndexEntry{R2WinBUGS} \documentclass{Z} -\usepackage{RdRW,thumbpdf} +\usepackage{RdRW} \newcommand{\WinBUGS}{{\proglang{WinBUGS}}{}} \newcommand{\RW}{{\pkg{R2WinBUGS}}{}} \renewcommand{\R}{{\proglang{R}}{}} Modified: trunk/R2WinBUGS/vignettes/bugs.tex =================================================================== --- trunk/R2WinBUGS/vignettes/bugs.tex 2015-05-31 15:27:27 UTC (rev 269) +++ trunk/R2WinBUGS/vignettes/bugs.tex 2015-07-29 17:09:35 UTC (rev 270) @@ -137,7 +137,7 @@ \end{ldescription} \end{Value} \begin{Author}\relax -Andrew Gelman, \email{ge...@st...}, \url{http:/www.stat.columbia.edu/~gelman/bugsR/}; +Andrew Gelman, \email{ge...@st...}; modifications and packaged by Sibylle Sturtz, \email{st...@st...}, and Uwe Ligges. \end{Author} \begin{References}\relax This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2015-05-31 15:27:29
|
Revision: 269 http://sourceforge.net/p/bugs-r/code/269 Author: ligges Date: 2015-05-31 15:27:27 +0000 (Sun, 31 May 2015) Log Message: ----------- bugfix release Modified Paths: -------------- trunk/BRugs/DESCRIPTION trunk/BRugs/NEWS trunk/BRugs/R/windows/findOpenBUGS.R Modified: trunk/BRugs/DESCRIPTION =================================================================== --- trunk/BRugs/DESCRIPTION 2015-04-07 19:05:12 UTC (rev 268) +++ trunk/BRugs/DESCRIPTION 2015-05-31 15:27:27 UTC (rev 269) @@ -1,7 +1,7 @@ Package: BRugs Title: R interface to the OpenBUGS MCMC software -Version: 0.8-3 -Date: 2013-08-18 +Version: 0.8-4 +Date: 2015-05-31 Author: 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. Description: 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. Maintainer: Uwe Ligges <li...@st...> Modified: trunk/BRugs/NEWS =================================================================== --- trunk/BRugs/NEWS 2015-04-07 19:05:12 UTC (rev 268) +++ trunk/BRugs/NEWS 2015-05-31 15:27:27 UTC (rev 269) @@ -1,6 +1,13 @@ Changes to BRugs: ===================== + +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. Modified: trunk/BRugs/R/windows/findOpenBUGS.R =================================================================== --- trunk/BRugs/R/windows/findOpenBUGS.R 2015-04-07 19:05:12 UTC (rev 268) +++ trunk/BRugs/R/windows/findOpenBUGS.R 2015-05-31 15:27:27 UTC (rev 269) @@ -35,7 +35,7 @@ warning("Environment variable OpenBUGS_PATH found but cannot access ", file.path(dir, "libOpenBUGS.dll")) return() } - version.inst <- NA + version.inst <- version.full <- NA } list(dir=dir, version=version.full) } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <snt...@us...> - 2015-04-07 19:05:14
|
Revision: 268 http://sourceforge.net/p/bugs-r/code/268 Author: snthomas99 Date: 2015-04-07 19:05:12 +0000 (Tue, 07 Apr 2015) Log Message: ----------- Version3.2-3.1 with bugs.inits external Modified Paths: -------------- trunk/R2OpenBUGS/DESCRIPTION trunk/R2OpenBUGS/NAMESPACE trunk/R2OpenBUGS/R/findOpenBUGS.R trunk/R2OpenBUGS/inst/NEWS trunk/R2OpenBUGS/man/bugs.Rd Modified: trunk/R2OpenBUGS/DESCRIPTION =================================================================== --- trunk/R2OpenBUGS/DESCRIPTION 2013-08-18 22:31:14 UTC (rev 267) +++ trunk/R2OpenBUGS/DESCRIPTION 2015-04-07 19:05:12 UTC (rev 268) @@ -1,7 +1,7 @@ Package: R2OpenBUGS Title: Running OpenBUGS from R -Date: 2013-4-10 -Version: 3.2-2.2 +Date: 2015-4-06 +Version: 3.2-3.1 Author: originally written as R2WinBUGS by Andrew Gelman <ge...@st...>; changes and packaged by Sibylle Sturtz <st...@st...> and Uwe Ligges <li...@st...>. Modified: trunk/R2OpenBUGS/NAMESPACE =================================================================== --- trunk/R2OpenBUGS/NAMESPACE 2013-08-18 22:31:14 UTC (rev 267) +++ trunk/R2OpenBUGS/NAMESPACE 2015-04-07 19:05:12 UTC (rev 268) @@ -9,6 +9,7 @@ bugs.data, read.bugs, bugs.log, + bugs.inits, monitor, as.bugs.array, write.model, Modified: trunk/R2OpenBUGS/R/findOpenBUGS.R =================================================================== --- trunk/R2OpenBUGS/R/findOpenBUGS.R 2013-08-18 22:31:14 UTC (rev 267) +++ trunk/R2OpenBUGS/R/findOpenBUGS.R 2015-04-07 19:05:12 UTC (rev 268) @@ -10,9 +10,9 @@ if(.Platform$OS.type != "windows") return(Sys.which('OpenBUGS')) - deps <- utils:::packageDescription("R2OpenBUGS", fields="SystemRequirements") + deps <- utils::packageDescription("R2OpenBUGS", fields="SystemRequirements") version.req <- gsub(".*OpenBUGS ?\\(>= ?(.+)\\).*", "\\1", deps) - ob.reg <- try(utils:::readRegistry("Software\\OpenBUGS", "HLM", view = "32-bit"), silent = TRUE) + ob.reg <- try(utils::readRegistry("Software\\OpenBUGS", "HLM", view = "32-bit"), silent = TRUE) if (inherits(ob.reg, "try-error")) return(NA) @@ -29,5 +29,5 @@ if (compareVersion(max(version.inst), version.req) < 0) warning("Found OpenBUGS version ", version.inst, ".\n Requires ", version.req, " or greater.") - utils:::readRegistry(paste("Software", "OpenBUGS", rnames, sep="\\"), "HLM", view = "32-bit")[["InstallPath"]] + utils::readRegistry(paste("Software", "OpenBUGS", rnames, sep="\\"), "HLM", view = "32-bit")[["InstallPath"]] } Modified: trunk/R2OpenBUGS/inst/NEWS =================================================================== --- trunk/R2OpenBUGS/inst/NEWS 2013-08-18 22:31:14 UTC (rev 267) +++ trunk/R2OpenBUGS/inst/NEWS 2015-04-07 19:05:12 UTC (rev 268) @@ -1,6 +1,9 @@ Changes to R2OpenBUGS: ====================== +Update 3.2-3 +- bugs.inits function is now exported. + Update 3.2-2.1 - Updated reading of CODA file formats for version 3.2.2 of OpenBUGS, which now consistently uses tab delimiters. Problems with reading the log Modified: trunk/R2OpenBUGS/man/bugs.Rd =================================================================== --- trunk/R2OpenBUGS/man/bugs.Rd 2013-08-18 22:31:14 UTC (rev 267) +++ trunk/R2OpenBUGS/man/bugs.Rd 2015-04-07 19:05:12 UTC (rev 268) @@ -232,8 +232,9 @@ \emph{Journal of Statistical Software} 12(3), 1-16. } -\author{Andrew Gelman, \email{ge...@st...}, - \url{http:/www.stat.columbia.edu/~gelman/bugsR/}; modifications and +\author{Andrew Gelman, + \email{ge...@st...}; + modifications and packaged by Sibylle Sturtz, \email{st...@st...}, Uwe Ligges, and Neal Thomas} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2013-08-18 22:31:19
|
Revision: 267 http://sourceforge.net/p/bugs-r/code/267 Author: ligges Date: 2013-08-18 22:31:14 +0000 (Sun, 18 Aug 2013) Log Message: ----------- "hotfix": some functions can only be imported under Windows Modified Paths: -------------- trunk/BRugs/DESCRIPTION trunk/BRugs/NAMESPACE Modified: trunk/BRugs/DESCRIPTION =================================================================== --- trunk/BRugs/DESCRIPTION 2013-08-18 16:54:53 UTC (rev 266) +++ trunk/BRugs/DESCRIPTION 2013-08-18 22:31:14 UTC (rev 267) @@ -1,6 +1,6 @@ Package: BRugs Title: R interface to the OpenBUGS MCMC software -Version: 0.8-2 +Version: 0.8-3 Date: 2013-08-18 Author: 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. Description: 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. Modified: trunk/BRugs/NAMESPACE =================================================================== --- trunk/BRugs/NAMESPACE 2013-08-18 16:54:53 UTC (rev 266) +++ trunk/BRugs/NAMESPACE 2013-08-18 22:31:14 UTC (rev 267) @@ -1,5 +1,6 @@ importFrom(coda, mcmc, mcmc.list) -importFrom(utils, compareVersion, maintainer, packageDescription, readRegistry) +importFrom(utils, compareVersion, maintainer, packageDescription) +if(tools:::.OStype() == "windows") importFrom(utils, readRegistry) export(BRugsFit, bugsData, bugsInits, buildMCMC, dicClear, dicSet, dicStats, getNumChains, help.BRugs, help.WinBUGS, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2013-08-18 16:54:58
|
Revision: 266 http://sourceforge.net/p/bugs-r/code/266 Author: ligges Date: 2013-08-18 16:54:53 +0000 (Sun, 18 Aug 2013) Log Message: ----------- Remove utils from Depends and make proper imports so ":::" usage is no longer necessary, as requested by CRAN maintainers. Modified Paths: -------------- trunk/BRugs/DESCRIPTION trunk/BRugs/NAMESPACE trunk/BRugs/NEWS trunk/BRugs/R/buildMCMC.R trunk/BRugs/R/windows/findOpenBUGS.R Modified: trunk/BRugs/DESCRIPTION =================================================================== --- trunk/BRugs/DESCRIPTION 2013-05-26 16:05:18 UTC (rev 265) +++ trunk/BRugs/DESCRIPTION 2013-08-18 16:54:53 UTC (rev 266) @@ -1,11 +1,11 @@ Package: BRugs Title: R interface to the OpenBUGS MCMC software -Version: 0.8-1 -Date: 2013-05-26 +Version: 0.8-2 +Date: 2013-08-18 Author: 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. Description: 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. Maintainer: Uwe Ligges <li...@st...> -Depends: R (>= 2.11.0), coda +Depends: R (>= 2.11.0) Imports: utils, coda SystemRequirements: OpenBUGS (>= 3.2.2), hence Windows or Linux License: GPL-2 Modified: trunk/BRugs/NAMESPACE =================================================================== --- trunk/BRugs/NAMESPACE 2013-05-26 16:05:18 UTC (rev 265) +++ trunk/BRugs/NAMESPACE 2013-08-18 16:54:53 UTC (rev 266) @@ -1,5 +1,5 @@ importFrom(coda, mcmc, mcmc.list) -importFrom(utils, compareVersion, maintainer) +importFrom(utils, compareVersion, maintainer, packageDescription, readRegistry) export(BRugsFit, bugsData, bugsInits, buildMCMC, dicClear, dicSet, dicStats, getNumChains, help.BRugs, help.WinBUGS, Modified: trunk/BRugs/NEWS =================================================================== --- trunk/BRugs/NEWS 2013-05-26 16:05:18 UTC (rev 265) +++ trunk/BRugs/NEWS 2013-08-18 16:54:53 UTC (rev 266) @@ -1,6 +1,12 @@ Changes to BRugs: ===================== +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 Modified: trunk/BRugs/R/buildMCMC.R =================================================================== --- trunk/BRugs/R/buildMCMC.R 2013-05-26 16:05:18 UTC (rev 265) +++ trunk/BRugs/R/buildMCMC.R 2013-08-18 16:54:53 UTC (rev 266) @@ -2,10 +2,6 @@ firstChain = samplesGetFirstChain(), lastChain = samplesGetLastChain(), thin = samplesGetThin()){ - if(!is.R() && !require("coda")) - stop("package 'coda' is required to use this function") - - oldBeg <- samplesGetBeg() oldEnd <- samplesGetEnd() oldFirstChain <- samplesGetFirstChain() Modified: trunk/BRugs/R/windows/findOpenBUGS.R =================================================================== --- trunk/BRugs/R/windows/findOpenBUGS.R 2013-05-26 16:05:18 UTC (rev 265) +++ trunk/BRugs/R/windows/findOpenBUGS.R 2013-08-18 16:54:53 UTC (rev 266) @@ -2,10 +2,10 @@ { dir <- Sys.getenv("OpenBUGS_PATH") if(!nchar(dir)){ - deps <- utils:::packageDescription("BRugs", fields="SystemRequirements") + deps <- packageDescription("BRugs", fields="SystemRequirements") version.req <- gsub(".*OpenBUGS ?\\(>= ?(.+)\\).*", "\\1", deps) - ob.reg <- try(utils:::readRegistry("Software\\OpenBUGS", "HLM", view = "32-bit"), silent = TRUE) + ob.reg <- try(readRegistry("Software\\OpenBUGS", "HLM", view = "32-bit"), silent = TRUE) if (inherits(ob.reg, "try-error")) { warning("OpenBUGS ", version.req, " or greater must be installed\n(if so, this indicates missing registry keys of OpenBUGS).\nSetting the environment variable 'OpenBUGS_PATH' in advance of loading 'BRugs' overwrites the path.\nSee ?loadOpenBUGS in order to load OpenBUGS manually.") return() @@ -29,7 +29,7 @@ } ## OpenBUGS installation location - dir <- utils:::readRegistry(paste("Software","OpenBUGS",rnames,sep="\\"), "HLM", view = "32-bit")[["InstallPath"]] + dir <- readRegistry(paste("Software","OpenBUGS",rnames,sep="\\"), "HLM", view = "32-bit")[["InstallPath"]] } else { if(!file.exists(file.path(dir, "libOpenBUGS.dll"))){ warning("Environment variable OpenBUGS_PATH found but cannot access ", file.path(dir, "libOpenBUGS.dll")) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2013-05-26 16:05:20
|
Revision: 265 http://sourceforge.net/p/bugs-r/code/265 Author: ligges Date: 2013-05-26 16:05:18 +0000 (Sun, 26 May 2013) Log Message: ----------- Bugfix: samplesStats(node) did not work on node vectors of length > 1 Modified Paths: -------------- trunk/BRugs/DESCRIPTION trunk/BRugs/NEWS trunk/BRugs/R/samples.stats.R Modified: trunk/BRugs/DESCRIPTION =================================================================== --- trunk/BRugs/DESCRIPTION 2013-04-10 20:33:41 UTC (rev 264) +++ trunk/BRugs/DESCRIPTION 2013-05-26 16:05:18 UTC (rev 265) @@ -1,7 +1,7 @@ Package: BRugs Title: R interface to the OpenBUGS MCMC software -Version: 0.8-0 -Date: 2012-07-23 +Version: 0.8-1 +Date: 2013-05-26 Author: 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. Description: 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. Maintainer: Uwe Ligges <li...@st...> Modified: trunk/BRugs/NEWS =================================================================== --- trunk/BRugs/NEWS 2013-04-10 20:33:41 UTC (rev 264) +++ trunk/BRugs/NEWS 2013-05-26 16:05:18 UTC (rev 265) @@ -1,6 +1,11 @@ Changes to BRugs: ===================== +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. Modified: trunk/BRugs/R/samples.stats.R =================================================================== --- trunk/BRugs/R/samples.stats.R 2013-04-10 20:33:41 UTC (rev 264) +++ trunk/BRugs/R/samples.stats.R 2013-05-26 16:05:18 UTC (rev 265) @@ -33,7 +33,7 @@ } for(i in seq(along=node)){ - command <- paste(.SamplesGlobalsCmd(node), "SamplesEmbed.StatsGuard;SamplesEmbed.Stats") + command <- paste(.SamplesGlobalsCmd(node[i]), "SamplesEmbed.StatsGuard;SamplesEmbed.Stats") .CmdInterpreter(command) buffer <- file.path(tempdir(), "buffer.txt") rlb <- readLines(buffer) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <snt...@us...> - 2013-04-10 20:33:48
|
Revision: 264 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=264&view=rev Author: snthomas99 Date: 2013-04-10 20:33:41 +0000 (Wed, 10 Apr 2013) Log Message: ----------- remove path.package call Modified Paths: -------------- trunk/R2OpenBUGS/DESCRIPTION Modified: trunk/R2OpenBUGS/DESCRIPTION =================================================================== --- trunk/R2OpenBUGS/DESCRIPTION 2013-04-07 17:34:22 UTC (rev 263) +++ trunk/R2OpenBUGS/DESCRIPTION 2013-04-10 20:33:41 UTC (rev 264) @@ -1,7 +1,7 @@ Package: R2OpenBUGS Title: Running OpenBUGS from R -Date: 2012-4-20 -Version: 3.2-2.1 +Date: 2013-4-10 +Version: 3.2-2.2 Author: originally written as R2WinBUGS by Andrew Gelman <ge...@st...>; changes and packaged by Sibylle Sturtz <st...@st...> and Uwe Ligges <li...@st...>. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2013-04-07 17:34:33
|
Revision: 263 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=263&view=rev Author: ligges Date: 2013-04-07 17:34:22 +0000 (Sun, 07 Apr 2013) Log Message: ----------- change .path.package() -> system.file() and update version dependency Modified Paths: -------------- trunk/R2OpenBUGS/DESCRIPTION trunk/R2OpenBUGS/man/attach.all.Rd Modified: trunk/R2OpenBUGS/DESCRIPTION =================================================================== --- trunk/R2OpenBUGS/DESCRIPTION 2013-04-07 17:33:18 UTC (rev 262) +++ trunk/R2OpenBUGS/DESCRIPTION 2013-04-07 17:34:22 UTC (rev 263) @@ -12,7 +12,7 @@ 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. -Depends: R (>= 2.11.0) +Depends: R (>= 2.13.0) Imports: coda (>= 0.11-0), boot SystemRequirements: OpenBUGS (>= 3.2.2) Maintainer: Neal Thomas <snt...@ya...> Modified: trunk/R2OpenBUGS/man/attach.all.Rd =================================================================== --- trunk/R2OpenBUGS/man/attach.all.Rd 2013-04-07 17:33:18 UTC (rev 262) +++ trunk/R2OpenBUGS/man/attach.all.Rd 2013-04-07 17:34:22 UTC (rev 263) @@ -64,7 +64,7 @@ \examples{ # An example model file is given in: -model.file <- file.path(.path.package("R2OpenBUGS"), "model", "schools.txt") +model.file <- system.file("model", "schools.txt", package="R2OpenBUGS") # Some example data (see ?schools for details): data(schools) J <- nrow(schools) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2013-04-07 17:33:33
|
Revision: 262 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=262&view=rev Author: ligges Date: 2013-04-07 17:33:18 +0000 (Sun, 07 Apr 2013) Log Message: ----------- adding the vignettes again - 3rd try to get it done Added Paths: ----------- trunk/R2WinBUGS/vignettes/ trunk/R2WinBUGS/vignettes/R2WinBUGS.Rnw trunk/R2WinBUGS/vignettes/RdRW.sty trunk/R2WinBUGS/vignettes/Z.cls trunk/R2WinBUGS/vignettes/benzolsw.pdf trunk/R2WinBUGS/vignettes/bugs.tex trunk/R2WinBUGS/vignettes/countssw.pdf trunk/R2WinBUGS/vignettes/expectedsw.pdf trunk/R2WinBUGS/vignettes/literatur.bib trunk/R2WinBUGS/vignettes/literatur.bst trunk/R2WinBUGS/vignettes/plot.pdf Added: trunk/R2WinBUGS/vignettes/R2WinBUGS.Rnw =================================================================== --- trunk/R2WinBUGS/vignettes/R2WinBUGS.Rnw (rev 0) +++ trunk/R2WinBUGS/vignettes/R2WinBUGS.Rnw 2013-04-07 17:33:18 UTC (rev 262) @@ -0,0 +1,506 @@ +%\VignetteIndexEntry{R2WinBUGS} +\documentclass{Z} +\usepackage{RdRW,thumbpdf} +\newcommand{\WinBUGS}{{\proglang{WinBUGS}}{}} +\newcommand{\RW}{{\pkg{R2WinBUGS}}{}} +\renewcommand{\R}{{\proglang{R}}{}} +\setlength{\textheight}{23.5cm} + +\title{\RW{}:\protect\linebreak A Package for Running \WinBUGS{} from \R{}} +\author{Sibylle Sturtz\thanks{\email{st...@st...}}\\Fachbereich Statistik\\Universit\"at Dortmund\\Germany + \And + Uwe Ligges\thanks{\email{li...@st...}}\\Fachbereich Statistik\\Universit\"at Dortmund\\Germany + \And + Andrew Gelman\thanks{\email{ge...@st...}}\\Department of Statistics\\Columbia University\\USA +} +\Plainauthor{Sibylle Sturtz, Uwe Ligges, Andrew Gelman} +\Plaintitle{R2WinBUGS: A Package for Running WinBUGS from R} + +\Abstract{ +The \RW{} package provides convenient functions to call \WinBUGS{} from \R{}. It +automatically writes the data and scripts in a format readable by \WinBUGS{} for processing in batch mode, which +is possible since version 1.4. After the \WinBUGS{} process has finished, it is possible either to read the +resulting data into \R{} by the package itself---which gives a compact graphical summary of inference and +convergence diagnostics---or to use the facilities of the \pkg{coda} package for further analyses of the +output. Examples are given to demonstrate the usage of this package. +} + +\Keywords{\R{}, \WinBUGS{}, interface, MCMC} +\Plainkeywords{R, WinBUGS, interface, MCMC} + +\begin{document} +An earlier version of this vignette has been published by the Journal of Statistical Software:\\ +Sturtz S, Ligges U, Gelman A (2005): +``\RW{}: A Package for Running \WinBUGS{} from \R{}.'' +{\em Journal of Statistical Software}, 12(3), 1--16. + + +\section{Introduction}\label{Introduction} +The usage of Markov chain Monte Carlo (MCMC) methods became very popular within the last decade. \WinBUGS{} +\citep[\textbf{B}ayesian inference \textbf{U}sing \textbf{G}ibbs \textbf{S}ampling, ][] +{Spiegelhalter;Thomas;Best:2003} is a popular software for analyzing complex statistical models using MCMC +methods. This software uses Gibbs sampling \citep{Geman;Geman:1984,Gelfand;Smith:1990,Casella;George:1992} and the +Metropolis algorithm \citep{Metropolis;Rosenbluth;Rosenbluth;Teller;Teller:1953} +to generate a Markov chain by sampling from full conditional +distributions. +The \WinBUGS{} software is available for free +at \url{http://www.mrc-bsu.cam.ac.uk/bugs/}. +An introduction to MCMC methods is given in \cite{Gilks;Richardson;Spiegelhalter:1996}. + +Using \WinBUGS{}, the user must specify the model to run, and to load data and initial values for a specified +number of Markov chains. Then it is possible to run the Markov chain(s) and to save the results for the parameters +the user is interested in. Summary statistics of these data, convergence diagnostics, kernel estimates +etc.\ are available as well. +Nevertheless, some users of this software might be interested in saving the output and reading it into \R{} +\citep{RCore:2004} for further analyses. +\WinBUGS{} 1.4 comes with the ability to run the software in batch mode using scripts. + +The \RW{} package makes use of this feature and provides the tools to call \WinBUGS{} +directly after data manipulation in \R{}. Furthermore, it is possible to +work with the results after importing them back into \R{} again, for example to create posterior predictive simulations or, more generally, graphical displays of data and posterior simulations \citep{gelman:2004}. +Embedding in R can also be useful for frequently changed data or processing a bunch of data sets, +because it is much more convenient to use some \R{} functions (possibly within a loop) +rather than using ``copy \& paste'' to update data in \WinBUGS{} each time; however difficulties have been encountered in this area because both \R{} and \WinBUGS{} can lock up RAM in the Windows operating system. + +\R{} is a ``language for data analysis and graphics'' and an open source and +freely available statistical software package implementing that language, see \url{http://www.R-project.org/}. +Historically, \R{} is an implementation of the award-winning \proglang{S} +language and system \citep{becker:1984r,becker:1988r,chambers:1992,chambers:1998}. +\R{} and \RW{} are available from \emph{CRAN} (Comprehensive \R{} Archive Network), +i.e., \url{http://CRAN.R-Project.org} or one of its mirrors. +\RW{} could be ported to the commercial \proglang{S} implementation +\textsc{S-Plus}. Minor adaptions would be needed since \textsc{S-Plus} +lacks some of \R{}'s functions and capabilities. +If an internet connection is available, \RW{} can be installed by typing +\verb+install.packages("R2WinBUGS")+ at the \R{} command prompt. +Do not forget to load the package with \verb+library("R2WinBUGS")+. + +The package \pkg{coda} by \cite{Plummer;Best;Cowles;Vines:2004} is very useful for the analysis of \WinBUGS{}' +output, the reader might want to install this package as well. The CRAN package \pkg{boa} (Bayesian Output +Analysis Program) by \cite{Smith:2004} has similar aims. +\proglang{JAGS} (Just Another Gibbs Sampler) +by \cite{Plummer:2003} is a program for analysis of Bayesian hierarchical models using Gibbs sampling that aims for +the same functionality as classic \proglang{BUGS}. \proglang{JAGS} is developed to work closely together with \R{} and +the \pkg{coda} package. + +%% Revision 2005-01-10 start +A new and completely revised version of WinBUGS called \proglang{OpenBUGS} \citep{Spiegelhalter;Thomas;Best;Lunn:2004} +was lately published under the terms of the GPL. +\proglang{OpenBUGS} is also expected to run under Linux. +It provides a much more flexible API on which ``BRugs'' is based including +a dynamic link library, incorporating a component loader +that allows \R{} to make use of \proglang{OpenBUGS} components. +OpenBUGS is still in development and suffers frequent crashes. +As OpenBUGS becomes more reliable, +it is planned to merge ``BRugs'' and \RW{} into one \R{} package. +%% Revision 2005-01-10 end + +For other packages and projects on spatial statistics +related to \R{}, follow the link to ``\R{} spatial projects'' at CRAN. + +In this paper, we give two examples, involving educational testing experiments in schools (cf.~Section~\ref{School}), +and incidence of childhood leukaemia depending on benzene emissions (cf.~Section~\ref{Leukaemia}). Details on the +functions of \RW{} are given in Section~\ref{Programming}. These functions automatically write the data and a +script in a format readable by \WinBUGS{} for processing in batch mode, and call \WinBUGS{} from \R{}. After the +\WinBUGS{} process has finished, it is possible either to read the resulting data into \R{} by the package itself +or to use the facilities of the \pkg{coda} package for further analyses of the output. In Section~\ref{Example2}, +we demonstrate how to apply the functions provided by \RW{} on the examples' data, and how to analyze the output +both with package \pkg{coda} and with \RW{}'s methods to \verb+plot()+ and \verb+print()+ the output. + + +\section{Examples}\label{Examples} +In this Section, we introduce two examples which will be continued in Section~\ref{Example2}. + +\subsection{Schools data}\label{School} +The Scholastic Aptitude Test (SAT) measures the aptitude of high-schoolers in order to help colleges to make +admissions decisions. It is divided into two parts, verbal (SAT-V) and mathematical (SAT-M). +Our data comes from the SAT-V (Scholastic Aptitude Test-Verbal) on eight different high schools, from an experiment conducted in the late 1970s. +SAT-V is a standard multiple choice test administered by the Educational Testing Service. +This Service was interested in the effects of coaching programs for each of the selected schools. + +The study included coached and uncoached pupils, about sixty in each of the eight different schools; see +\cite{Rubin:1981}. All of them had already taken the PSAT (Preliminary SAT) which results were used as covariates. +%Even if the test is constructed to be resistant to short-term +%efforts directed specifically toward improving test performance, each of the schools is successful at increasing +%SAT scores. +For each school, the estimated treatment effect and the standard error of the effect estimate are given. +These are calculated by an analysis of covariance adjustment appropriate for a completely randomized experiment +\citep{Rubin:1981}. This example was analyzed using a hierarchical normal model in \cite{Rubin:1981} and +\citeauthor{Gelman:2003} (\citeyear{Gelman:2003}, Section 5.5). + +\subsection{Leukaemia registration data}\label{Leukaemia} +Spatial data usually arises on different, non-nesting spatial scales. One example is childhood leukaemia +registration data analyzed by \cite{Best;Cockings;Bennett;Wakefield;Elliot:2001} +using ecologic regression. Data are given for Greater London bounded by the M25 orbital motorway. +%% Revision 2005-01-10 start +The data are not available as an example in \RW{} but we use the example here +to illustrate +alternative calls to the \verb+bugs()+ function and output analysis using the \pkg{coda} package. +%% Revision 2005-01-10 end + +The observed number of leukaemia cases among children under 15 years old is given at ward level. Census wards are +administrative areas containing approximately 5000 to 10\,000 people. Central London is divided into 873 wards. The +number of incident cases of leukaemia in children is available from 1985 until 1996 from the Office of National +Statistics and the Thames Cancer Registry. A plot of these numbers is given in Figure~\ref{observed}. + +\begin{figure} +\begin{center} +\includegraphics[width=0.85\textwidth]{countssw} +\caption{\label{observed}Observed number of cases of childhood leukaemia in 1985--1996} +\end{center} +\end{figure} + +Additionally, the number of expected cases (cf.~Fig.~\ref{expected}) is calculated on the same +resolution using population numbers for different age-sex-strata and the national leukaemia +rate for the corresponding strata, for details see \cite{Best;Cockings;Bennett;Wakefield;Elliot:2001}. + +\begin{figure} +\begin{center} +\includegraphics[width=0.85\textwidth]{expectedsw} +\caption{\label{expected}Expected number of cases of childhood leukaemia in 1985--1996}%, as obtained from a simple demographic model} +\end{center} +\end{figure} + +It is assumed that benzene emissions have an effect on the incidence rate of leukaemia. Benzene emission rates are +available in tonnes per year from an atmospheric emissions inventory for London +\citep{Buckingham;Clewley;Hutchinson;Sadler;Shah:1997} produced by the London Research Centre. They are provided +at 1km $\times$ 1km grid cells, giving 2132 grid cells in total. +Their spatial distribution is shown in Figure~\ref{benzene}. + +\begin{figure} +\begin{center} +\includegraphics[width=0.9\textwidth]{benzolsw} +\caption{\label{benzene}Benzene emissions in tonnes per year} +\end{center} +\end{figure} + +For further details on the data see \cite{Best;Cockings;Bennett;Wakefield;Elliot:2001}. + +We model these data by Poisson-Gamma models introduced by \cite{Best;Ickstadt;Wolpert:2000} using \WinBUGS{}. +A linking matrix containing information which grid cell belongs to which ward +and to which amount is required. This matrix is calculated using \R{}. +Unfortunately, \WinBUGS{} does not support a list format such as directly produced by \R{}. +Therefore, the data must be provided as a matrix with 2132 rows and 873 columns (or vice versa). +Most of the entries of this matrix are zeroes, but using \verb+dump()+ to export it from \R{} +yields in a file size of 14.2~MB. +Unfortunately, opening a file of such size really slows \WinBUGS{} down, +and it was not even possible on some of our PCs. +Importing data written by our \RW{} package does not make any problems using the batch mode, +probably due to memory management issues in \WinBUGS{}. + + +\section{Implementation}\label{Programming} +The implementation of the \RW{} package is straightforward. +The ``main'' function \verb+bugs()+ is intended to be called by the user. +In principle, it is a wrapper for several other functions called therein step by step as follows: +\begin{enumerate} + \item \verb+bugs.data.inits()+ writes the data files \file{data.txt}, and \file{inits1.txt}, \file{inits2.txt}, ... + into the working directory. These files will be used by \WinBUGS{} during batch processing. + + In particular, input for \WinBUGS{} must not exceed a certain number of digits. + Moreover, it needs an \verb+E+ instead of an \verb+e+ in scientific notation. + Scientific notation is particularly desirable because of the ``number of digits'' limitation. + The default (\verb+digits = 5+) is to, e.g., reformat the number \verb+123456.789+ to \verb@1.23457E+05@. + \item \verb+bugs.script()+ writes the file \file{script.txt} that is used by \WinBUGS{} for batch processing. + \item \verb+bugs.run()+ updates the lengths of the adaptive phases in the \WinBUGS{} registry + (using a function \verb+bugs.update.settings()+), + calls \WinBUGS{}, and runs it in batch mode with \file{script.txt}. + \item \verb+bugs.sims()+ is only called if the argument \verb+codaPkg+ has been set to \verb+FALSE+ (the default). + Otherwise \verb+bugs()+ returns the filenames of stored data. These can, for example, + be imported by package \pkg{coda} (see the example in Section~\ref{Leukaemia2}, page~\pageref{codaexample}), + which provides functions for convergence diagnostics, + calculation of Monte Carlo estimates, trace plots, and so forth. + + The function \verb+bugs.sims()+ reads simulations from \WinBUGS{} into \R{} (not necessarily called by \verb+bugs()+ + itself), formats them, + monitors convergence, performs convergence checks, and computes medians and quantiles. + It also prepares the output for \verb+bugs()+ itself. +\end{enumerate} +These functions are not intended to be called by the user directly. +Arguments are passed from \verb+bugs()+ to the other functions, if appropriate. +A shortened help file of \verb+bugs()+ listing all arguments is given in Appendix~\ref{Doc}; +for the full version type \verb+?bugs+ in \R{} after having installed and loaded the package \RW{} +(see Section~\ref{Introduction}). + +%\newpage +As known from \WinBUGS{}, one must specify the \verb+data+ in form of a list, with list names equal to the names +of data in the corresponding \WinBUGS{} model. Alternatively, it is possible to specify a vector or list of names +(of mode \verb+character+). In that case objects of that names are looked for in the environment in which +\verb+bugs()+ has been called (usually that is the user's Workspace, \verb+.GlobalEnv+). +%% Revision 2005-01-10 start +If data have already been written in a file called \file{data.txt} to the working directory, +it is possible to specify \verb+data = "data.txt"+. +%% Revision 2005-01-10 end +One will usually want to supply initial values. +This can be done either in the form of a function \verb+inits()+ that creates these values, so that +different chains can be automatically initialized at different points (see Section \ref{School2}), or by specifying them +directly (see Section \ref{Leukaemia2}). +If \verb+inits()+ is not specified, +\verb+bugs()+ just uses the starting values created by \WinBUGS{}; but in practice \WinBUGS{} can crash when +reasonable initial values are not specified, and so we recommend constructing a simple \verb+inits()+ function to +simulate reasonable starting points \cite[Section C.2]{Gelman:2003}. It is also necessary to specify which +parameters should be saved for monitoring by specifying \verb+parameters.to.save+. + +The user might also want to change the defaults for the length of the burn-in (\verb+n.burnin+, which defaults to half the length of the chain) +period for every MCMC run and the number of iterations (\verb+n.iter+, default value 3) +that are used to calculate Monte Carlo estimates. +%SS: Achtung: n.iter=n.burn.in + length of stored chain! +The specification of a thinning parameter (\verb+n.thin+) is possible as well; this is useful when the number of parameters is large, to keep the saved output to a reasonably-sized R object. In the default setting, the chains are thinned enough so that approximately 1000 simulation draws are saved. + +By setting the argument \verb+debug = TRUE+, +\WinBUGS{} remains open after the run. +This way it is possible to find errors in the code or the data structure, +or even to work with that software as in a usual run. + +It is possible to run one or more Markov chains. +The number of chains (\verb+n.chains+) must be specified together with the chains' initial values (\verb+inits+). +If more than one Markov chain is requested and \verb+codaPkg+ is set to \verb+FALSE+, the convergence diagnostic +$\hat{R}$ \citep{Brooks;Gelman:1998} is calculated by \verb+bugs.sims()+ for each of the saved parameters. + +%% Revision 2005-01-10 start +Since the communication between \WinBUGS{} and \R{} is based on files, +rather huge files will be saved in the working directory by the \verb+bugs()+ call, +either files to be read in by \verb+bugs()+ itself, or by the \pkg{coda} package. +The user might want to delete those files after the desired contents has been imported into \R{}, +and save those objects, e.g., as compressed \R{} data files. +%% Revision 2005-01-10 end + +The function \verb+bugs()+ returns a rather complex object of class \verb+bugs+, +if called with argument \verb+codaPkg = FALSE+. +In order to look at the structure of such an object, type \verb+str(objectname)+. +For convenience, \RW{} provides methods corresponding to class \verb+bugs+ for +the generic functions \verb+print()+ and \verb+plot()+. + +So that user will not be overwhelmed with information; summaries of the output are provided by the +\verb+print()+ method. That is, some parameters of the \verb+bugs()+ call are summarized, and mean, +standard deviation, several quantiles of the parameters and convergence diagnostics based on \cite{Gelman;Rubin:1992} +are printed. See the example in +Section~\ref{School2}, page~\pageref{schoolssim}, for a typical output. As with \cite{Spiegelhalter;Best;Carlin;vdLinde:2002}, +%\pagebreak + the DIC computed by \verb+bugs.sims()+ is defined as the posterior mean +of the deviance plus $p_D$, the estimated effective number of parameters in the posterior distribution. We define +$p_D$ as half the posterior variance of the deviance and estimate it as half the average of the within-chain +variances of the deviance.\footnote{In contrast, \cite{Spiegelhalter;Best;Carlin;vdLinde:2002}, + and WinBUGS, define $p_D$ as the +posterior mean of the deviance evaluated at the posterior mean of the parameter values. We cannot use that +definition because the deviance function is not available to our program, which calls \WinBUGS{} from the +``outside''. Both definitions of $p_D$---ours and that introduced by \cite{Spiegelhalter;Best;Carlin;vdLinde:2002}---can be +derived from the asymptotic $\chi^2$ distribution of the deviance relative to its minimum \citep[Section 6.7]{Gelman:2003}. +We make no claim that our measure of $p_D$ is superior to that of \cite{Spiegelhalter;Best;Carlin;vdLinde:2002}; +we choose this measure purely because it is computationally possible given what is available to us from the \WinBUGS{} output.} + + +The \verb+plot()+ for objects of class \verb+bugs+ +provides information condensed in some plots conveniently arranged within the same graphics device. +For an example, see Figure~\ref{plot} in Section~\ref{School2}. It is intended to adapt this function to work with MCMC output in general, even if obtained from software other than WinBUGS. + + + +\section{Examples continued}\label{Example2} +The Examples introduced in Section~\ref{Example2} are continued in this Section. +We apply the functions provided by \RW{} +to the examples' data and analyze the output. + +\subsection{Schools data}\label{School2} +Schools example data (see Section~\ref{School}) are available with the \RW{} package: +\begin{Code} + > data(schools) + > schools + school estimate sd + 1 A 28.39 14.9 + 2 B 7.94 10.2 + 3 C -2.75 16.3 + 4 D 6.82 11.0 + 5 E -0.64 9.4 + 6 F 0.63 11.4 + 7 G 18.01 10.4 + 8 H 12.16 17.6 +\end{Code} +For modeling these data, we use a hierarchical model as proposed by \citeauthor{Gelman:2003} (\citeyear{Gelman:2003}, Section 5.5). +We assume a normal distribution for the observed estimate for each school with +mean \verb+theta+ and inverse-variance \verb+tau.y+. +The inverse-variance is given as $1/\verb+sigma.y+^{2}$ and its prior distribution is uniform on (0,1000). For the mean +\verb+theta+, we employ another normal distribution with mean \verb+mu.theta+ and inverse-variance \verb+tau.theta+. For +their prior distributions, see the following \WinBUGS{} code: + + +\begin{Code} + model { + for (j in 1:J) + { + y[j] ~ dnorm (theta[j], tau.y[j]) + theta[j] ~ dnorm (mu.theta, tau.theta) + tau.y[j] <- pow(sigma.y[j], -2) + } + mu.theta ~ dnorm (0.0, 1.0E-6) + tau.theta <- pow(sigma.theta, -2) + sigma.theta ~ dunif (0, 1000) + } +\end{Code} +This model must be stored in a separate file, e.g.~\file{schools.bug}\footnote{Emacs Speaks Statistics (ESS) +by \cite{rossini04}, a package available with Gnu Emacs \citep{stallmann99}, +recognizes and properly formats Bugs model files that have the .bug extension.}, +in an appropriate directory, say \path{c:/schools/}. +In \R{} the user must prepare the data inputs the \verb+bugs()+ function needs. +This can be a list containing the name of each data vector, e.g. +\begin{Code} + > J <- nrow(schools) + > y <- schools$estimate + > sigma.y <- schools$sd + > data <- list ("J", "y", "sigma.y") +\end{Code} +Using these data and the model file, we can run an MCMC simulation to get estimates for \verb+theta+, +\verb+mu.theta+ and \verb+sigma.theta+. Before running, the user must decide how many chains to be run +(\verb+n.chain = 3+) for how many iterations (\verb+n.iter = 1000+). +If the length of burn-in is not specified, \verb+n.burnin = floor(n.iter/2)+ is used, that is, 500 in this example. +Additionally, the user must specify initial values for the chains, for example by writing a function. This can be done by +\begin{Code} + > inits <- function(){ + + list(theta = rnorm(J, 0, 100), mu.theta = rnorm(1, 0, 100), + + sigma.theta = runif(1, 0, 100)) + + } +\end{Code} +Now, the user can start the MCMC simulation by typing +\begin{Code} + > schools.sim <- bugs(data, inits, model.file = "c:/schools/schools.bug", + + parameters = c("theta", "mu.theta", "sigma.theta"), + + n.chains = 3, n.iter = 1000, + + bugs.directory = "c:/Program Files/WinBUGS14/") +\end{Code} +in \R{}.\label{schoolssim} The argument \verb+bugs.directory+ must point to the directory +where \WinBUGS{} has been installed. +For other available arguments, see Appendix \ref{Doc}. + +The results in objects \verb+schools.sim+ can conveniently be printed by \verb+print(schools.sim)+. +The generic function \verb+print()+ calls the print method for an object of class \verb+bugs+ +provided by \RW{}. +For this example, you will get something like + +\small +\begin{Code} + > print(schools.sim) + Inference for Bugs model at "c:/schools/schools.bug" + 3 chains, each with 1000 iterations (first 500 discarded) + n.sims = 1500 iterations saved + mean sd 2.5% 25% 50% 75% 97.5% Rhat n.eff + theta[1] 11.1 9.1 -3.0 5.0 10.0 16.0 31.8 1.1 39 + theta[2] 7.6 6.6 -4.7 3.3 7.8 11.6 21.1 1.1 42 + theta[3] 5.7 8.4 -12.5 0.6 6.1 10.8 21.8 1.0 150 + theta[4] 7.1 7.0 -6.6 2.7 7.2 11.5 21.0 1.1 42 + theta[5] 5.1 6.8 -9.5 0.7 5.2 9.7 18.1 1.0 83 + theta[6] 5.7 7.3 -9.7 1.0 6.2 10.2 20.0 1.0 56 + theta[7] 10.4 7.3 -2.1 5.3 9.8 15.3 25.5 1.1 27 + theta[8] 8.3 8.4 -6.6 2.8 8.1 12.7 26.2 1.0 64 + mu.theta 7.6 5.9 -3.0 3.7 8.0 11.0 19.5 1.1 35 + sigma.theta 6.7 5.6 0.3 2.8 5.1 9.2 21.2 1.1 46 + deviance 60.8 2.5 57.0 59.1 60.2 62.1 66.6 1.0 170 + pD = 3 and DIC = 63.8 (using the rule, pD = var(deviance)/2) + + For each parameter, n.eff is a crude measure of effective sample size, + and Rhat is the potential scale reduction factor (at convergence, Rhat=1). + DIC is an estimate of expected predictive error (lower deviance is better). +\end{Code} +\normalsize +Additionally, the user can generate a plot of the results by typing \verb+plot(schools.sim)+. +The resulting plot is given in Figure~\ref{plot}. +\begin{figure}[t] +\begin{center} +\fbox{ +\includegraphics[width=0.9\textwidth]{plot} +} \caption{\label{plot}Plot produced by \RW{} package for the schools example. } +\end{center} +\end{figure} +In this plot, the left column shows a quick +summary of inference and convergence ($\widehat{R}$ is close to 1.0 for all parameters, indicating good mixing of +the three chains and thus approximate convergence); and the right column shows inferences for each set of +parameters. As can be seen in the right column, \RW{} uses the parameter names in \WinBUGS{} to structure the +output into scalar, vector, and arrays of parameters, in addition to storing the parameters as a long vector. + +For the interpretation of these results see \citeauthor{Gelman:2003} (\citeyear{Gelman:2003}, Section 5.5). + +\subsection{Leukaemia registration data}\label{Leukaemia2} +The leukaemia registration data (see Section \ref{Leukaemia}) are used to show data modeling and output reading +into \R{} using the \pkg{coda} package. A simple model for these data looks as follows: +\begin{Code} +model{ + beta.0 ~ dgamma(a.0, tau.0) + beta.benz ~ dgamma(a.benz, tau.benz) + a.0 <- 0.575 + tau.0 <- a.0*2 + a.benz <- 0.575 + tau.benz <- a.benz*2 +\end{Code} +\clearpage +\begin{Code} + for (i in 1:I) + { + count[i] ~ dpois(lambda[i]) + lambda[i] <- p[i]*expect[i] + for (j in 1:J) + { + prop[j,i] <- gamma[j,i]*(benz[j] - benzbar) + } + p[i]<- beta.0 + beta.benz*sum(prop[,i]) + } + } +\end{Code} +Here \verb+count+ denotes the number of observed incidences of childhood leukaemia in ward~\verb+i+. These are +assumed to be Poisson distributed with mean \verb+lambda+ depending on the number of expected cases \verb+expect+ +in ward \verb+i+ and an area-specific risk rate \verb+p+. For calculation of this area specific risk rate we use +an intercept \verb+beta.0+ and a term depending on the weighted sum of benzene emissions \verb+benz+ in each grid +cell \verb+j+. The weights are chosen proportional to the amount of area that ward \verb+i+ and grid cell \verb+j+ have +in common. + +In \R{} we can define all these data and then initialize the model. The data needed for this example are +\begin{description} +\item[\tt{benzbar}:] arithmetic mean of all benzene values, +\item[\tt{benz}:] a vector containing benzene emissions of all 2132 grid cells, +\item[\tt{expect}:] expected number of cases of childhood leukaemia in each of the 873 wards, +\item[\tt{count}:] observed number of childhood leukaemia in these wards, +\item[\tt{gamma}:] a $2132\times 873$ matrix containing the amount of area each grid cell and each ward have in common, +\item[\tt{J}:] total number of grid cells, i.e.~2132, and +\item[\tt{I}:] total number of ward cells, i.e.~873. +\end{description} +The parameters we want to store are regression coefficients \verb+beta.0+ and \verb+beta.benz+ as well as +\verb+p+, the area specific relative risk compared to the reference rate. This reference rate was used to +calculate the expected number of cases in each ward. + +Since we want to use the \pkg{coda} package for reading the data into \WinBUGS{}, we specify \verb+codaPkg = TRUE+ +in the \verb+bugs()+ call: +\begin{Code} + > data <- list(benzbar = mean(benz), benz = benz, expect = expect, + + count = count, gamma = gamma, J = J, I = I) + > parameters <- c("beta.0", "beta.benz", "p") + > inits1 <- list(beta.0 = 1, beta.benz = 1) + > inits2 <- list(beta.0 = 0.5, beta.benz = 0.5) + > inits <- list(inits1, inits2) + > model <- bugs(data, inits, parameters, model.file = "c:/model.bug", + + n.chains = 2, n.iter = 8000, n.burnin = 5000, n.thin = 1, + + codaPkg = TRUE, bugs.directory = "c:/Program Files/WinBUGS14/") +\end{Code} + +\clearpage +Starting with, e.g.,\label{codaexample} +\begin{Code} + > library("coda") + > codaobject <- read.bugs(model) + > plot(codaobject) +\end{Code} +it is now possible to use the \pkg{coda} package for output analyses. + + +\section*{Acknowledgments} +The work of Uwe Ligges has been supported by the Deutsche Forschungsgemeinschaft, +Sonderforschungsbereich 475. +The work of Andrew Gelman has been supported by the U.S. National Science Foundation. + +\bibliography{literatur} + +\clearpage +\begin{appendix} +\section[Help page for the function bugs()]{Help page for the function \code{bugs()}\label{Doc}} +\small +This help page has been shortened. +\input{bugs} +\end{appendix} +\end{document} Added: trunk/R2WinBUGS/vignettes/RdRW.sty =================================================================== --- trunk/R2WinBUGS/vignettes/RdRW.sty (rev 0) +++ trunk/R2WinBUGS/vignettes/RdRW.sty 2013-04-07 17:33:18 UTC (rev 262) @@ -0,0 +1,363 @@ +%%% Rd.sty ... Style for printing the R manual +%%% +%%% Modified 1998/01/05 by Fri...@ci... +%%% Modified 1998/07/07 by Martin Maechler +%%% Modified 1999/11/20 by Brian Ripley +%%% Modified 1999/12/26 by Kurt Hornik +%%% and so on. + +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{Rd}{} + +\RequirePackage{ifthen} +\newboolean{Rd@has@ae} +\newboolean{Rd@use@ae} +\newboolean{Rd@use@hyper} +\newboolean{Rd@has@times} +\newboolean{Rd@use@times} +\newboolean{Rd@use@cm-super} +\newboolean{Rd@has@lm} +\newboolean{Rd@use@lm} +\DeclareOption{ae}{\setboolean{Rd@use@ae}{true}} +\DeclareOption{hyper}{\setboolean{Rd@use@hyper}{true}} +\DeclareOption{times}{\setboolean{Rd@use@times}{true}} +\DeclareOption{lm}{\setboolean{Rd@use@lm}{true}} +\DeclareOption{cm-super}{\setboolean{Rd@use@cm-super}{true}} +\ProcessOptions +\RequirePackage{longtable} +\setcounter{LTchunksize}{250} +\ifthenelse{\boolean{Rd@use@hyper}} +{\IfFileExists{hyperref.sty}{}{\setboolean{Rd@use@hyper}{false} + \message{package hyperref not found}}} +{} + +\RequirePackage{bm} % standard boldsymbol +\RequirePackage{alltt} % {verbatim} allowing \.. +\RequirePackage{verbatim} % small example code +\RequirePackage{url} % set urls + +%% See 'upquote.sty' for details. +%% We use \pkg{verbatim} for our ExampleCode environment, which in its +%% \verbatim@font has an explicit \let\do\do@noligs\verbatim@nolig@list +%% rather than (the identical) \@noligs from the LaTeX2e kernel. +%% Hence, we add to \verbatim@font ... suggestion by Bernd Raichle +%% <ra...@In...>. +\RequirePackage{upquote} +\g@addto@macro\verbatim@font\@noligs + +%% \addtolength{\textheight}{12mm} +%% \addtolength{\topmargin}{-9mm} % still fits on US paper +%% \addtolength{\textwidth}{24mm} % still fits on US paper +%% \setlength{\oddsidemargin}{10mm} +%% \setlength{\evensidemargin}{\oddsidemargin} + +\newenvironment{display}[0]% + {\begin{list}{}{\setlength{\leftmargin}{30pt}}\item}% + {\end{list}} +\newcommand{\HTML}{{\normalfont\textsc{html}}} +\newcommand{\R}{{\normalfont\textsf{R}}{}} +\newcommand{\Rdash}{-} + +\def\href#1#2{\special{html:<a href="#1">}{#2}\special{html:</a>}} + +\newcommand{\vneed}[1]{% + \penalty-1000\vskip#1 plus 10pt minus #1\penalty-1000\vspace{-#1}} + +\newcommand{\Rdcontents}[1]{% modified \tableofcontents -- not \chapter +\section*{{#1}\@mkboth{\MakeUppercase#1}{\MakeUppercase#1}} + \@starttoc{toc}} + +\newcommand{\Header}[2]{% + \vneed{1ex} + \markboth{#1}{#1} + \noindent + \nopagebreak + \begin{center} + \ifthenelse{\boolean{Rd@use@hyper}}% + {\def\@currentHref{page.\thepage} + \hypertarget{Rfn.#1}{\index{#1@\texttt{#1}}}% + \myaddcontentsline{toc}{subsection}{#1}% + \pdfbookmark[1]{#1}{Rfn.#1}} + {\addcontentsline{toc}{subsection}{#1} + \index{#1@\texttt{#1}|textbf}} + \hrule + \parbox{0.95\textwidth}{% + \begin{ldescription}[1.5in] + \item[\texttt{#1}] \emph{#2} + \end{ldescription}} + \hrule + \end{center} + \nopagebreak} +% +% +% +% \alias{<alias>}{<header>} +\ifthenelse{\boolean{Rd@use@hyper}} +{\newcommand{\alias}[2]{\hypertarget{Rfn.#1}{\index{#1@\texttt{#1} \textit{(\texttt{#2})}}}}} +{\newcommand{\alias}[2]{\index{#1@\texttt{#1} \textit{(\texttt{#2})}}}} +\ifthenelse{\boolean{Rd@use@hyper}} +{\newcommand{\methalias}[2]{\hypertarget{Rfn.#1}{\relax}}} +{\newcommand{\methalias}[2]{}} +% \keyword{<topic>}{<header>} +\newcommand{\keyword}[2]{\index{$*$Topic{\large\ \textbf{#1}}!#2@\texttt{#2}}} +% +\newcommand{\Itemize}[1]{\begin{itemize}{#1}\end{itemize}} +\newcommand{\Enumerate}[1]{\begin{enumerate}{#1}\end{enumerate}} +\newcommand{\describe}[1]{\begin{description}{#1}\end{description}} + +\newcommand{\Tabular}[2]{% + \par\begin{longtable}{#1} + #2 + \end{longtable}} + +\newlength{\ldescriptionwidth} +\newcommand{\ldescriptionlabel}[1]{% + \settowidth{\ldescriptionwidth}{{#1}}% + \ifdim\ldescriptionwidth>\labelwidth + {\parbox[b]{\labelwidth}% + {\makebox[0pt][l]{#1}\\[1pt]\makebox{}}}% + \else + \makebox[\labelwidth][l]{{#1}}% + \fi + \hfil\relax} +\newenvironment{ldescription}[1][1in]% + {\begin{list}{}% + {\setlength{\labelwidth}{#1}% + \setlength{\leftmargin}{\labelwidth}% + \addtolength{\leftmargin}{\labelsep}% + \renewcommand{\makelabel}{\ldescriptionlabel}}}% + {\end{list}} + +\newenvironment{Rdsection}[1]{% + \ifx\@empty#1\else\subsubsection*{#1}\fi + \begin{list}{}{\setlength{\leftmargin}{0.25in}}\item} + {\end{list}} + +\newenvironment{Arguments}{% + \begin{Rdsection}{Arguments}}{\end{Rdsection}} +\newenvironment{Author}{% + \begin{Rdsection}{Author(s)}}{\end{Rdsection}} +\newenvironment{Description}{% + \begin{Rdsection}{Description}}{\end{Rdsection}} +\newenvironment{Details}{% + \begin{Rdsection}{Details}}{\end{Rdsection}} +\newenvironment{Examples}{% + \begin{Rdsection}{Examples}}{\end{Rdsection}} +\newenvironment{Note}{% + \begin{Rdsection}{Note}}{\end{Rdsection}} +\newenvironment{References}{% + \begin{Rdsection}{References}}{\end{Rdsection}} +\newenvironment{SeeAlso}{% + \begin{Rdsection}{See Also}}{\end{Rdsection}} +\newenvironment{Format}{% + \begin{Rdsection}{Format}}{\end{Rdsection}} +\newenvironment{Source}{% + \begin{Rdsection}{Source}}{\end{Rdsection}} +\newenvironment{Section}[1]{% + \begin{Rdsection}{#1}}{\end{Rdsection}} +\newenvironment{Usage}{% + \begin{Rdsection}{Usage}}{\end{Rdsection}} +\newenvironment{Value}{% + \begin{Rdsection}{Value}}{\end{Rdsection}} + +\newenvironment{ExampleCode}{\small\verbatim}{\endverbatim} + +\ifx\textbackslash\undefined%-- e.g. for MM + \newcommand{\bsl}{\ifmmode\backslash\else$\backslash$\fi} +\else + \newcommand{\bsl}{\ifmmode\backslash\else\textbackslash\fi} +\fi +%fails for index (but is not used there...) +\newcommand{\SIs}{\relax\ifmmode\leftarrow\else$\leftarrow$\fi} +\newcommand{\SIIs}{\relax\ifmmode<\leftarrow\else$<\leftarrow$\fi} +\newcommand{\Sbecomes}{\relax\ifmmode\rightarrow\else$\rightarrow$\fi} +% +\newcommand{\deqn}[2]{\[#1\]} +\newcommand{\eqn}[2]{$#1$} +\newcommand{\bold}[1]{\ifmmode\bm{#1}\else\textbf{#1}\fi} +\newcommand{\file}[1]{`\textsf{#1}'} + +\ifthenelse{\boolean{Rd@use@hyper}} +{\newcommand{\link}[1]{\hyperlink{Rfn.#1}{#1}\index{#1@\texttt{#1}}}} +{\newcommand{\link}[1]{#1\index{#1@\texttt{#1}}}} + +\newcommand{\email}[1]{$\langle${#1}$\rangle$} + +%% \code without `-' ligatures +{\catcode`\-=\active% + \global\def\code{\bgroup% + \catcode`\-=\active \let-\codedash% + \Rd@code}} +\def\codedash{-\discretionary{}{}{}} +\def\Rd@code#1{\texttt{#1}\egroup} + +\def\AsIs{\bgroup\let\do\@makeother\Rd@AsIs@dospecials\Rd@AsIsX} +\def\Rd@AsIs@dospecials{\do\$\do\&\do\#\do\^\do\_\do\%\do\~} +\def\Rd@AsIsX#1{\normalfont #1\egroup} +\let\command=\code +\let\env=\code + +\newcommand\samp{`\bgroup\@noligs\@sampx} +\def\@sampx#1{{\normalfont\texttt{#1}}\egroup'} +\let\option=\samp + +\newcommand{\var}[1]{{\normalfont\textsl{#1}}} + +\newcommand{\dfn}[1]{\textsl{#1}} +\let\Cite=\dfn + +\newcommand{\acronym}[1]{\textsc{\lowercase{#1}}} +\newcommand{\kbd}[1]{\texttt{\textsl{#1}}} + +\newcommand{\strong}[1]{{\normalfont\fontseries{b}\selectfont #1}} +\let\pkg=\strong + +\newcommand{\sQuote}[1]{`#1'} +\newcommand{\dQuote}[1]{``#1''} + +\IfFileExists{ae.sty}{\setboolean{Rd@has@ae}{true}}{} +\ifthenelse{\boolean{Rd@use@ae}\and\boolean{Rd@has@ae}}{% + \usepackage[T1]{fontenc} + \usepackage{ae} + \input{t1aett.fd} + \DeclareFontShape{T1}{aett}{bx}{n}{<->ssub*aett/m/n}{}} + {\message{NOT loading ae}} +\IfFileExists{times.sty}{\setboolean{Rd@has@times}{true}}{} +\ifthenelse{\boolean{Rd@use@times}\and\boolean{Rd@has@times}}{% + \usepackage[T1]{fontenc} + \usepackage{times}} + {\message{NOT loading times}} +\IfFileExists{lmodern.sty}{\setboolean{Rd@has@lm}{true}}{} +\ifthenelse{\boolean{Rd@use@lm}\and\boolean{Rd@has@lm}}{% + \usepackage[T1]{fontenc} + \usepackage{lmodern}} + {\message{NOT loading lmodern}} +\ifthenelse{\boolean{Rd@use@cm-super}}{% + \usepackage[T1]{fontenc}}{} + +\ifthenelse{\boolean{Rd@use@hyper}}{% + \RequirePackage{color} + \def\myaddcontentsline#1#2#3{% + \addtocontents{#1}{\protect\contentsline{#2}{#3}{\thepage}{page.\thepage}}} + \RequirePackage{hyperref} + \DeclareTextCommand{\Rpercent}{PD1}{\045} % percent + %% <NOTE> + %% Formerly in R's hyperref.cfg, possibly to be shared with Sweave.sty + %% as well (but without setting pagebackref as this can give trouble + %% for .bib entries containing URLs with '#' characters). + \definecolor{Blue}{rgb}{0,0,0.8} + \definecolor{Red}{rgb}{0.7,0,0} + \hypersetup{% + hyperindex,% + colorlinks,% + pagebackref,% + linktocpage,% + plainpages=false,% + linkcolor=Blue,% + citecolor=Blue,% + urlcolor=Red,% + pdfstartview=Fit,% + pdfview={XYZ null null null}% + } + %% </NOTE> + \renewcommand\tableofcontents{% + \if@twocolumn + \@restonecoltrue\onecolumn + \else + \@restonecolfalse + \fi + \chapter*{\contentsname + \@mkboth{% + \MakeUppercase\contentsname}{\MakeUppercase\contentsname}}% + \pdfbookmark{Contents}{contents} + \@starttoc{toc}% + \if@restonecol\twocolumn\fi + } + \renewenvironment{theindex} + {\if@twocolumn + \@restonecolfalse + \else + \@restonecoltrue + \fi + \columnseprule \z@ + \columnsep 35\p@ + \twocolumn[\@makeschapterhead{\indexname}]% + \@mkboth{\MakeUppercase\indexname}% + {\MakeUppercase\indexname}% + \pdfbookmark{Index}{index} + \myaddcontentsline{toc}{chapter}{Index} + \thispagestyle{plain}\parindent\z@ + \parskip\z@ \@plus .3\p@\relax + \raggedright + \let\item\@idxitem} + {\if@restonecol\onecolumn\else\clearpage\fi} + }{ + \renewenvironment{theindex} + {\if@twocolumn + \@restonecolfalse + \else + \@restonecoltrue + \fi + \columnseprule \z@ + \columnsep 35\p@ + \twocolumn[\@makeschapterhead{\indexname}]% + \@mkboth{\MakeUppercase\indexname}% + {\MakeUppercase\indexname}% + \addcontentsline{toc}{chapter}{Index} + \thispagestyle{plain}\parindent\z@ + \parskip\z@ \@plus .3\p@\relax + \raggedright + \let\item\@idxitem} + {\if@restonecol\onecolumn\else\clearpage\fi} + } + +% new definitions for R >= 2.0.0 +\ifthenelse{\boolean{Rd@use@hyper}} +{\newcommand{\LinkA}[2]{\hyperlink{Rfn.#2}{#1}\index{#1@\texttt{#1}|textit}}} +{\newcommand{\LinkA}[2]{#1\index{#1@\texttt{#1}|textit}}} +% +% \alias{<alias>}{<header>} +\ifthenelse{\boolean{Rd@use@hyper}} +{\newcommand{\aliasA}[3]{\hypertarget{Rfn.#3}{\index{#1@\texttt{#1} \textit{(\texttt{#2})}}}}} +{\newcommand{\aliasA}[3]{\index{#1@\texttt{#1} \textit{(\texttt{#2})}}}} +\ifthenelse{\boolean{Rd@use@hyper}} +{\newcommand{\methaliasA}[3]{\hypertarget{Rfn.#3}{\relax}}} +{\newcommand{\methaliasA}[3]{}} +\newcommand{\HeaderA}[3]{% + \vneed{1ex} + \markboth{#1}{#1} + \noindent + \nopagebreak + \begin{center} + \ifthenelse{\boolean{Rd@use@hyper}}% + {\def\@currentHref{page.\thepage} + \hypertarget{Rfn.#3}{\index{#1@\texttt{#1}}}% + \myaddcontentsline{toc}{subsection}{#1}% + \pdfbookmark[1]{#1}{Rfn.#3}} + {\addcontentsline{toc}{subsection}{#1} + \index{#1@\texttt{#1}|textbf}} + \hrule + \parbox{0.95\textwidth}{% + \begin{ldescription}[1.5in] + \item[\texttt{#1}] \emph{#2} + \end{ldescription}} + \hrule + \end{center} + \nopagebreak} +\DeclareTextCommandDefault{\Rpercent}{\%{}} +%% for use with the output of encoded_text_to_latex +\ProvideTextCommandDefault{\textdegree}{\ensuremath{{^\circ}}} +\ProvideTextCommandDefault{\textonehalf}{\ensuremath{\frac12}} +\ProvideTextCommandDefault{\textonequarter}{\ensuremath{\frac14}} +\ProvideTextCommandDefault{\textthreequarters}{\ensuremath{\frac34}} +\ProvideTextCommandDefault{\textcent}{\TextSymbolUnavailable\textcent} +\ProvideTextCommandDefault{\textyen}{\TextSymbolUnavailable\textyen} +\ProvideTextCommandDefault{\textcurrency}{\TextSymbolUnavailable\textcurrency} +\ProvideTextCommandDefault{\textbrokenbar}{\TextSymbolUnavailable\textbrokenbar} +\ProvideTextCommandDefault{\texteuro}{\TextSymbolUnavailable\texteuro} +\providecommand{\mathonesuperior}{\ensuremath{^1}} +\providecommand{\mathtwosuperior}{\ensuremath{^2}} +\providecommand{\maththreesuperior}{\ensuremath{^3}} + +\InputIfFileExists{Rd.cfg}{% + \typeout{Reading personal defaults ...}}{} Added: trunk/R2WinBUGS/vignettes/Z.cls =================================================================== --- trunk/R2WinBUGS/vignettes/Z.cls (rev 0) +++ trunk/R2WinBUGS/vignettes/Z.cls 2013-04-07 17:33:18 UTC (rev 262) @@ -0,0 +1,183 @@ +\def\fileversion{1.0} +\def\filename{Z} +\def\filedate{2004/10/08} +%% +%% Package `Z' to use with LaTeX2e for Z reports +%% Copyright (C) 2004 Achim Zeileis +%% +\NeedsTeXFormat{LaTeX2e} +\ProvidesClass{Z}[\filedate\space\fileversion\space Z class by Achim Zeileis] + +%% options +\LoadClass[10pt,a4paper,twoside]{article} +\newif\if@notitle +\@notitlefalse +\DeclareOption{notitle}{\@notitletrue} +\ProcessOptions + +%% required packages +\RequirePackage{graphicx,a4wide,color,hyperref,ae,fancyvrb,thumbpdf} +\RequirePackage[T1]{fontenc} +\usepackage[authoryear,round,longnamesfirst]{natbib} +\bibpunct{(}{)}{;}{a}{}{,} +\bibliographystyle{literatur} + +%% paragraphs +\setlength{\parskip}{0.7ex plus0.1ex minus0.1ex} +\setlength{\parindent}{0em} + +%% commands +\let\code=\texttt +\let\proglang=\textsf +\newcommand{\E}{\mathsf{E}} +\newcommand{\VAR}{\mathsf{VAR}} +\newcommand{\COV}{\mathsf{COV}} +\newcommand{\Prob}{\mathsf{P}} + +%% for all publications +\newcommand{\Plaintitle}[1]{\def\@Plaintitle{#1}} +\newcommand{\Shorttitle}[1]{\def\@Shorttitle{#1}} +\newcommand{\Plainauthor}[1]{\def\@Plainauthor{#1}} +\newcommand{\Keywords}[1]{\def\@Keywords{#1}} +\newcommand{\Plainkeywords}[1]{\def\@Plainkeywords{#1}} +\newcommand{\Abstract}[1]{\def\@Abstract{#1}} + +%% defaults +\author{Firstname Lastname\\Affiliation} +\title{Title} +\Abstract{---!!!---an abstract is required---!!!---} +\Plainauthor{\@author} +\Plaintitle{\@title} +\Shorttitle{\@title} +\Keywords{---!!!---at least one keyword is required---!!!---} +\Plainkeywords{\@Keywords} + +%% Sweave(-like) +\DefineVerbatimEnvironment{Sinput}{Verbatim}{fontshape=sl} +\DefineVerbatimEnvironment{Soutput}{Verbatim}{} +\DefineVerbatimEnvironment{Scode}{Verbatim}{fontshape=sl} +%\newenvironment{Schunk}{}{} +\DefineVerbatimEnvironment{Code}{Verbatim}{} +\DefineVerbatimEnvironment{CodeInput}{Verbatim}{fontshape=sl} +\DefineVerbatimEnvironment{CodeOutput}{Verbatim}{} +\newenvironment{CodeChunk}{}{} +\setkeys{Gin}{width=0.8\textwidth} + +%% new \maketitle +\def\maketitle{ + \begingroup + \def\thefootnote{\fnsymbol{footnote}} + \def\@makefnmark{\hbox to 0pt{$^{\@thefnmark}$\hss}} + \long\def\@makefntext##1{\parindent 1em\noindent + \hbox to1.8em{\hss $\m@th ^{\@thefnmark}$}##1} + \@maketitle \@thanks + \endgroup + \setcounter{footnote}{0} + \thispagestyle{empty} + \markboth{\centerline{\@Shorttitle}}{\centerline{\@Plainauthor}} + \pagestyle{myheadings} + + \let\maketitle\relax \let\@maketitle\relax + \gdef\@thanks{}\gdef\@author{}\gdef\@title{}\let\thanks\relax +} + +\def\@maketitle{\vbox{\hsize\textwidth \linewidth\hsize + {\centering + {\LARGE\bf \@title\par} + \def\And{\end{tabular}\hfil\linebreak[0]\hfil + \begin{tabular}[t]{c}\large\bf\rule{\z@}{24pt}\ignorespaces}% + \begin{tabular}[t]{c}\large\bf\rule{\z@}{24pt}\@author\end{tabular}% + \vskip 0.3in minus 0.1in + \hrule + \begin{abstract} + \@Abstract + \end{abstract}} + \textit{Keywords}:~\@Keywords. + \vskip 0.1in minus 0.05in + \hrule + \vskip 0.2in minus 0.1in +}} + + +%% sections, subsections, and subsubsections +\newlength{\preXLskip} +\newlength{\preLskip} +\newlength{\preMskip} +\newlength{\preSskip} +\newlength{\postMskip} +\newlength{\postSskip} +\setlength{\preXLskip}{1.8\baselineskip plus 0.5ex minus 0ex} +\setlength{\preLskip}{1.5\baselineskip plus 0.3ex minus 0ex} +\setlength{\preMskip}{1\baselineskip plus 0.2ex minus 0ex} +\setlength{\preSskip}{.8\baselineskip plus 0.2ex minus 0ex} +\setlength{\postMskip}{.5\baselineskip plus 0ex minus 0.1ex} +\setlength{\postSskip}{.3\baselineskip plus 0ex minus 0.1ex} + +\newcommand{\jsssec}[2][default]{\vskip \preXLskip% + \pdfbookmark[1]{#1}{Section.\thesection.#1}% + \refstepcounter{section}% + \centerline{\textbf{\Large \thesection. #2}} \nopagebreak + \vskip \postMskip \nopagebreak} +\newcommand{\jsssecnn}[1]{\vskip \preXLskip% + \centerline{\textbf{\Large #1}} \nopagebreak + \vskip \postMskip \nopagebreak} + +\newcommand{\jsssubsec}[2][default]{\vskip \preMskip% + \pdfbookmark[2]{#1}{Subsection.\thesubsection.#1}% + \refstepcounter{subsection}% + \textbf{\large \thesubsection. #2} \nopagebreak + \vskip \postSskip \nopagebreak} +\newcommand{\jsssubsecnn}[1]{\vskip \preMskip% + \textbf{\large #1} \nopagebreak + \vskip \postSskip \nopagebreak} + +\newcommand{\jsssubsubsec}[2][default]{\vskip \preSskip% + \pdfbookmark[3]{#1}{Subsubsection.\thesubsubsection.#1}% + \refstepcounter{subsubsection}% + {\large \textit{#2}} \nopagebreak + \vskip \postSskip \nopagebreak} +\newcommand{\jsssubsubsecnn}[1]{\vskip \preSskip% + {\textit{\large #1}} \nopagebreak + \vskip \postSskip \nopagebreak} + +\newcommand{\jsssimplesec}[2][default]{\vskip \preLskip% +%% \pdfbookmark[1]{#1}{Section.\thesection.#1}% + \refstepcounter{section}% + \textbf{\large #1} \nopagebreak + \vskip \postSskip \nopagebreak} +\newcommand{\jsssimplesecnn}[1]{\vskip \preLskip% + \textbf{\large #1} \nopagebreak + \vskip \postSskip \nopagebreak} + +\renewcommand{\section}{\secdef \jsssec \jsssecnn} +\renewcommand{\subsection}{\secdef \jsssubsec \jsssubsecnn} +\renewcommand{\subsubsection}{\secdef \jsssubsubsec \jsssubsubsecnn} + +%% colors +\definecolor{Red}{rgb}{0.7,0,0} +\definecolor{Blue}{rgb}{0,0,0.8} +\hypersetup{% + hyperindex = {true}, + colorlinks = {true}, + linktocpage = {true}, + plainpages = {false}, + linkcolor = {Blue}, + citecolor = {Blue}, + urlcolor = {Red}, + pdfstartview = {Fit}, + pdfpagemode = {UseOutlines}, + pdfview = {XYZ null null null} +} + +\AtBeginDocument{ + \hypersetup{% + pdfauthor = {\@Plainauthor}, + pdftitle = {\@Plaintitle}, + pdfkeywords = {\@Plainkeywords} + } +} +\if@notitle + %% \AtBeginDocument{\maketitle} +\else + \AtBeginDocument{\maketitle} +\fi Added: trunk/R2WinBUGS/vignettes/benzolsw.pdf =================================================================== (Binary files differ) Property changes on: trunk/R2WinBUGS/vignettes/benzolsw.pdf ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/R2WinBUGS/vignettes/bugs.tex =================================================================== --- trunk/R2WinBUGS/vignettes/bugs.tex (rev 0) +++ trunk/R2WinBUGS/vignettes/bugs.tex 2013-04-07 17:33:18 UTC (rev 262) @@ -0,0 +1,201 @@ +\HeaderA{bugs}{Run WinBUGS and OpenBUGS from R or S-PLUS}{bugs} +\keyword{interface}{bugs} +\keyword{models}{bugs} +\begin{Description}\relax +The \code{bugs} function takes data and starting values as input. +It automatically writes a WinBUGS script, calls the model, +and saves the simulations for easy access in R or S-PLUS. +\end{Description} +\begin{Usage} +\begin{verbatim} +bugs(data, inits, parameters.to.save, model.file = "model.bug", + n.chains = 3, n.iter = 2000, n.burnin = floor(n.iter/2), + n.thin = max(1, floor(n.chains * (n.iter - n.burnin)/1000)), + bin = (n.iter - n.burnin) / n.thin, + debug = FALSE, DIC = TRUE, digits = 5, codaPkg = FALSE, + bugs.directory = "c:/Program Files/WinBUGS14/", + program = c("winbugs", "openbugs", "WinBugs", "OpenBugs"), + working.directory = NULL, clearWD = FALSE, + useWINE = .Platform$OS.type != "windows", WINE = Sys.getenv("WINE"), + newWINE = FALSE, WINEPATH = NULL) +\end{verbatim} +\end{Usage} +\begin{Arguments} +\begin{ldescription} +\item[\code{data}] either a named list (names corresponding to variable names in the \code{model.file}) +of the data for the WinBUGS model, \emph{or} +a vector or list of the names of the data objects used by the model. +If \code{data = "data.txt"}, it is assumed that data have already been written to the working directory +in a file called \file{data.txt}, e.g. by the function \code{\LinkA{bugs.data}{bugs.data}}. +\item[\code{inits}] a list with \code{n.chains} elements; each element of the list is +itself a list of starting values for the WinBUGS model, \emph{or} +a function creating (possibly random) initial values. +Alternatively, if \code{inits = NULL}, initial values are generated by WinBUGS +\item[\code{parameters.to.save}] character vector of the names of the parameters to save which should be monitored +\item[\code{model.file}] file containing the model written in WinBUGS code. +The extension can be either \file{.bug} or \file{.txt}. + +If the extension is \file{.bug} and \code{program=="winbugs"}, +a copy of the file with extension \file{.txt} will be created +in the \code{bugs()} call and removed afterwards. +Note that similarly named \file{.txt} files will be overwritten. +\item[\code{n.chains}] number of Markov chains (default: 3) +\item[\code{n.iter}] number of total iterations per chain (including burn in; default: 2000) +\item[\code{n.burnin}] length of burn in, i.e. number of iterations to discard at the beginning. +Default is \code{n.iter/2}, that is, discarding the first half of the simulations. +\item[\code{n.thin}] thinning rate. Must be a positive integer. +Set \code{n.thin} > 1 to save memory and computation time if \code{n.iter} is large. +Default is \code{max(1, floor(n.chains * (n.iter-n.burnin) / 1000))} +which will only thin if there are at least 2000 simulations. +\item[\code{bin}] number of iterations between saving of results +(i.e. the coda files are saved after each \code{bin} iterations); +default is to save only at the end. +\item[\code{debug}] if \code{FALSE} (default), WinBUGS is closed automatically +when the script has finished running, otherwise WinBUGS remains open for further investigation +\item[\code{DIC}] logical; if \code{TRUE} (default), compute deviance, pD, and DIC. +This is done in WinBUGS directly using the rule \code{pD = Dbar - Dhat}. +If there are less iterations than required for the adaptive phase, +the rule \code{pD = var(deviance) / 2} is used. +\item[\code{digits}] number of significant digits used for WinBUGS input, see \code{\LinkA{formatC}{formatC}} +\item[\code{codaPkg}] logical; if \code{FALSE} (default) a \code{bugs} object is returned, +if \code{TRUE} file names of WinBUGS output are returned for easy access by the \pkg{coda} package +through function \code{\LinkA{read.bugs}{read.bugs}}. (not used if \code{program = "openbugs"}) +\item[\code{bugs.directory}] directory that contains the WinBUGS executable +\item[\code{program}] the program to use, either \code{winbugs}/\code{WinBugs} or \code{openbugs}/\code{OpenBugs}, +the latter makes use of function \code{\LinkA{openbugs}{openbugs}} and requires the CRAN package \pkg{BRugs}. +The \code{openbugs}/\code{OpenBugs} choice is not available in S-PLUS. +\item[\code{working.directory}] sets working directory during execution of this function; +WinBUGS' in- and output will be stored in this directory; +if \code{NULL}, the current working directory is chosen. +\item[\code{clearWD}] logical; indicating whether the files \file{data.txt}, +\file{inits[1:n.chains].txt}, \file{log.odc}, \file{codaIndex.txt}, and +\file{coda[1:nchains].txt} should be removed after WinBUGS has finished. +If set to \code{TRUE}, this argument is only respected if \code{codaPkg = FALSE}. + +\item[\code{useWINE}] logical; attempt to use the WINE emulator to run WinBUGS, +defaults to \code{TRUE} on Windows, and \code{FALSE} otherwise. +If WINE is used, the arguments \code{bugs.directory} and \code{working.directory} must be given in form of Linux paths +rather than Windows paths (if not \code{NULL}). +The \code{useWINE = TRUE} option is not available in S-PLUS. +\item[\code{WINE}] character; name of WINE binary file +\item[\code{newWINE}] Set this one to \code{TRUE} for new versions of WINE. +\item[\code{WINEPATH}] Path the WINE, it is tried hard to get the information automatically if not given. +\end{ldescription} +\end{Arguments} +\begin{Details}\relax +To run: +\Enumerate{ +\item Write a WinBUGS model in a ASCII file. +\item Go into R / S-PLUS. +\item Prepare the inputs to the \code{bugs} function and run it (see Example). +\item A WinBUGS window will pop up and R / S-PLUS will freeze up. The model +will now run in WinBUGS. It might take awhile. You will see +things happening in the Log window within WinBUGS. When WinBugs +is done, its window will close and R / S-PLUS will work again. +\item If an error message appears, re-run with \code{debug = TRUE}. +} +\end{Details} +\begin{Value} +If \code{codaPkg = TRUE} the returned values are the names +of coda output files written by WinBUGS containing +the Markov Chain Monte Carlo output in the CODA format. +This is useful for direct access with \code{\LinkA{read.bugs}{read.bugs}}. + +If \code{codaPkg = FALSE}, the following values are returned: +\begin{ldescription} +\item[\code{n.chains}] see Section \sQuote{Arguments} +\item[\code{n.iter}] see Section \sQuote{Arguments} +\item[\code{n.burnin}] see Section \sQuote{Arguments} +\item[\code{n.thin}] see Section \sQuote{Arguments} +\item[\code{n.keep}] number of iterations kept per chain (equal to \code{(n.iter-n.burnin) / n.thin}) +\item[\code{n.sims}] number of posterior simulations (equal to \code{n.chains * n.keep}) +\item[\code{sims.array}] 3-way array of simulation output, with dimensions +n.keep, n.chains, and length of combined parameter vector +\item[\code{sims.list}] list of simulated parameters:\\ +for each scalar parameter, a vector of length n.sims\\ +for each vector parameter, a 2-way array of simulations,\\ +for each matrix parameter, a 3-way array of simulations, etc. +(for convenience, the \code{n.keep * n.chains} simulations in +sims.matrix and sims.list (but NOT sims.array have been randomly permuted) +\item[\code{sims.matrix}] matrix of simulation output, with \code{n.chains * n.keep} rows and +one column for each element of each saved parameter +(for convenience, the \code{n.keep * n.chains} simulations in +sims.matrix and sims.list (but NOT sims.array have been randomly permuted) +\item[\code{summary}] summary statistics and convergence information for each +element of each saved parameter. +\item[\code{mean}] a list of the estimated parameter means +\item[\code{sd}] a list of the estimated parameter standard deviations +\item[\code{median}] a list of the estimated parameter medians +\item[\code{root.short}] names of argument \code{parameters.to.save} and \dQuote{deviance} +\item[\code{long.short}] indexes; programming stuff +\item[\code{dimension.short}] dimension of \code{indexes.short} +\item[\code{indexes.short}] indexes of \code{root.short} +\item[\code{last.values}] list of simulations from the most recent iteration; they +can be used as starting points if you wish to run WinBUGS for further iterations +\item[\code{pD}] an estimate of the effective number of parameters, for calculations see the section \dQuote{Arguments}. +\item[\code{DIC}] \code{mean(deviance) + pD} +\end{ldescription} +\end{Value} +\begin{Author}\relax +Andrew Gelman, \email{ge...@st...}, \url{http:/www.stat.columbia.edu/~gelman/bugsR/}; +modifications and packaged by Sibylle Sturtz, \email{st...@st...}, and Uwe Ligges. +\end{Author} +\begin{References}\relax +Gelman, A., Carlin, J.B., Stern, H.S., Rubin, D.B. (2003): +\emph{Bayesian Data Analysis}, 2nd edition, CRC Press. + +Sturtz, S., Ligges, U., Gelman, A. (2005): +R2WinBUGS: A Package for Running WinBUGS from R. +\emph{Journal of Statistical Software} 12(3), 1-16. +\end{References} +\begin{SeeAlso}\relax +\code{\LinkA{print.bugs}{print.bugs}}, \code{\LinkA{plot.bugs}{plot.bugs}}, and the \pkg{coda} package +\end{SeeAlso} +\begin{Examples} +\begin{ExampleCode} +# An example model file is given in: +model.file <- system.file(package = "R2WinBUGS", "model", "schools.txt") +# Let's take a look: +file.show(model.file) + + + + + + +# Some example data (see ?schools for details): +data(schools) +schools + +J <- nrow(schools) +y <- schools$estimate +sigma.y <- schools$sd +data <- list ("J", "y", "sigma.y") +inits <- function(){ + list(theta = rnorm(J, 0, 100), mu.theta = rnorm(1, 0, 100), + sigma.theta = runif(1, 0, 100)) +} +## or alternatively something like: +# inits <- list( +# list(theta = rnorm(J, 0, 90), mu.theta = rnorm(1, 0, 90), +# sigma.theta = runif(1, 0, 90)), +# list(theta = rnorm(J, 0, 100), mu.theta = rnorm(1, 0, 100), +# sigma.theta = runif(1, 0, 100)) +# list(theta = rnorm(J, 0, 110), mu.theta = rnorm(1, 0, 110), +# sigma.theta = runif(1, 0, 110))) + +parameters <- c("theta", "mu.theta", "sigma.theta") + +## Not run: +## You may need to edit "bugs.directory", +## also you need write access in the working directory: +schools.sim <- bugs(data, inits, parameters, model.file, + n.chains = 3, n.iter = 5000, + bugs.directory = "c:/Program Files/WinBUGS14/", + working.directory = NULL, clearWD = TRUE) +print(schools.sim) +plot(schools.sim) +## End(Not run) +\end{ExampleCode} +\end{Examples} + Added: trunk/R2WinBUGS/vignettes/countssw.pdf =================================================================== (Binary files differ) Property changes on: trunk/R2Win... [truncated message content] |
From: <li...@us...> - 2013-04-07 17:32:05
|
Revision: 261 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=261&view=rev Author: ligges Date: 2013-04-07 17:31:52 +0000 (Sun, 07 Apr 2013) Log Message: ----------- remove vignettes again! Removed Paths: ------------- trunk/R2WinBUGS/vignettes/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2013-04-07 17:27:58
|
Revision: 260 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=260&view=rev Author: ligges Date: 2013-04-07 17:27:43 +0000 (Sun, 07 Apr 2013) Log Message: ----------- ok, deleted and re-added the vignettes, perhaps svn is happy now .... Added Paths: ----------- trunk/R2WinBUGS/vignettes/ trunk/R2WinBUGS/vignettes/R2WinBUGS.Rnw trunk/R2WinBUGS/vignettes/RdRW.sty trunk/R2WinBUGS/vignettes/Z.cls trunk/R2WinBUGS/vignettes/benzolsw.pdf trunk/R2WinBUGS/vignettes/bugs.tex trunk/R2WinBUGS/vignettes/countssw.pdf trunk/R2WinBUGS/vignettes/expectedsw.pdf trunk/R2WinBUGS/vignettes/literatur.bib trunk/R2WinBUGS/vignettes/literatur.bst trunk/R2WinBUGS/vignettes/plot.pdf Added: trunk/R2WinBUGS/vignettes/R2WinBUGS.Rnw =================================================================== --- trunk/R2WinBUGS/vignettes/R2WinBUGS.Rnw (rev 0) +++ trunk/R2WinBUGS/vignettes/R2WinBUGS.Rnw 2013-04-07 17:27:43 UTC (rev 260) @@ -0,0 +1,506 @@ +%\VignetteIndexEntry{R2WinBUGS} +\documentclass{Z} +\usepackage{RdRW,thumbpdf} +\newcommand{\WinBUGS}{{\proglang{WinBUGS}}{}} +\newcommand{\RW}{{\pkg{R2WinBUGS}}{}} +\renewcommand{\R}{{\proglang{R}}{}} +\setlength{\textheight}{23.5cm} + +\title{\RW{}:\protect\linebreak A Package for Running \WinBUGS{} from \R{}} +\author{Sibylle Sturtz\thanks{\email{st...@st...}}\\Fachbereich Statistik\\Universit\"at Dortmund\\Germany + \And + Uwe Ligges\thanks{\email{li...@st...}}\\Fachbereich Statistik\\Universit\"at Dortmund\\Germany + \And + Andrew Gelman\thanks{\email{ge...@st...}}\\Department of Statistics\\Columbia University\\USA +} +\Plainauthor{Sibylle Sturtz, Uwe Ligges, Andrew Gelman} +\Plaintitle{R2WinBUGS: A Package for Running WinBUGS from R} + +\Abstract{ +The \RW{} package provides convenient functions to call \WinBUGS{} from \R{}. It +automatically writes the data and scripts in a format readable by \WinBUGS{} for processing in batch mode, which +is possible since version 1.4. After the \WinBUGS{} process has finished, it is possible either to read the +resulting data into \R{} by the package itself---which gives a compact graphical summary of inference and +convergence diagnostics---or to use the facilities of the \pkg{coda} package for further analyses of the +output. Examples are given to demonstrate the usage of this package. +} + +\Keywords{\R{}, \WinBUGS{}, interface, MCMC} +\Plainkeywords{R, WinBUGS, interface, MCMC} + +\begin{document} +An earlier version of this vignette has been published by the Journal of Statistical Software:\\ +Sturtz S, Ligges U, Gelman A (2005): +``\RW{}: A Package for Running \WinBUGS{} from \R{}.'' +{\em Journal of Statistical Software}, 12(3), 1--16. + + +\section{Introduction}\label{Introduction} +The usage of Markov chain Monte Carlo (MCMC) methods became very popular within the last decade. \WinBUGS{} +\citep[\textbf{B}ayesian inference \textbf{U}sing \textbf{G}ibbs \textbf{S}ampling, ][] +{Spiegelhalter;Thomas;Best:2003} is a popular software for analyzing complex statistical models using MCMC +methods. This software uses Gibbs sampling \citep{Geman;Geman:1984,Gelfand;Smith:1990,Casella;George:1992} and the +Metropolis algorithm \citep{Metropolis;Rosenbluth;Rosenbluth;Teller;Teller:1953} +to generate a Markov chain by sampling from full conditional +distributions. +The \WinBUGS{} software is available for free +at \url{http://www.mrc-bsu.cam.ac.uk/bugs/}. +An introduction to MCMC methods is given in \cite{Gilks;Richardson;Spiegelhalter:1996}. + +Using \WinBUGS{}, the user must specify the model to run, and to load data and initial values for a specified +number of Markov chains. Then it is possible to run the Markov chain(s) and to save the results for the parameters +the user is interested in. Summary statistics of these data, convergence diagnostics, kernel estimates +etc.\ are available as well. +Nevertheless, some users of this software might be interested in saving the output and reading it into \R{} +\citep{RCore:2004} for further analyses. +\WinBUGS{} 1.4 comes with the ability to run the software in batch mode using scripts. + +The \RW{} package makes use of this feature and provides the tools to call \WinBUGS{} +directly after data manipulation in \R{}. Furthermore, it is possible to +work with the results after importing them back into \R{} again, for example to create posterior predictive simulations or, more generally, graphical displays of data and posterior simulations \citep{gelman:2004}. +Embedding in R can also be useful for frequently changed data or processing a bunch of data sets, +because it is much more convenient to use some \R{} functions (possibly within a loop) +rather than using ``copy \& paste'' to update data in \WinBUGS{} each time; however difficulties have been encountered in this area because both \R{} and \WinBUGS{} can lock up RAM in the Windows operating system. + +\R{} is a ``language for data analysis and graphics'' and an open source and +freely available statistical software package implementing that language, see \url{http://www.R-project.org/}. +Historically, \R{} is an implementation of the award-winning \proglang{S} +language and system \citep{becker:1984r,becker:1988r,chambers:1992,chambers:1998}. +\R{} and \RW{} are available from \emph{CRAN} (Comprehensive \R{} Archive Network), +i.e., \url{http://CRAN.R-Project.org} or one of its mirrors. +\RW{} could be ported to the commercial \proglang{S} implementation +\textsc{S-Plus}. Minor adaptions would be needed since \textsc{S-Plus} +lacks some of \R{}'s functions and capabilities. +If an internet connection is available, \RW{} can be installed by typing +\verb+install.packages("R2WinBUGS")+ at the \R{} command prompt. +Do not forget to load the package with \verb+library("R2WinBUGS")+. + +The package \pkg{coda} by \cite{Plummer;Best;Cowles;Vines:2004} is very useful for the analysis of \WinBUGS{}' +output, the reader might want to install this package as well. The CRAN package \pkg{boa} (Bayesian Output +Analysis Program) by \cite{Smith:2004} has similar aims. +\proglang{JAGS} (Just Another Gibbs Sampler) +by \cite{Plummer:2003} is a program for analysis of Bayesian hierarchical models using Gibbs sampling that aims for +the same functionality as classic \proglang{BUGS}. \proglang{JAGS} is developed to work closely together with \R{} and +the \pkg{coda} package. + +%% Revision 2005-01-10 start +A new and completely revised version of WinBUGS called \proglang{OpenBUGS} \citep{Spiegelhalter;Thomas;Best;Lunn:2004} +was lately published under the terms of the GPL. +\proglang{OpenBUGS} is also expected to run under Linux. +It provides a much more flexible API on which ``BRugs'' is based including +a dynamic link library, incorporating a component loader +that allows \R{} to make use of \proglang{OpenBUGS} components. +OpenBUGS is still in development and suffers frequent crashes. +As OpenBUGS becomes more reliable, +it is planned to merge ``BRugs'' and \RW{} into one \R{} package. +%% Revision 2005-01-10 end + +For other packages and projects on spatial statistics +related to \R{}, follow the link to ``\R{} spatial projects'' at CRAN. + +In this paper, we give two examples, involving educational testing experiments in schools (cf.~Section~\ref{School}), +and incidence of childhood leukaemia depending on benzene emissions (cf.~Section~\ref{Leukaemia}). Details on the +functions of \RW{} are given in Section~\ref{Programming}. These functions automatically write the data and a +script in a format readable by \WinBUGS{} for processing in batch mode, and call \WinBUGS{} from \R{}. After the +\WinBUGS{} process has finished, it is possible either to read the resulting data into \R{} by the package itself +or to use the facilities of the \pkg{coda} package for further analyses of the output. In Section~\ref{Example2}, +we demonstrate how to apply the functions provided by \RW{} on the examples' data, and how to analyze the output +both with package \pkg{coda} and with \RW{}'s methods to \verb+plot()+ and \verb+print()+ the output. + + +\section{Examples}\label{Examples} +In this Section, we introduce two examples which will be continued in Section~\ref{Example2}. + +\subsection{Schools data}\label{School} +The Scholastic Aptitude Test (SAT) measures the aptitude of high-schoolers in order to help colleges to make +admissions decisions. It is divided into two parts, verbal (SAT-V) and mathematical (SAT-M). +Our data comes from the SAT-V (Scholastic Aptitude Test-Verbal) on eight different high schools, from an experiment conducted in the late 1970s. +SAT-V is a standard multiple choice test administered by the Educational Testing Service. +This Service was interested in the effects of coaching programs for each of the selected schools. + +The study included coached and uncoached pupils, about sixty in each of the eight different schools; see +\cite{Rubin:1981}. All of them had already taken the PSAT (Preliminary SAT) which results were used as covariates. +%Even if the test is constructed to be resistant to short-term +%efforts directed specifically toward improving test performance, each of the schools is successful at increasing +%SAT scores. +For each school, the estimated treatment effect and the standard error of the effect estimate are given. +These are calculated by an analysis of covariance adjustment appropriate for a completely randomized experiment +\citep{Rubin:1981}. This example was analyzed using a hierarchical normal model in \cite{Rubin:1981} and +\citeauthor{Gelman:2003} (\citeyear{Gelman:2003}, Section 5.5). + +\subsection{Leukaemia registration data}\label{Leukaemia} +Spatial data usually arises on different, non-nesting spatial scales. One example is childhood leukaemia +registration data analyzed by \cite{Best;Cockings;Bennett;Wakefield;Elliot:2001} +using ecologic regression. Data are given for Greater London bounded by the M25 orbital motorway. +%% Revision 2005-01-10 start +The data are not available as an example in \RW{} but we use the example here +to illustrate +alternative calls to the \verb+bugs()+ function and output analysis using the \pkg{coda} package. +%% Revision 2005-01-10 end + +The observed number of leukaemia cases among children under 15 years old is given at ward level. Census wards are +administrative areas containing approximately 5000 to 10\,000 people. Central London is divided into 873 wards. The +number of incident cases of leukaemia in children is available from 1985 until 1996 from the Office of National +Statistics and the Thames Cancer Registry. A plot of these numbers is given in Figure~\ref{observed}. + +\begin{figure} +\begin{center} +\includegraphics[width=0.85\textwidth]{countssw} +\caption{\label{observed}Observed number of cases of childhood leukaemia in 1985--1996} +\end{center} +\end{figure} + +Additionally, the number of expected cases (cf.~Fig.~\ref{expected}) is calculated on the same +resolution using population numbers for different age-sex-strata and the national leukaemia +rate for the corresponding strata, for details see \cite{Best;Cockings;Bennett;Wakefield;Elliot:2001}. + +\begin{figure} +\begin{center} +\includegraphics[width=0.85\textwidth]{expectedsw} +\caption{\label{expected}Expected number of cases of childhood leukaemia in 1985--1996}%, as obtained from a simple demographic model} +\end{center} +\end{figure} + +It is assumed that benzene emissions have an effect on the incidence rate of leukaemia. Benzene emission rates are +available in tonnes per year from an atmospheric emissions inventory for London +\citep{Buckingham;Clewley;Hutchinson;Sadler;Shah:1997} produced by the London Research Centre. They are provided +at 1km $\times$ 1km grid cells, giving 2132 grid cells in total. +Their spatial distribution is shown in Figure~\ref{benzene}. + +\begin{figure} +\begin{center} +\includegraphics[width=0.9\textwidth]{benzolsw} +\caption{\label{benzene}Benzene emissions in tonnes per year} +\end{center} +\end{figure} + +For further details on the data see \cite{Best;Cockings;Bennett;Wakefield;Elliot:2001}. + +We model these data by Poisson-Gamma models introduced by \cite{Best;Ickstadt;Wolpert:2000} using \WinBUGS{}. +A linking matrix containing information which grid cell belongs to which ward +and to which amount is required. This matrix is calculated using \R{}. +Unfortunately, \WinBUGS{} does not support a list format such as directly produced by \R{}. +Therefore, the data must be provided as a matrix with 2132 rows and 873 columns (or vice versa). +Most of the entries of this matrix are zeroes, but using \verb+dump()+ to export it from \R{} +yields in a file size of 14.2~MB. +Unfortunately, opening a file of such size really slows \WinBUGS{} down, +and it was not even possible on some of our PCs. +Importing data written by our \RW{} package does not make any problems using the batch mode, +probably due to memory management issues in \WinBUGS{}. + + +\section{Implementation}\label{Programming} +The implementation of the \RW{} package is straightforward. +The ``main'' function \verb+bugs()+ is intended to be called by the user. +In principle, it is a wrapper for several other functions called therein step by step as follows: +\begin{enumerate} + \item \verb+bugs.data.inits()+ writes the data files \file{data.txt}, and \file{inits1.txt}, \file{inits2.txt}, ... + into the working directory. These files will be used by \WinBUGS{} during batch processing. + + In particular, input for \WinBUGS{} must not exceed a certain number of digits. + Moreover, it needs an \verb+E+ instead of an \verb+e+ in scientific notation. + Scientific notation is particularly desirable because of the ``number of digits'' limitation. + The default (\verb+digits = 5+) is to, e.g., reformat the number \verb+123456.789+ to \verb@1.23457E+05@. + \item \verb+bugs.script()+ writes the file \file{script.txt} that is used by \WinBUGS{} for batch processing. + \item \verb+bugs.run()+ updates the lengths of the adaptive phases in the \WinBUGS{} registry + (using a function \verb+bugs.update.settings()+), + calls \WinBUGS{}, and runs it in batch mode with \file{script.txt}. + \item \verb+bugs.sims()+ is only called if the argument \verb+codaPkg+ has been set to \verb+FALSE+ (the default). + Otherwise \verb+bugs()+ returns the filenames of stored data. These can, for example, + be imported by package \pkg{coda} (see the example in Section~\ref{Leukaemia2}, page~\pageref{codaexample}), + which provides functions for convergence diagnostics, + calculation of Monte Carlo estimates, trace plots, and so forth. + + The function \verb+bugs.sims()+ reads simulations from \WinBUGS{} into \R{} (not necessarily called by \verb+bugs()+ + itself), formats them, + monitors convergence, performs convergence checks, and computes medians and quantiles. + It also prepares the output for \verb+bugs()+ itself. +\end{enumerate} +These functions are not intended to be called by the user directly. +Arguments are passed from \verb+bugs()+ to the other functions, if appropriate. +A shortened help file of \verb+bugs()+ listing all arguments is given in Appendix~\ref{Doc}; +for the full version type \verb+?bugs+ in \R{} after having installed and loaded the package \RW{} +(see Section~\ref{Introduction}). + +%\newpage +As known from \WinBUGS{}, one must specify the \verb+data+ in form of a list, with list names equal to the names +of data in the corresponding \WinBUGS{} model. Alternatively, it is possible to specify a vector or list of names +(of mode \verb+character+). In that case objects of that names are looked for in the environment in which +\verb+bugs()+ has been called (usually that is the user's Workspace, \verb+.GlobalEnv+). +%% Revision 2005-01-10 start +If data have already been written in a file called \file{data.txt} to the working directory, +it is possible to specify \verb+data = "data.txt"+. +%% Revision 2005-01-10 end +One will usually want to supply initial values. +This can be done either in the form of a function \verb+inits()+ that creates these values, so that +different chains can be automatically initialized at different points (see Section \ref{School2}), or by specifying them +directly (see Section \ref{Leukaemia2}). +If \verb+inits()+ is not specified, +\verb+bugs()+ just uses the starting values created by \WinBUGS{}; but in practice \WinBUGS{} can crash when +reasonable initial values are not specified, and so we recommend constructing a simple \verb+inits()+ function to +simulate reasonable starting points \cite[Section C.2]{Gelman:2003}. It is also necessary to specify which +parameters should be saved for monitoring by specifying \verb+parameters.to.save+. + +The user might also want to change the defaults for the length of the burn-in (\verb+n.burnin+, which defaults to half the length of the chain) +period for every MCMC run and the number of iterations (\verb+n.iter+, default value 3) +that are used to calculate Monte Carlo estimates. +%SS: Achtung: n.iter=n.burn.in + length of stored chain! +The specification of a thinning parameter (\verb+n.thin+) is possible as well; this is useful when the number of parameters is large, to keep the saved output to a reasonably-sized R object. In the default setting, the chains are thinned enough so that approximately 1000 simulation draws are saved. + +By setting the argument \verb+debug = TRUE+, +\WinBUGS{} remains open after the run. +This way it is possible to find errors in the code or the data structure, +or even to work with that software as in a usual run. + +It is possible to run one or more Markov chains. +The number of chains (\verb+n.chains+) must be specified together with the chains' initial values (\verb+inits+). +If more than one Markov chain is requested and \verb+codaPkg+ is set to \verb+FALSE+, the convergence diagnostic +$\hat{R}$ \citep{Brooks;Gelman:1998} is calculated by \verb+bugs.sims()+ for each of the saved parameters. + +%% Revision 2005-01-10 start +Since the communication between \WinBUGS{} and \R{} is based on files, +rather huge files will be saved in the working directory by the \verb+bugs()+ call, +either files to be read in by \verb+bugs()+ itself, or by the \pkg{coda} package. +The user might want to delete those files after the desired contents has been imported into \R{}, +and save those objects, e.g., as compressed \R{} data files. +%% Revision 2005-01-10 end + +The function \verb+bugs()+ returns a rather complex object of class \verb+bugs+, +if called with argument \verb+codaPkg = FALSE+. +In order to look at the structure of such an object, type \verb+str(objectname)+. +For convenience, \RW{} provides methods corresponding to class \verb+bugs+ for +the generic functions \verb+print()+ and \verb+plot()+. + +So that user will not be overwhelmed with information; summaries of the output are provided by the +\verb+print()+ method. That is, some parameters of the \verb+bugs()+ call are summarized, and mean, +standard deviation, several quantiles of the parameters and convergence diagnostics based on \cite{Gelman;Rubin:1992} +are printed. See the example in +Section~\ref{School2}, page~\pageref{schoolssim}, for a typical output. As with \cite{Spiegelhalter;Best;Carlin;vdLinde:2002}, +%\pagebreak + the DIC computed by \verb+bugs.sims()+ is defined as the posterior mean +of the deviance plus $p_D$, the estimated effective number of parameters in the posterior distribution. We define +$p_D$ as half the posterior variance of the deviance and estimate it as half the average of the within-chain +variances of the deviance.\footnote{In contrast, \cite{Spiegelhalter;Best;Carlin;vdLinde:2002}, + and WinBUGS, define $p_D$ as the +posterior mean of the deviance evaluated at the posterior mean of the parameter values. We cannot use that +definition because the deviance function is not available to our program, which calls \WinBUGS{} from the +``outside''. Both definitions of $p_D$---ours and that introduced by \cite{Spiegelhalter;Best;Carlin;vdLinde:2002}---can be +derived from the asymptotic $\chi^2$ distribution of the deviance relative to its minimum \citep[Section 6.7]{Gelman:2003}. +We make no claim that our measure of $p_D$ is superior to that of \cite{Spiegelhalter;Best;Carlin;vdLinde:2002}; +we choose this measure purely because it is computationally possible given what is available to us from the \WinBUGS{} output.} + + +The \verb+plot()+ for objects of class \verb+bugs+ +provides information condensed in some plots conveniently arranged within the same graphics device. +For an example, see Figure~\ref{plot} in Section~\ref{School2}. It is intended to adapt this function to work with MCMC output in general, even if obtained from software other than WinBUGS. + + + +\section{Examples continued}\label{Example2} +The Examples introduced in Section~\ref{Example2} are continued in this Section. +We apply the functions provided by \RW{} +to the examples' data and analyze the output. + +\subsection{Schools data}\label{School2} +Schools example data (see Section~\ref{School}) are available with the \RW{} package: +\begin{Code} + > data(schools) + > schools + school estimate sd + 1 A 28.39 14.9 + 2 B 7.94 10.2 + 3 C -2.75 16.3 + 4 D 6.82 11.0 + 5 E -0.64 9.4 + 6 F 0.63 11.4 + 7 G 18.01 10.4 + 8 H 12.16 17.6 +\end{Code} +For modeling these data, we use a hierarchical model as proposed by \citeauthor{Gelman:2003} (\citeyear{Gelman:2003}, Section 5.5). +We assume a normal distribution for the observed estimate for each school with +mean \verb+theta+ and inverse-variance \verb+tau.y+. +The inverse-variance is given as $1/\verb+sigma.y+^{2}$ and its prior distribution is uniform on (0,1000). For the mean +\verb+theta+, we employ another normal distribution with mean \verb+mu.theta+ and inverse-variance \verb+tau.theta+. For +their prior distributions, see the following \WinBUGS{} code: + + +\begin{Code} + model { + for (j in 1:J) + { + y[j] ~ dnorm (theta[j], tau.y[j]) + theta[j] ~ dnorm (mu.theta, tau.theta) + tau.y[j] <- pow(sigma.y[j], -2) + } + mu.theta ~ dnorm (0.0, 1.0E-6) + tau.theta <- pow(sigma.theta, -2) + sigma.theta ~ dunif (0, 1000) + } +\end{Code} +This model must be stored in a separate file, e.g.~\file{schools.bug}\footnote{Emacs Speaks Statistics (ESS) +by \cite{rossini04}, a package available with Gnu Emacs \citep{stallmann99}, +recognizes and properly formats Bugs model files that have the .bug extension.}, +in an appropriate directory, say \path{c:/schools/}. +In \R{} the user must prepare the data inputs the \verb+bugs()+ function needs. +This can be a list containing the name of each data vector, e.g. +\begin{Code} + > J <- nrow(schools) + > y <- schools$estimate + > sigma.y <- schools$sd + > data <- list ("J", "y", "sigma.y") +\end{Code} +Using these data and the model file, we can run an MCMC simulation to get estimates for \verb+theta+, +\verb+mu.theta+ and \verb+sigma.theta+. Before running, the user must decide how many chains to be run +(\verb+n.chain = 3+) for how many iterations (\verb+n.iter = 1000+). +If the length of burn-in is not specified, \verb+n.burnin = floor(n.iter/2)+ is used, that is, 500 in this example. +Additionally, the user must specify initial values for the chains, for example by writing a function. This can be done by +\begin{Code} + > inits <- function(){ + + list(theta = rnorm(J, 0, 100), mu.theta = rnorm(1, 0, 100), + + sigma.theta = runif(1, 0, 100)) + + } +\end{Code} +Now, the user can start the MCMC simulation by typing +\begin{Code} + > schools.sim <- bugs(data, inits, model.file = "c:/schools/schools.bug", + + parameters = c("theta", "mu.theta", "sigma.theta"), + + n.chains = 3, n.iter = 1000, + + bugs.directory = "c:/Program Files/WinBUGS14/") +\end{Code} +in \R{}.\label{schoolssim} The argument \verb+bugs.directory+ must point to the directory +where \WinBUGS{} has been installed. +For other available arguments, see Appendix \ref{Doc}. + +The results in objects \verb+schools.sim+ can conveniently be printed by \verb+print(schools.sim)+. +The generic function \verb+print()+ calls the print method for an object of class \verb+bugs+ +provided by \RW{}. +For this example, you will get something like + +\small +\begin{Code} + > print(schools.sim) + Inference for Bugs model at "c:/schools/schools.bug" + 3 chains, each with 1000 iterations (first 500 discarded) + n.sims = 1500 iterations saved + mean sd 2.5% 25% 50% 75% 97.5% Rhat n.eff + theta[1] 11.1 9.1 -3.0 5.0 10.0 16.0 31.8 1.1 39 + theta[2] 7.6 6.6 -4.7 3.3 7.8 11.6 21.1 1.1 42 + theta[3] 5.7 8.4 -12.5 0.6 6.1 10.8 21.8 1.0 150 + theta[4] 7.1 7.0 -6.6 2.7 7.2 11.5 21.0 1.1 42 + theta[5] 5.1 6.8 -9.5 0.7 5.2 9.7 18.1 1.0 83 + theta[6] 5.7 7.3 -9.7 1.0 6.2 10.2 20.0 1.0 56 + theta[7] 10.4 7.3 -2.1 5.3 9.8 15.3 25.5 1.1 27 + theta[8] 8.3 8.4 -6.6 2.8 8.1 12.7 26.2 1.0 64 + mu.theta 7.6 5.9 -3.0 3.7 8.0 11.0 19.5 1.1 35 + sigma.theta 6.7 5.6 0.3 2.8 5.1 9.2 21.2 1.1 46 + deviance 60.8 2.5 57.0 59.1 60.2 62.1 66.6 1.0 170 + pD = 3 and DIC = 63.8 (using the rule, pD = var(deviance)/2) + + For each parameter, n.eff is a crude measure of effective sample size, + and Rhat is the potential scale reduction factor (at convergence, Rhat=1). + DIC is an estimate of expected predictive error (lower deviance is better). +\end{Code} +\normalsize +Additionally, the user can generate a plot of the results by typing \verb+plot(schools.sim)+. +The resulting plot is given in Figure~\ref{plot}. +\begin{figure}[t] +\begin{center} +\fbox{ +\includegraphics[width=0.9\textwidth]{plot} +} \caption{\label{plot}Plot produced by \RW{} package for the schools example. } +\end{center} +\end{figure} +In this plot, the left column shows a quick +summary of inference and convergence ($\widehat{R}$ is close to 1.0 for all parameters, indicating good mixing of +the three chains and thus approximate convergence); and the right column shows inferences for each set of +parameters. As can be seen in the right column, \RW{} uses the parameter names in \WinBUGS{} to structure the +output into scalar, vector, and arrays of parameters, in addition to storing the parameters as a long vector. + +For the interpretation of these results see \citeauthor{Gelman:2003} (\citeyear{Gelman:2003}, Section 5.5). + +\subsection{Leukaemia registration data}\label{Leukaemia2} +The leukaemia registration data (see Section \ref{Leukaemia}) are used to show data modeling and output reading +into \R{} using the \pkg{coda} package. A simple model for these data looks as follows: +\begin{Code} +model{ + beta.0 ~ dgamma(a.0, tau.0) + beta.benz ~ dgamma(a.benz, tau.benz) + a.0 <- 0.575 + tau.0 <- a.0*2 + a.benz <- 0.575 + tau.benz <- a.benz*2 +\end{Code} +\clearpage +\begin{Code} + for (i in 1:I) + { + count[i] ~ dpois(lambda[i]) + lambda[i] <- p[i]*expect[i] + for (j in 1:J) + { + prop[j,i] <- gamma[j,i]*(benz[j] - benzbar) + } + p[i]<- beta.0 + beta.benz*sum(prop[,i]) + } + } +\end{Code} +Here \verb+count+ denotes the number of observed incidences of childhood leukaemia in ward~\verb+i+. These are +assumed to be Poisson distributed with mean \verb+lambda+ depending on the number of expected cases \verb+expect+ +in ward \verb+i+ and an area-specific risk rate \verb+p+. For calculation of this area specific risk rate we use +an intercept \verb+beta.0+ and a term depending on the weighted sum of benzene emissions \verb+benz+ in each grid +cell \verb+j+. The weights are chosen proportional to the amount of area that ward \verb+i+ and grid cell \verb+j+ have +in common. + +In \R{} we can define all these data and then initialize the model. The data needed for this example are +\begin{description} +\item[\tt{benzbar}:] arithmetic mean of all benzene values, +\item[\tt{benz}:] a vector containing benzene emissions of all 2132 grid cells, +\item[\tt{expect}:] expected number of cases of childhood leukaemia in each of the 873 wards, +\item[\tt{count}:] observed number of childhood leukaemia in these wards, +\item[\tt{gamma}:] a $2132\times 873$ matrix containing the amount of area each grid cell and each ward have in common, +\item[\tt{J}:] total number of grid cells, i.e.~2132, and +\item[\tt{I}:] total number of ward cells, i.e.~873. +\end{description} +The parameters we want to store are regression coefficients \verb+beta.0+ and \verb+beta.benz+ as well as +\verb+p+, the area specific relative risk compared to the reference rate. This reference rate was used to +calculate the expected number of cases in each ward. + +Since we want to use the \pkg{coda} package for reading the data into \WinBUGS{}, we specify \verb+codaPkg = TRUE+ +in the \verb+bugs()+ call: +\begin{Code} + > data <- list(benzbar = mean(benz), benz = benz, expect = expect, + + count = count, gamma = gamma, J = J, I = I) + > parameters <- c("beta.0", "beta.benz", "p") + > inits1 <- list(beta.0 = 1, beta.benz = 1) + > inits2 <- list(beta.0 = 0.5, beta.benz = 0.5) + > inits <- list(inits1, inits2) + > model <- bugs(data, inits, parameters, model.file = "c:/model.bug", + + n.chains = 2, n.iter = 8000, n.burnin = 5000, n.thin = 1, + + codaPkg = TRUE, bugs.directory = "c:/Program Files/WinBUGS14/") +\end{Code} + +\clearpage +Starting with, e.g.,\label{codaexample} +\begin{Code} + > library("coda") + > codaobject <- read.bugs(model) + > plot(codaobject) +\end{Code} +it is now possible to use the \pkg{coda} package for output analyses. + + +\section*{Acknowledgments} +The work of Uwe Ligges has been supported by the Deutsche Forschungsgemeinschaft, +Sonderforschungsbereich 475. +The work of Andrew Gelman has been supported by the U.S. National Science Foundation. + +\bibliography{literatur} + +\clearpage +\begin{appendix} +\section[Help page for the function bugs()]{Help page for the function \code{bugs()}\label{Doc}} +\small +This help page has been shortened. +\input{bugs} +\end{appendix} +\end{document} Added: trunk/R2WinBUGS/vignettes/RdRW.sty =================================================================== --- trunk/R2WinBUGS/vignettes/RdRW.sty (rev 0) +++ trunk/R2WinBUGS/vignettes/RdRW.sty 2013-04-07 17:27:43 UTC (rev 260) @@ -0,0 +1,363 @@ +%%% Rd.sty ... Style for printing the R manual +%%% +%%% Modified 1998/01/05 by Fri...@ci... +%%% Modified 1998/07/07 by Martin Maechler +%%% Modified 1999/11/20 by Brian Ripley +%%% Modified 1999/12/26 by Kurt Hornik +%%% and so on. + +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{Rd}{} + +\RequirePackage{ifthen} +\newboolean{Rd@has@ae} +\newboolean{Rd@use@ae} +\newboolean{Rd@use@hyper} +\newboolean{Rd@has@times} +\newboolean{Rd@use@times} +\newboolean{Rd@use@cm-super} +\newboolean{Rd@has@lm} +\newboolean{Rd@use@lm} +\DeclareOption{ae}{\setboolean{Rd@use@ae}{true}} +\DeclareOption{hyper}{\setboolean{Rd@use@hyper}{true}} +\DeclareOption{times}{\setboolean{Rd@use@times}{true}} +\DeclareOption{lm}{\setboolean{Rd@use@lm}{true}} +\DeclareOption{cm-super}{\setboolean{Rd@use@cm-super}{true}} +\ProcessOptions +\RequirePackage{longtable} +\setcounter{LTchunksize}{250} +\ifthenelse{\boolean{Rd@use@hyper}} +{\IfFileExists{hyperref.sty}{}{\setboolean{Rd@use@hyper}{false} + \message{package hyperref not found}}} +{} + +\RequirePackage{bm} % standard boldsymbol +\RequirePackage{alltt} % {verbatim} allowing \.. +\RequirePackage{verbatim} % small example code +\RequirePackage{url} % set urls + +%% See 'upquote.sty' for details. +%% We use \pkg{verbatim} for our ExampleCode environment, which in its +%% \verbatim@font has an explicit \let\do\do@noligs\verbatim@nolig@list +%% rather than (the identical) \@noligs from the LaTeX2e kernel. +%% Hence, we add to \verbatim@font ... suggestion by Bernd Raichle +%% <ra...@In...>. +\RequirePackage{upquote} +\g@addto@macro\verbatim@font\@noligs + +%% \addtolength{\textheight}{12mm} +%% \addtolength{\topmargin}{-9mm} % still fits on US paper +%% \addtolength{\textwidth}{24mm} % still fits on US paper +%% \setlength{\oddsidemargin}{10mm} +%% \setlength{\evensidemargin}{\oddsidemargin} + +\newenvironment{display}[0]% + {\begin{list}{}{\setlength{\leftmargin}{30pt}}\item}% + {\end{list}} +\newcommand{\HTML}{{\normalfont\textsc{html}}} +\newcommand{\R}{{\normalfont\textsf{R}}{}} +\newcommand{\Rdash}{-} + +\def\href#1#2{\special{html:<a href="#1">}{#2}\special{html:</a>}} + +\newcommand{\vneed}[1]{% + \penalty-1000\vskip#1 plus 10pt minus #1\penalty-1000\vspace{-#1}} + +\newcommand{\Rdcontents}[1]{% modified \tableofcontents -- not \chapter +\section*{{#1}\@mkboth{\MakeUppercase#1}{\MakeUppercase#1}} + \@starttoc{toc}} + +\newcommand{\Header}[2]{% + \vneed{1ex} + \markboth{#1}{#1} + \noindent + \nopagebreak + \begin{center} + \ifthenelse{\boolean{Rd@use@hyper}}% + {\def\@currentHref{page.\thepage} + \hypertarget{Rfn.#1}{\index{#1@\texttt{#1}}}% + \myaddcontentsline{toc}{subsection}{#1}% + \pdfbookmark[1]{#1}{Rfn.#1}} + {\addcontentsline{toc}{subsection}{#1} + \index{#1@\texttt{#1}|textbf}} + \hrule + \parbox{0.95\textwidth}{% + \begin{ldescription}[1.5in] + \item[\texttt{#1}] \emph{#2} + \end{ldescription}} + \hrule + \end{center} + \nopagebreak} +% +% +% +% \alias{<alias>}{<header>} +\ifthenelse{\boolean{Rd@use@hyper}} +{\newcommand{\alias}[2]{\hypertarget{Rfn.#1}{\index{#1@\texttt{#1} \textit{(\texttt{#2})}}}}} +{\newcommand{\alias}[2]{\index{#1@\texttt{#1} \textit{(\texttt{#2})}}}} +\ifthenelse{\boolean{Rd@use@hyper}} +{\newcommand{\methalias}[2]{\hypertarget{Rfn.#1}{\relax}}} +{\newcommand{\methalias}[2]{}} +% \keyword{<topic>}{<header>} +\newcommand{\keyword}[2]{\index{$*$Topic{\large\ \textbf{#1}}!#2@\texttt{#2}}} +% +\newcommand{\Itemize}[1]{\begin{itemize}{#1}\end{itemize}} +\newcommand{\Enumerate}[1]{\begin{enumerate}{#1}\end{enumerate}} +\newcommand{\describe}[1]{\begin{description}{#1}\end{description}} + +\newcommand{\Tabular}[2]{% + \par\begin{longtable}{#1} + #2 + \end{longtable}} + +\newlength{\ldescriptionwidth} +\newcommand{\ldescriptionlabel}[1]{% + \settowidth{\ldescriptionwidth}{{#1}}% + \ifdim\ldescriptionwidth>\labelwidth + {\parbox[b]{\labelwidth}% + {\makebox[0pt][l]{#1}\\[1pt]\makebox{}}}% + \else + \makebox[\labelwidth][l]{{#1}}% + \fi + \hfil\relax} +\newenvironment{ldescription}[1][1in]% + {\begin{list}{}% + {\setlength{\labelwidth}{#1}% + \setlength{\leftmargin}{\labelwidth}% + \addtolength{\leftmargin}{\labelsep}% + \renewcommand{\makelabel}{\ldescriptionlabel}}}% + {\end{list}} + +\newenvironment{Rdsection}[1]{% + \ifx\@empty#1\else\subsubsection*{#1}\fi + \begin{list}{}{\setlength{\leftmargin}{0.25in}}\item} + {\end{list}} + +\newenvironment{Arguments}{% + \begin{Rdsection}{Arguments}}{\end{Rdsection}} +\newenvironment{Author}{% + \begin{Rdsection}{Author(s)}}{\end{Rdsection}} +\newenvironment{Description}{% + \begin{Rdsection}{Description}}{\end{Rdsection}} +\newenvironment{Details}{% + \begin{Rdsection}{Details}}{\end{Rdsection}} +\newenvironment{Examples}{% + \begin{Rdsection}{Examples}}{\end{Rdsection}} +\newenvironment{Note}{% + \begin{Rdsection}{Note}}{\end{Rdsection}} +\newenvironment{References}{% + \begin{Rdsection}{References}}{\end{Rdsection}} +\newenvironment{SeeAlso}{% + \begin{Rdsection}{See Also}}{\end{Rdsection}} +\newenvironment{Format}{% + \begin{Rdsection}{Format}}{\end{Rdsection}} +\newenvironment{Source}{% + \begin{Rdsection}{Source}}{\end{Rdsection}} +\newenvironment{Section}[1]{% + \begin{Rdsection}{#1}}{\end{Rdsection}} +\newenvironment{Usage}{% + \begin{Rdsection}{Usage}}{\end{Rdsection}} +\newenvironment{Value}{% + \begin{Rdsection}{Value}}{\end{Rdsection}} + +\newenvironment{ExampleCode}{\small\verbatim}{\endverbatim} + +\ifx\textbackslash\undefined%-- e.g. for MM + \newcommand{\bsl}{\ifmmode\backslash\else$\backslash$\fi} +\else + \newcommand{\bsl}{\ifmmode\backslash\else\textbackslash\fi} +\fi +%fails for index (but is not used there...) +\newcommand{\SIs}{\relax\ifmmode\leftarrow\else$\leftarrow$\fi} +\newcommand{\SIIs}{\relax\ifmmode<\leftarrow\else$<\leftarrow$\fi} +\newcommand{\Sbecomes}{\relax\ifmmode\rightarrow\else$\rightarrow$\fi} +% +\newcommand{\deqn}[2]{\[#1\]} +\newcommand{\eqn}[2]{$#1$} +\newcommand{\bold}[1]{\ifmmode\bm{#1}\else\textbf{#1}\fi} +\newcommand{\file}[1]{`\textsf{#1}'} + +\ifthenelse{\boolean{Rd@use@hyper}} +{\newcommand{\link}[1]{\hyperlink{Rfn.#1}{#1}\index{#1@\texttt{#1}}}} +{\newcommand{\link}[1]{#1\index{#1@\texttt{#1}}}} + +\newcommand{\email}[1]{$\langle${#1}$\rangle$} + +%% \code without `-' ligatures +{\catcode`\-=\active% + \global\def\code{\bgroup% + \catcode`\-=\active \let-\codedash% + \Rd@code}} +\def\codedash{-\discretionary{}{}{}} +\def\Rd@code#1{\texttt{#1}\egroup} + +\def\AsIs{\bgroup\let\do\@makeother\Rd@AsIs@dospecials\Rd@AsIsX} +\def\Rd@AsIs@dospecials{\do\$\do\&\do\#\do\^\do\_\do\%\do\~} +\def\Rd@AsIsX#1{\normalfont #1\egroup} +\let\command=\code +\let\env=\code + +\newcommand\samp{`\bgroup\@noligs\@sampx} +\def\@sampx#1{{\normalfont\texttt{#1}}\egroup'} +\let\option=\samp + +\newcommand{\var}[1]{{\normalfont\textsl{#1}}} + +\newcommand{\dfn}[1]{\textsl{#1}} +\let\Cite=\dfn + +\newcommand{\acronym}[1]{\textsc{\lowercase{#1}}} +\newcommand{\kbd}[1]{\texttt{\textsl{#1}}} + +\newcommand{\strong}[1]{{\normalfont\fontseries{b}\selectfont #1}} +\let\pkg=\strong + +\newcommand{\sQuote}[1]{`#1'} +\newcommand{\dQuote}[1]{``#1''} + +\IfFileExists{ae.sty}{\setboolean{Rd@has@ae}{true}}{} +\ifthenelse{\boolean{Rd@use@ae}\and\boolean{Rd@has@ae}}{% + \usepackage[T1]{fontenc} + \usepackage{ae} + \input{t1aett.fd} + \DeclareFontShape{T1}{aett}{bx}{n}{<->ssub*aett/m/n}{}} + {\message{NOT loading ae}} +\IfFileExists{times.sty}{\setboolean{Rd@has@times}{true}}{} +\ifthenelse{\boolean{Rd@use@times}\and\boolean{Rd@has@times}}{% + \usepackage[T1]{fontenc} + \usepackage{times}} + {\message{NOT loading times}} +\IfFileExists{lmodern.sty}{\setboolean{Rd@has@lm}{true}}{} +\ifthenelse{\boolean{Rd@use@lm}\and\boolean{Rd@has@lm}}{% + \usepackage[T1]{fontenc} + \usepackage{lmodern}} + {\message{NOT loading lmodern}} +\ifthenelse{\boolean{Rd@use@cm-super}}{% + \usepackage[T1]{fontenc}}{} + +\ifthenelse{\boolean{Rd@use@hyper}}{% + \RequirePackage{color} + \def\myaddcontentsline#1#2#3{% + \addtocontents{#1}{\protect\contentsline{#2}{#3}{\thepage}{page.\thepage}}} + \RequirePackage{hyperref} + \DeclareTextCommand{\Rpercent}{PD1}{\045} % percent + %% <NOTE> + %% Formerly in R's hyperref.cfg, possibly to be shared with Sweave.sty + %% as well (but without setting pagebackref as this can give trouble + %% for .bib entries containing URLs with '#' characters). + \definecolor{Blue}{rgb}{0,0,0.8} + \definecolor{Red}{rgb}{0.7,0,0} + \hypersetup{% + hyperindex,% + colorlinks,% + pagebackref,% + linktocpage,% + plainpages=false,% + linkcolor=Blue,% + citecolor=Blue,% + urlcolor=Red,% + pdfstartview=Fit,% + pdfview={XYZ null null null}% + } + %% </NOTE> + \renewcommand\tableofcontents{% + \if@twocolumn + \@restonecoltrue\onecolumn + \else + \@restonecolfalse + \fi + \chapter*{\contentsname + \@mkboth{% + \MakeUppercase\contentsname}{\MakeUppercase\contentsname}}% + \pdfbookmark{Contents}{contents} + \@starttoc{toc}% + \if@restonecol\twocolumn\fi + } + \renewenvironment{theindex} + {\if@twocolumn + \@restonecolfalse + \else + \@restonecoltrue + \fi + \columnseprule \z@ + \columnsep 35\p@ + \twocolumn[\@makeschapterhead{\indexname}]% + \@mkboth{\MakeUppercase\indexname}% + {\MakeUppercase\indexname}% + \pdfbookmark{Index}{index} + \myaddcontentsline{toc}{chapter}{Index} + \thispagestyle{plain}\parindent\z@ + \parskip\z@ \@plus .3\p@\relax + \raggedright + \let\item\@idxitem} + {\if@restonecol\onecolumn\else\clearpage\fi} + }{ + \renewenvironment{theindex} + {\if@twocolumn + \@restonecolfalse + \else + \@restonecoltrue + \fi + \columnseprule \z@ + \columnsep 35\p@ + \twocolumn[\@makeschapterhead{\indexname}]% + \@mkboth{\MakeUppercase\indexname}% + {\MakeUppercase\indexname}% + \addcontentsline{toc}{chapter}{Index} + \thispagestyle{plain}\parindent\z@ + \parskip\z@ \@plus .3\p@\relax + \raggedright + \let\item\@idxitem} + {\if@restonecol\onecolumn\else\clearpage\fi} + } + +% new definitions for R >= 2.0.0 +\ifthenelse{\boolean{Rd@use@hyper}} +{\newcommand{\LinkA}[2]{\hyperlink{Rfn.#2}{#1}\index{#1@\texttt{#1}|textit}}} +{\newcommand{\LinkA}[2]{#1\index{#1@\texttt{#1}|textit}}} +% +% \alias{<alias>}{<header>} +\ifthenelse{\boolean{Rd@use@hyper}} +{\newcommand{\aliasA}[3]{\hypertarget{Rfn.#3}{\index{#1@\texttt{#1} \textit{(\texttt{#2})}}}}} +{\newcommand{\aliasA}[3]{\index{#1@\texttt{#1} \textit{(\texttt{#2})}}}} +\ifthenelse{\boolean{Rd@use@hyper}} +{\newcommand{\methaliasA}[3]{\hypertarget{Rfn.#3}{\relax}}} +{\newcommand{\methaliasA}[3]{}} +\newcommand{\HeaderA}[3]{% + \vneed{1ex} + \markboth{#1}{#1} + \noindent + \nopagebreak + \begin{center} + \ifthenelse{\boolean{Rd@use@hyper}}% + {\def\@currentHref{page.\thepage} + \hypertarget{Rfn.#3}{\index{#1@\texttt{#1}}}% + \myaddcontentsline{toc}{subsection}{#1}% + \pdfbookmark[1]{#1}{Rfn.#3}} + {\addcontentsline{toc}{subsection}{#1} + \index{#1@\texttt{#1}|textbf}} + \hrule + \parbox{0.95\textwidth}{% + \begin{ldescription}[1.5in] + \item[\texttt{#1}] \emph{#2} + \end{ldescription}} + \hrule + \end{center} + \nopagebreak} +\DeclareTextCommandDefault{\Rpercent}{\%{}} +%% for use with the output of encoded_text_to_latex +\ProvideTextCommandDefault{\textdegree}{\ensuremath{{^\circ}}} +\ProvideTextCommandDefault{\textonehalf}{\ensuremath{\frac12}} +\ProvideTextCommandDefault{\textonequarter}{\ensuremath{\frac14}} +\ProvideTextCommandDefault{\textthreequarters}{\ensuremath{\frac34}} +\ProvideTextCommandDefault{\textcent}{\TextSymbolUnavailable\textcent} +\ProvideTextCommandDefault{\textyen}{\TextSymbolUnavailable\textyen} +\ProvideTextCommandDefault{\textcurrency}{\TextSymbolUnavailable\textcurrency} +\ProvideTextCommandDefault{\textbrokenbar}{\TextSymbolUnavailable\textbrokenbar} +\ProvideTextCommandDefault{\texteuro}{\TextSymbolUnavailable\texteuro} +\providecommand{\mathonesuperior}{\ensuremath{^1}} +\providecommand{\mathtwosuperior}{\ensuremath{^2}} +\providecommand{\maththreesuperior}{\ensuremath{^3}} + +\InputIfFileExists{Rd.cfg}{% + \typeout{Reading personal defaults ...}}{} Added: trunk/R2WinBUGS/vignettes/Z.cls =================================================================== --- trunk/R2WinBUGS/vignettes/Z.cls (rev 0) +++ trunk/R2WinBUGS/vignettes/Z.cls 2013-04-07 17:27:43 UTC (rev 260) @@ -0,0 +1,183 @@ +\def\fileversion{1.0} +\def\filename{Z} +\def\filedate{2004/10/08} +%% +%% Package `Z' to use with LaTeX2e for Z reports +%% Copyright (C) 2004 Achim Zeileis +%% +\NeedsTeXFormat{LaTeX2e} +\ProvidesClass{Z}[\filedate\space\fileversion\space Z class by Achim Zeileis] + +%% options +\LoadClass[10pt,a4paper,twoside]{article} +\newif\if@notitle +\@notitlefalse +\DeclareOption{notitle}{\@notitletrue} +\ProcessOptions + +%% required packages +\RequirePackage{graphicx,a4wide,color,hyperref,ae,fancyvrb,thumbpdf} +\RequirePackage[T1]{fontenc} +\usepackage[authoryear,round,longnamesfirst]{natbib} +\bibpunct{(}{)}{;}{a}{}{,} +\bibliographystyle{literatur} + +%% paragraphs +\setlength{\parskip}{0.7ex plus0.1ex minus0.1ex} +\setlength{\parindent}{0em} + +%% commands +\let\code=\texttt +\let\proglang=\textsf +\newcommand{\E}{\mathsf{E}} +\newcommand{\VAR}{\mathsf{VAR}} +\newcommand{\COV}{\mathsf{COV}} +\newcommand{\Prob}{\mathsf{P}} + +%% for all publications +\newcommand{\Plaintitle}[1]{\def\@Plaintitle{#1}} +\newcommand{\Shorttitle}[1]{\def\@Shorttitle{#1}} +\newcommand{\Plainauthor}[1]{\def\@Plainauthor{#1}} +\newcommand{\Keywords}[1]{\def\@Keywords{#1}} +\newcommand{\Plainkeywords}[1]{\def\@Plainkeywords{#1}} +\newcommand{\Abstract}[1]{\def\@Abstract{#1}} + +%% defaults +\author{Firstname Lastname\\Affiliation} +\title{Title} +\Abstract{---!!!---an abstract is required---!!!---} +\Plainauthor{\@author} +\Plaintitle{\@title} +\Shorttitle{\@title} +\Keywords{---!!!---at least one keyword is required---!!!---} +\Plainkeywords{\@Keywords} + +%% Sweave(-like) +\DefineVerbatimEnvironment{Sinput}{Verbatim}{fontshape=sl} +\DefineVerbatimEnvironment{Soutput}{Verbatim}{} +\DefineVerbatimEnvironment{Scode}{Verbatim}{fontshape=sl} +%\newenvironment{Schunk}{}{} +\DefineVerbatimEnvironment{Code}{Verbatim}{} +\DefineVerbatimEnvironment{CodeInput}{Verbatim}{fontshape=sl} +\DefineVerbatimEnvironment{CodeOutput}{Verbatim}{} +\newenvironment{CodeChunk}{}{} +\setkeys{Gin}{width=0.8\textwidth} + +%% new \maketitle +\def\maketitle{ + \begingroup + \def\thefootnote{\fnsymbol{footnote}} + \def\@makefnmark{\hbox to 0pt{$^{\@thefnmark}$\hss}} + \long\def\@makefntext##1{\parindent 1em\noindent + \hbox to1.8em{\hss $\m@th ^{\@thefnmark}$}##1} + \@maketitle \@thanks + \endgroup + \setcounter{footnote}{0} + \thispagestyle{empty} + \markboth{\centerline{\@Shorttitle}}{\centerline{\@Plainauthor}} + \pagestyle{myheadings} + + \let\maketitle\relax \let\@maketitle\relax + \gdef\@thanks{}\gdef\@author{}\gdef\@title{}\let\thanks\relax +} + +\def\@maketitle{\vbox{\hsize\textwidth \linewidth\hsize + {\centering + {\LARGE\bf \@title\par} + \def\And{\end{tabular}\hfil\linebreak[0]\hfil + \begin{tabular}[t]{c}\large\bf\rule{\z@}{24pt}\ignorespaces}% + \begin{tabular}[t]{c}\large\bf\rule{\z@}{24pt}\@author\end{tabular}% + \vskip 0.3in minus 0.1in + \hrule + \begin{abstract} + \@Abstract + \end{abstract}} + \textit{Keywords}:~\@Keywords. + \vskip 0.1in minus 0.05in + \hrule + \vskip 0.2in minus 0.1in +}} + + +%% sections, subsections, and subsubsections +\newlength{\preXLskip} +\newlength{\preLskip} +\newlength{\preMskip} +\newlength{\preSskip} +\newlength{\postMskip} +\newlength{\postSskip} +\setlength{\preXLskip}{1.8\baselineskip plus 0.5ex minus 0ex} +\setlength{\preLskip}{1.5\baselineskip plus 0.3ex minus 0ex} +\setlength{\preMskip}{1\baselineskip plus 0.2ex minus 0ex} +\setlength{\preSskip}{.8\baselineskip plus 0.2ex minus 0ex} +\setlength{\postMskip}{.5\baselineskip plus 0ex minus 0.1ex} +\setlength{\postSskip}{.3\baselineskip plus 0ex minus 0.1ex} + +\newcommand{\jsssec}[2][default]{\vskip \preXLskip% + \pdfbookmark[1]{#1}{Section.\thesection.#1}% + \refstepcounter{section}% + \centerline{\textbf{\Large \thesection. #2}} \nopagebreak + \vskip \postMskip \nopagebreak} +\newcommand{\jsssecnn}[1]{\vskip \preXLskip% + \centerline{\textbf{\Large #1}} \nopagebreak + \vskip \postMskip \nopagebreak} + +\newcommand{\jsssubsec}[2][default]{\vskip \preMskip% + \pdfbookmark[2]{#1}{Subsection.\thesubsection.#1}% + \refstepcounter{subsection}% + \textbf{\large \thesubsection. #2} \nopagebreak + \vskip \postSskip \nopagebreak} +\newcommand{\jsssubsecnn}[1]{\vskip \preMskip% + \textbf{\large #1} \nopagebreak + \vskip \postSskip \nopagebreak} + +\newcommand{\jsssubsubsec}[2][default]{\vskip \preSskip% + \pdfbookmark[3]{#1}{Subsubsection.\thesubsubsection.#1}% + \refstepcounter{subsubsection}% + {\large \textit{#2}} \nopagebreak + \vskip \postSskip \nopagebreak} +\newcommand{\jsssubsubsecnn}[1]{\vskip \preSskip% + {\textit{\large #1}} \nopagebreak + \vskip \postSskip \nopagebreak} + +\newcommand{\jsssimplesec}[2][default]{\vskip \preLskip% +%% \pdfbookmark[1]{#1}{Section.\thesection.#1}% + \refstepcounter{section}% + \textbf{\large #1} \nopagebreak + \vskip \postSskip \nopagebreak} +\newcommand{\jsssimplesecnn}[1]{\vskip \preLskip% + \textbf{\large #1} \nopagebreak + \vskip \postSskip \nopagebreak} + +\renewcommand{\section}{\secdef \jsssec \jsssecnn} +\renewcommand{\subsection}{\secdef \jsssubsec \jsssubsecnn} +\renewcommand{\subsubsection}{\secdef \jsssubsubsec \jsssubsubsecnn} + +%% colors +\definecolor{Red}{rgb}{0.7,0,0} +\definecolor{Blue}{rgb}{0,0,0.8} +\hypersetup{% + hyperindex = {true}, + colorlinks = {true}, + linktocpage = {true}, + plainpages = {false}, + linkcolor = {Blue}, + citecolor = {Blue}, + urlcolor = {Red}, + pdfstartview = {Fit}, + pdfpagemode = {UseOutlines}, + pdfview = {XYZ null null null} +} + +\AtBeginDocument{ + \hypersetup{% + pdfauthor = {\@Plainauthor}, + pdftitle = {\@Plaintitle}, + pdfkeywords = {\@Plainkeywords} + } +} +\if@notitle + %% \AtBeginDocument{\maketitle} +\else + \AtBeginDocument{\maketitle} +\fi Added: trunk/R2WinBUGS/vignettes/benzolsw.pdf =================================================================== (Binary files differ) Property changes on: trunk/R2WinBUGS/vignettes/benzolsw.pdf ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/R2WinBUGS/vignettes/bugs.tex =================================================================== --- trunk/R2WinBUGS/vignettes/bugs.tex (rev 0) +++ trunk/R2WinBUGS/vignettes/bugs.tex 2013-04-07 17:27:43 UTC (rev 260) @@ -0,0 +1,201 @@ +\HeaderA{bugs}{Run WinBUGS and OpenBUGS from R or S-PLUS}{bugs} +\keyword{interface}{bugs} +\keyword{models}{bugs} +\begin{Description}\relax +The \code{bugs} function takes data and starting values as input. +It automatically writes a WinBUGS script, calls the model, +and saves the simulations for easy access in R or S-PLUS. +\end{Description} +\begin{Usage} +\begin{verbatim} +bugs(data, inits, parameters.to.save, model.file = "model.bug", + n.chains = 3, n.iter = 2000, n.burnin = floor(n.iter/2), + n.thin = max(1, floor(n.chains * (n.iter - n.burnin)/1000)), + bin = (n.iter - n.burnin) / n.thin, + debug = FALSE, DIC = TRUE, digits = 5, codaPkg = FALSE, + bugs.directory = "c:/Program Files/WinBUGS14/", + program = c("winbugs", "openbugs", "WinBugs", "OpenBugs"), + working.directory = NULL, clearWD = FALSE, + useWINE = .Platform$OS.type != "windows", WINE = Sys.getenv("WINE"), + newWINE = FALSE, WINEPATH = NULL) +\end{verbatim} +\end{Usage} +\begin{Arguments} +\begin{ldescription} +\item[\code{data}] either a named list (names corresponding to variable names in the \code{model.file}) +of the data for the WinBUGS model, \emph{or} +a vector or list of the names of the data objects used by the model. +If \code{data = "data.txt"}, it is assumed that data have already been written to the working directory +in a file called \file{data.txt}, e.g. by the function \code{\LinkA{bugs.data}{bugs.data}}. +\item[\code{inits}] a list with \code{n.chains} elements; each element of the list is +itself a list of starting values for the WinBUGS model, \emph{or} +a function creating (possibly random) initial values. +Alternatively, if \code{inits = NULL}, initial values are generated by WinBUGS +\item[\code{parameters.to.save}] character vector of the names of the parameters to save which should be monitored +\item[\code{model.file}] file containing the model written in WinBUGS code. +The extension can be either \file{.bug} or \file{.txt}. + +If the extension is \file{.bug} and \code{program=="winbugs"}, +a copy of the file with extension \file{.txt} will be created +in the \code{bugs()} call and removed afterwards. +Note that similarly named \file{.txt} files will be overwritten. +\item[\code{n.chains}] number of Markov chains (default: 3) +\item[\code{n.iter}] number of total iterations per chain (including burn in; default: 2000) +\item[\code{n.burnin}] length of burn in, i.e. number of iterations to discard at the beginning. +Default is \code{n.iter/2}, that is, discarding the first half of the simulations. +\item[\code{n.thin}] thinning rate. Must be a positive integer. +Set \code{n.thin} > 1 to save memory and computation time if \code{n.iter} is large. +Default is \code{max(1, floor(n.chains * (n.iter-n.burnin) / 1000))} +which will only thin if there are at least 2000 simulations. +\item[\code{bin}] number of iterations between saving of results +(i.e. the coda files are saved after each \code{bin} iterations); +default is to save only at the end. +\item[\code{debug}] if \code{FALSE} (default), WinBUGS is closed automatically +when the script has finished running, otherwise WinBUGS remains open for further investigation +\item[\code{DIC}] logical; if \code{TRUE} (default), compute deviance, pD, and DIC. +This is done in WinBUGS directly using the rule \code{pD = Dbar - Dhat}. +If there are less iterations than required for the adaptive phase, +the rule \code{pD = var(deviance) / 2} is used. +\item[\code{digits}] number of significant digits used for WinBUGS input, see \code{\LinkA{formatC}{formatC}} +\item[\code{codaPkg}] logical; if \code{FALSE} (default) a \code{bugs} object is returned, +if \code{TRUE} file names of WinBUGS output are returned for easy access by the \pkg{coda} package +through function \code{\LinkA{read.bugs}{read.bugs}}. (not used if \code{program = "openbugs"}) +\item[\code{bugs.directory}] directory that contains the WinBUGS executable +\item[\code{program}] the program to use, either \code{winbugs}/\code{WinBugs} or \code{openbugs}/\code{OpenBugs}, +the latter makes use of function \code{\LinkA{openbugs}{openbugs}} and requires the CRAN package \pkg{BRugs}. +The \code{openbugs}/\code{OpenBugs} choice is not available in S-PLUS. +\item[\code{working.directory}] sets working directory during execution of this function; +WinBUGS' in- and output will be stored in this directory; +if \code{NULL}, the current working directory is chosen. +\item[\code{clearWD}] logical; indicating whether the files \file{data.txt}, +\file{inits[1:n.chains].txt}, \file{log.odc}, \file{codaIndex.txt}, and +\file{coda[1:nchains].txt} should be removed after WinBUGS has finished. +If set to \code{TRUE}, this argument is only respected if \code{codaPkg = FALSE}. + +\item[\code{useWINE}] logical; attempt to use the WINE emulator to run WinBUGS, +defaults to \code{TRUE} on Windows, and \code{FALSE} otherwise. +If WINE is used, the arguments \code{bugs.directory} and \code{working.directory} must be given in form of Linux paths +rather than Windows paths (if not \code{NULL}). +The \code{useWINE = TRUE} option is not available in S-PLUS. +\item[\code{WINE}] character; name of WINE binary file +\item[\code{newWINE}] Set this one to \code{TRUE} for new versions of WINE. +\item[\code{WINEPATH}] Path the WINE, it is tried hard to get the information automatically if not given. +\end{ldescription} +\end{Arguments} +\begin{Details}\relax +To run: +\Enumerate{ +\item Write a WinBUGS model in a ASCII file. +\item Go into R / S-PLUS. +\item Prepare the inputs to the \code{bugs} function and run it (see Example). +\item A WinBUGS window will pop up and R / S-PLUS will freeze up. The model +will now run in WinBUGS. It might take awhile. You will see +things happening in the Log window within WinBUGS. When WinBugs +is done, its window will close and R / S-PLUS will work again. +\item If an error message appears, re-run with \code{debug = TRUE}. +} +\end{Details} +\begin{Value} +If \code{codaPkg = TRUE} the returned values are the names +of coda output files written by WinBUGS containing +the Markov Chain Monte Carlo output in the CODA format. +This is useful for direct access with \code{\LinkA{read.bugs}{read.bugs}}. + +If \code{codaPkg = FALSE}, the following values are returned: +\begin{ldescription} +\item[\code{n.chains}] see Section \sQuote{Arguments} +\item[\code{n.iter}] see Section \sQuote{Arguments} +\item[\code{n.burnin}] see Section \sQuote{Arguments} +\item[\code{n.thin}] see Section \sQuote{Arguments} +\item[\code{n.keep}] number of iterations kept per chain (equal to \code{(n.iter-n.burnin) / n.thin}) +\item[\code{n.sims}] number of posterior simulations (equal to \code{n.chains * n.keep}) +\item[\code{sims.array}] 3-way array of simulation output, with dimensions +n.keep, n.chains, and length of combined parameter vector +\item[\code{sims.list}] list of simulated parameters:\\ +for each scalar parameter, a vector of length n.sims\\ +for each vector parameter, a 2-way array of simulations,\\ +for each matrix parameter, a 3-way array of simulations, etc. +(for convenience, the \code{n.keep * n.chains} simulations in +sims.matrix and sims.list (but NOT sims.array have been randomly permuted) +\item[\code{sims.matrix}] matrix of simulation output, with \code{n.chains * n.keep} rows and +one column for each element of each saved parameter +(for convenience, the \code{n.keep * n.chains} simulations in +sims.matrix and sims.list (but NOT sims.array have been randomly permuted) +\item[\code{summary}] summary statistics and convergence information for each +element of each saved parameter. +\item[\code{mean}] a list of the estimated parameter means +\item[\code{sd}] a list of the estimated parameter standard deviations +\item[\code{median}] a list of the estimated parameter medians +\item[\code{root.short}] names of argument \code{parameters.to.save} and \dQuote{deviance} +\item[\code{long.short}] indexes; programming stuff +\item[\code{dimension.short}] dimension of \code{indexes.short} +\item[\code{indexes.short}] indexes of \code{root.short} +\item[\code{last.values}] list of simulations from the most recent iteration; they +can be used as starting points if you wish to run WinBUGS for further iterations +\item[\code{pD}] an estimate of the effective number of parameters, for calculations see the section \dQuote{Arguments}. +\item[\code{DIC}] \code{mean(deviance) + pD} +\end{ldescription} +\end{Value} +\begin{Author}\relax +Andrew Gelman, \email{ge...@st...}, \url{http:/www.stat.columbia.edu/~gelman/bugsR/}; +modifications and packaged by Sibylle Sturtz, \email{st...@st...}, and Uwe Ligges. +\end{Author} +\begin{References}\relax +Gelman, A., Carlin, J.B., Stern, H.S., Rubin, D.B. (2003): +\emph{Bayesian Data Analysis}, 2nd edition, CRC Press. + +Sturtz, S., Ligges, U., Gelman, A. (2005): +R2WinBUGS: A Package for Running WinBUGS from R. +\emph{Journal of Statistical Software} 12(3), 1-16. +\end{References} +\begin{SeeAlso}\relax +\code{\LinkA{print.bugs}{print.bugs}}, \code{\LinkA{plot.bugs}{plot.bugs}}, and the \pkg{coda} package +\end{SeeAlso} +\begin{Examples} +\begin{ExampleCode} +# An example model file is given in: +model.file <- system.file(package = "R2WinBUGS", "model", "schools.txt") +# Let's take a look: +file.show(model.file) + + + + + + +# Some example data (see ?schools for details): +data(schools) +schools + +J <- nrow(schools) +y <- schools$estimate +sigma.y <- schools$sd +data <- list ("J", "y", "sigma.y") +inits <- function(){ + list(theta = rnorm(J, 0, 100), mu.theta = rnorm(1, 0, 100), + sigma.theta = runif(1, 0, 100)) +} +## or alternatively something like: +# inits <- list( +# list(theta = rnorm(J, 0, 90), mu.theta = rnorm(1, 0, 90), +# sigma.theta = runif(1, 0, 90)), +# list(theta = rnorm(J, 0, 100), mu.theta = rnorm(1, 0, 100), +# sigma.theta = runif(1, 0, 100)) +# list(theta = rnorm(J, 0, 110), mu.theta = rnorm(1, 0, 110), +# sigma.theta = runif(1, 0, 110))) + +parameters <- c("theta", "mu.theta", "sigma.theta") + +## Not run: +## You may need to edit "bugs.directory", +## also you need write access in the working directory: +schools.sim <- bugs(data, inits, parameters, model.file, + n.chains = 3, n.iter = 5000, + bugs.directory = "c:/Program Files/WinBUGS14/", + working.directory = NULL, clearWD = TRUE) +print(schools.sim) +plot(schools.sim) +## End(Not run) +\end{ExampleCode} +\end{Examples} + Added: trunk/R2WinBUGS/vignettes/countssw.pdf =================================================================== (Binary files differ) Property chang... [truncated message content] |
From: <li...@us...> - 2013-04-07 17:26:43
|
Revision: 259 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=259&view=rev Author: ligges Date: 2013-04-07 17:26:34 +0000 (Sun, 07 Apr 2013) Log Message: ----------- Removed Paths: ------------- trunk/R2WinBUGS/vignettes/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2013-04-07 17:24:37
|
Revision: 258 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=258&view=rev Author: ligges Date: 2013-04-07 17:24:24 +0000 (Sun, 07 Apr 2013) Log Message: ----------- last committed did not complete, hence retry Added Paths: ----------- trunk/R2WinBUGS/vignettes/R2WinBUGS.Rnw trunk/R2WinBUGS/vignettes/RdRW.sty trunk/R2WinBUGS/vignettes/Z.cls trunk/R2WinBUGS/vignettes/benzolsw.pdf trunk/R2WinBUGS/vignettes/bugs.tex trunk/R2WinBUGS/vignettes/countssw.pdf trunk/R2WinBUGS/vignettes/expectedsw.pdf trunk/R2WinBUGS/vignettes/literatur.bib trunk/R2WinBUGS/vignettes/literatur.bst trunk/R2WinBUGS/vignettes/plot.pdf Removed Paths: ------------- trunk/R2WinBUGS/vignettes/R2WinBUGS.Rnw trunk/R2WinBUGS/vignettes/RdRW.sty trunk/R2WinBUGS/vignettes/Z.cls trunk/R2WinBUGS/vignettes/benzolsw.pdf trunk/R2WinBUGS/vignettes/bugs.tex trunk/R2WinBUGS/vignettes/countssw.pdf trunk/R2WinBUGS/vignettes/expectedsw.pdf trunk/R2WinBUGS/vignettes/literatur.bib trunk/R2WinBUGS/vignettes/literatur.bst trunk/R2WinBUGS/vignettes/plot.pdf Deleted: trunk/R2WinBUGS/vignettes/R2WinBUGS.Rnw =================================================================== --- trunk/R2WinBUGS/vignettes/R2WinBUGS.Rnw 2013-04-07 17:22:49 UTC (rev 257) +++ trunk/R2WinBUGS/vignettes/R2WinBUGS.Rnw 2013-04-07 17:24:24 UTC (rev 258) @@ -1,506 +0,0 @@ -%\VignetteIndexEntry{R2WinBUGS} -\documentclass{Z} -\usepackage{RdRW,thumbpdf} -\newcommand{\WinBUGS}{{\proglang{WinBUGS}}{}} -\newcommand{\RW}{{\pkg{R2WinBUGS}}{}} -\renewcommand{\R}{{\proglang{R}}{}} -\setlength{\textheight}{23.5cm} - -\title{\RW{}:\protect\linebreak A Package for Running \WinBUGS{} from \R{}} -\author{Sibylle Sturtz\thanks{\email{st...@st...}}\\Fachbereich Statistik\\Universit\"at Dortmund\\Germany - \And - Uwe Ligges\thanks{\email{li...@st...}}\\Fachbereich Statistik\\Universit\"at Dortmund\\Germany - \And - Andrew Gelman\thanks{\email{ge...@st...}}\\Department of Statistics\\Columbia University\\USA -} -\Plainauthor{Sibylle Sturtz, Uwe Ligges, Andrew Gelman} -\Plaintitle{R2WinBUGS: A Package for Running WinBUGS from R} - -\Abstract{ -The \RW{} package provides convenient functions to call \WinBUGS{} from \R{}. It -automatically writes the data and scripts in a format readable by \WinBUGS{} for processing in batch mode, which -is possible since version 1.4. After the \WinBUGS{} process has finished, it is possible either to read the -resulting data into \R{} by the package itself---which gives a compact graphical summary of inference and -convergence diagnostics---or to use the facilities of the \pkg{coda} package for further analyses of the -output. Examples are given to demonstrate the usage of this package. -} - -\Keywords{\R{}, \WinBUGS{}, interface, MCMC} -\Plainkeywords{R, WinBUGS, interface, MCMC} - -\begin{document} -An earlier version of this vignette has been published by the Journal of Statistical Software:\\ -Sturtz S, Ligges U, Gelman A (2005): -``\RW{}: A Package for Running \WinBUGS{} from \R{}.'' -{\em Journal of Statistical Software}, 12(3), 1--16. - - -\section{Introduction}\label{Introduction} -The usage of Markov chain Monte Carlo (MCMC) methods became very popular within the last decade. \WinBUGS{} -\citep[\textbf{B}ayesian inference \textbf{U}sing \textbf{G}ibbs \textbf{S}ampling, ][] -{Spiegelhalter;Thomas;Best:2003} is a popular software for analyzing complex statistical models using MCMC -methods. This software uses Gibbs sampling \citep{Geman;Geman:1984,Gelfand;Smith:1990,Casella;George:1992} and the -Metropolis algorithm \citep{Metropolis;Rosenbluth;Rosenbluth;Teller;Teller:1953} -to generate a Markov chain by sampling from full conditional -distributions. -The \WinBUGS{} software is available for free -at \url{http://www.mrc-bsu.cam.ac.uk/bugs/}. -An introduction to MCMC methods is given in \cite{Gilks;Richardson;Spiegelhalter:1996}. - -Using \WinBUGS{}, the user must specify the model to run, and to load data and initial values for a specified -number of Markov chains. Then it is possible to run the Markov chain(s) and to save the results for the parameters -the user is interested in. Summary statistics of these data, convergence diagnostics, kernel estimates -etc.\ are available as well. -Nevertheless, some users of this software might be interested in saving the output and reading it into \R{} -\citep{RCore:2004} for further analyses. -\WinBUGS{} 1.4 comes with the ability to run the software in batch mode using scripts. - -The \RW{} package makes use of this feature and provides the tools to call \WinBUGS{} -directly after data manipulation in \R{}. Furthermore, it is possible to -work with the results after importing them back into \R{} again, for example to create posterior predictive simulations or, more generally, graphical displays of data and posterior simulations \citep{gelman:2004}. -Embedding in R can also be useful for frequently changed data or processing a bunch of data sets, -because it is much more convenient to use some \R{} functions (possibly within a loop) -rather than using ``copy \& paste'' to update data in \WinBUGS{} each time; however difficulties have been encountered in this area because both \R{} and \WinBUGS{} can lock up RAM in the Windows operating system. - -\R{} is a ``language for data analysis and graphics'' and an open source and -freely available statistical software package implementing that language, see \url{http://www.R-project.org/}. -Historically, \R{} is an implementation of the award-winning \proglang{S} -language and system \citep{becker:1984r,becker:1988r,chambers:1992,chambers:1998}. -\R{} and \RW{} are available from \emph{CRAN} (Comprehensive \R{} Archive Network), -i.e., \url{http://CRAN.R-Project.org} or one of its mirrors. -\RW{} could be ported to the commercial \proglang{S} implementation -\textsc{S-Plus}. Minor adaptions would be needed since \textsc{S-Plus} -lacks some of \R{}'s functions and capabilities. -If an internet connection is available, \RW{} can be installed by typing -\verb+install.packages("R2WinBUGS")+ at the \R{} command prompt. -Do not forget to load the package with \verb+library("R2WinBUGS")+. - -The package \pkg{coda} by \cite{Plummer;Best;Cowles;Vines:2004} is very useful for the analysis of \WinBUGS{}' -output, the reader might want to install this package as well. The CRAN package \pkg{boa} (Bayesian Output -Analysis Program) by \cite{Smith:2004} has similar aims. -\proglang{JAGS} (Just Another Gibbs Sampler) -by \cite{Plummer:2003} is a program for analysis of Bayesian hierarchical models using Gibbs sampling that aims for -the same functionality as classic \proglang{BUGS}. \proglang{JAGS} is developed to work closely together with \R{} and -the \pkg{coda} package. - -%% Revision 2005-01-10 start -A new and completely revised version of WinBUGS called \proglang{OpenBUGS} \citep{Spiegelhalter;Thomas;Best;Lunn:2004} -was lately published under the terms of the GPL. -\proglang{OpenBUGS} is also expected to run under Linux. -It provides a much more flexible API on which ``BRugs'' is based including -a dynamic link library, incorporating a component loader -that allows \R{} to make use of \proglang{OpenBUGS} components. -OpenBUGS is still in development and suffers frequent crashes. -As OpenBUGS becomes more reliable, -it is planned to merge ``BRugs'' and \RW{} into one \R{} package. -%% Revision 2005-01-10 end - -For other packages and projects on spatial statistics -related to \R{}, follow the link to ``\R{} spatial projects'' at CRAN. - -In this paper, we give two examples, involving educational testing experiments in schools (cf.~Section~\ref{School}), -and incidence of childhood leukaemia depending on benzene emissions (cf.~Section~\ref{Leukaemia}). Details on the -functions of \RW{} are given in Section~\ref{Programming}. These functions automatically write the data and a -script in a format readable by \WinBUGS{} for processing in batch mode, and call \WinBUGS{} from \R{}. After the -\WinBUGS{} process has finished, it is possible either to read the resulting data into \R{} by the package itself -or to use the facilities of the \pkg{coda} package for further analyses of the output. In Section~\ref{Example2}, -we demonstrate how to apply the functions provided by \RW{} on the examples' data, and how to analyze the output -both with package \pkg{coda} and with \RW{}'s methods to \verb+plot()+ and \verb+print()+ the output. - - -\section{Examples}\label{Examples} -In this Section, we introduce two examples which will be continued in Section~\ref{Example2}. - -\subsection{Schools data}\label{School} -The Scholastic Aptitude Test (SAT) measures the aptitude of high-schoolers in order to help colleges to make -admissions decisions. It is divided into two parts, verbal (SAT-V) and mathematical (SAT-M). -Our data comes from the SAT-V (Scholastic Aptitude Test-Verbal) on eight different high schools, from an experiment conducted in the late 1970s. -SAT-V is a standard multiple choice test administered by the Educational Testing Service. -This Service was interested in the effects of coaching programs for each of the selected schools. - -The study included coached and uncoached pupils, about sixty in each of the eight different schools; see -\cite{Rubin:1981}. All of them had already taken the PSAT (Preliminary SAT) which results were used as covariates. -%Even if the test is constructed to be resistant to short-term -%efforts directed specifically toward improving test performance, each of the schools is successful at increasing -%SAT scores. -For each school, the estimated treatment effect and the standard error of the effect estimate are given. -These are calculated by an analysis of covariance adjustment appropriate for a completely randomized experiment -\citep{Rubin:1981}. This example was analyzed using a hierarchical normal model in \cite{Rubin:1981} and -\citeauthor{Gelman:2003} (\citeyear{Gelman:2003}, Section 5.5). - -\subsection{Leukaemia registration data}\label{Leukaemia} -Spatial data usually arises on different, non-nesting spatial scales. One example is childhood leukaemia -registration data analyzed by \cite{Best;Cockings;Bennett;Wakefield;Elliot:2001} -using ecologic regression. Data are given for Greater London bounded by the M25 orbital motorway. -%% Revision 2005-01-10 start -The data are not available as an example in \RW{} but we use the example here -to illustrate -alternative calls to the \verb+bugs()+ function and output analysis using the \pkg{coda} package. -%% Revision 2005-01-10 end - -The observed number of leukaemia cases among children under 15 years old is given at ward level. Census wards are -administrative areas containing approximately 5000 to 10\,000 people. Central London is divided into 873 wards. The -number of incident cases of leukaemia in children is available from 1985 until 1996 from the Office of National -Statistics and the Thames Cancer Registry. A plot of these numbers is given in Figure~\ref{observed}. - -\begin{figure} -\begin{center} -\includegraphics[width=0.85\textwidth]{countssw} -\caption{\label{observed}Observed number of cases of childhood leukaemia in 1985--1996} -\end{center} -\end{figure} - -Additionally, the number of expected cases (cf.~Fig.~\ref{expected}) is calculated on the same -resolution using population numbers for different age-sex-strata and the national leukaemia -rate for the corresponding strata, for details see \cite{Best;Cockings;Bennett;Wakefield;Elliot:2001}. - -\begin{figure} -\begin{center} -\includegraphics[width=0.85\textwidth]{expectedsw} -\caption{\label{expected}Expected number of cases of childhood leukaemia in 1985--1996}%, as obtained from a simple demographic model} -\end{center} -\end{figure} - -It is assumed that benzene emissions have an effect on the incidence rate of leukaemia. Benzene emission rates are -available in tonnes per year from an atmospheric emissions inventory for London -\citep{Buckingham;Clewley;Hutchinson;Sadler;Shah:1997} produced by the London Research Centre. They are provided -at 1km $\times$ 1km grid cells, giving 2132 grid cells in total. -Their spatial distribution is shown in Figure~\ref{benzene}. - -\begin{figure} -\begin{center} -\includegraphics[width=0.9\textwidth]{benzolsw} -\caption{\label{benzene}Benzene emissions in tonnes per year} -\end{center} -\end{figure} - -For further details on the data see \cite{Best;Cockings;Bennett;Wakefield;Elliot:2001}. - -We model these data by Poisson-Gamma models introduced by \cite{Best;Ickstadt;Wolpert:2000} using \WinBUGS{}. -A linking matrix containing information which grid cell belongs to which ward -and to which amount is required. This matrix is calculated using \R{}. -Unfortunately, \WinBUGS{} does not support a list format such as directly produced by \R{}. -Therefore, the data must be provided as a matrix with 2132 rows and 873 columns (or vice versa). -Most of the entries of this matrix are zeroes, but using \verb+dump()+ to export it from \R{} -yields in a file size of 14.2~MB. -Unfortunately, opening a file of such size really slows \WinBUGS{} down, -and it was not even possible on some of our PCs. -Importing data written by our \RW{} package does not make any problems using the batch mode, -probably due to memory management issues in \WinBUGS{}. - - -\section{Implementation}\label{Programming} -The implementation of the \RW{} package is straightforward. -The ``main'' function \verb+bugs()+ is intended to be called by the user. -In principle, it is a wrapper for several other functions called therein step by step as follows: -\begin{enumerate} - \item \verb+bugs.data.inits()+ writes the data files \file{data.txt}, and \file{inits1.txt}, \file{inits2.txt}, ... - into the working directory. These files will be used by \WinBUGS{} during batch processing. - - In particular, input for \WinBUGS{} must not exceed a certain number of digits. - Moreover, it needs an \verb+E+ instead of an \verb+e+ in scientific notation. - Scientific notation is particularly desirable because of the ``number of digits'' limitation. - The default (\verb+digits = 5+) is to, e.g., reformat the number \verb+123456.789+ to \verb@1.23457E+05@. - \item \verb+bugs.script()+ writes the file \file{script.txt} that is used by \WinBUGS{} for batch processing. - \item \verb+bugs.run()+ updates the lengths of the adaptive phases in the \WinBUGS{} registry - (using a function \verb+bugs.update.settings()+), - calls \WinBUGS{}, and runs it in batch mode with \file{script.txt}. - \item \verb+bugs.sims()+ is only called if the argument \verb+codaPkg+ has been set to \verb+FALSE+ (the default). - Otherwise \verb+bugs()+ returns the filenames of stored data. These can, for example, - be imported by package \pkg{coda} (see the example in Section~\ref{Leukaemia2}, page~\pageref{codaexample}), - which provides functions for convergence diagnostics, - calculation of Monte Carlo estimates, trace plots, and so forth. - - The function \verb+bugs.sims()+ reads simulations from \WinBUGS{} into \R{} (not necessarily called by \verb+bugs()+ - itself), formats them, - monitors convergence, performs convergence checks, and computes medians and quantiles. - It also prepares the output for \verb+bugs()+ itself. -\end{enumerate} -These functions are not intended to be called by the user directly. -Arguments are passed from \verb+bugs()+ to the other functions, if appropriate. -A shortened help file of \verb+bugs()+ listing all arguments is given in Appendix~\ref{Doc}; -for the full version type \verb+?bugs+ in \R{} after having installed and loaded the package \RW{} -(see Section~\ref{Introduction}). - -%\newpage -As known from \WinBUGS{}, one must specify the \verb+data+ in form of a list, with list names equal to the names -of data in the corresponding \WinBUGS{} model. Alternatively, it is possible to specify a vector or list of names -(of mode \verb+character+). In that case objects of that names are looked for in the environment in which -\verb+bugs()+ has been called (usually that is the user's Workspace, \verb+.GlobalEnv+). -%% Revision 2005-01-10 start -If data have already been written in a file called \file{data.txt} to the working directory, -it is possible to specify \verb+data = "data.txt"+. -%% Revision 2005-01-10 end -One will usually want to supply initial values. -This can be done either in the form of a function \verb+inits()+ that creates these values, so that -different chains can be automatically initialized at different points (see Section \ref{School2}), or by specifying them -directly (see Section \ref{Leukaemia2}). -If \verb+inits()+ is not specified, -\verb+bugs()+ just uses the starting values created by \WinBUGS{}; but in practice \WinBUGS{} can crash when -reasonable initial values are not specified, and so we recommend constructing a simple \verb+inits()+ function to -simulate reasonable starting points \cite[Section C.2]{Gelman:2003}. It is also necessary to specify which -parameters should be saved for monitoring by specifying \verb+parameters.to.save+. - -The user might also want to change the defaults for the length of the burn-in (\verb+n.burnin+, which defaults to half the length of the chain) -period for every MCMC run and the number of iterations (\verb+n.iter+, default value 3) -that are used to calculate Monte Carlo estimates. -%SS: Achtung: n.iter=n.burn.in + length of stored chain! -The specification of a thinning parameter (\verb+n.thin+) is possible as well; this is useful when the number of parameters is large, to keep the saved output to a reasonably-sized R object. In the default setting, the chains are thinned enough so that approximately 1000 simulation draws are saved. - -By setting the argument \verb+debug = TRUE+, -\WinBUGS{} remains open after the run. -This way it is possible to find errors in the code or the data structure, -or even to work with that software as in a usual run. - -It is possible to run one or more Markov chains. -The number of chains (\verb+n.chains+) must be specified together with the chains' initial values (\verb+inits+). -If more than one Markov chain is requested and \verb+codaPkg+ is set to \verb+FALSE+, the convergence diagnostic -$\hat{R}$ \citep{Brooks;Gelman:1998} is calculated by \verb+bugs.sims()+ for each of the saved parameters. - -%% Revision 2005-01-10 start -Since the communication between \WinBUGS{} and \R{} is based on files, -rather huge files will be saved in the working directory by the \verb+bugs()+ call, -either files to be read in by \verb+bugs()+ itself, or by the \pkg{coda} package. -The user might want to delete those files after the desired contents has been imported into \R{}, -and save those objects, e.g., as compressed \R{} data files. -%% Revision 2005-01-10 end - -The function \verb+bugs()+ returns a rather complex object of class \verb+bugs+, -if called with argument \verb+codaPkg = FALSE+. -In order to look at the structure of such an object, type \verb+str(objectname)+. -For convenience, \RW{} provides methods corresponding to class \verb+bugs+ for -the generic functions \verb+print()+ and \verb+plot()+. - -So that user will not be overwhelmed with information; summaries of the output are provided by the -\verb+print()+ method. That is, some parameters of the \verb+bugs()+ call are summarized, and mean, -standard deviation, several quantiles of the parameters and convergence diagnostics based on \cite{Gelman;Rubin:1992} -are printed. See the example in -Section~\ref{School2}, page~\pageref{schoolssim}, for a typical output. As with \cite{Spiegelhalter;Best;Carlin;vdLinde:2002}, -%\pagebreak - the DIC computed by \verb+bugs.sims()+ is defined as the posterior mean -of the deviance plus $p_D$, the estimated effective number of parameters in the posterior distribution. We define -$p_D$ as half the posterior variance of the deviance and estimate it as half the average of the within-chain -variances of the deviance.\footnote{In contrast, \cite{Spiegelhalter;Best;Carlin;vdLinde:2002}, - and WinBUGS, define $p_D$ as the -posterior mean of the deviance evaluated at the posterior mean of the parameter values. We cannot use that -definition because the deviance function is not available to our program, which calls \WinBUGS{} from the -``outside''. Both definitions of $p_D$---ours and that introduced by \cite{Spiegelhalter;Best;Carlin;vdLinde:2002}---can be -derived from the asymptotic $\chi^2$ distribution of the deviance relative to its minimum \citep[Section 6.7]{Gelman:2003}. -We make no claim that our measure of $p_D$ is superior to that of \cite{Spiegelhalter;Best;Carlin;vdLinde:2002}; -we choose this measure purely because it is computationally possible given what is available to us from the \WinBUGS{} output.} - - -The \verb+plot()+ for objects of class \verb+bugs+ -provides information condensed in some plots conveniently arranged within the same graphics device. -For an example, see Figure~\ref{plot} in Section~\ref{School2}. It is intended to adapt this function to work with MCMC output in general, even if obtained from software other than WinBUGS. - - - -\section{Examples continued}\label{Example2} -The Examples introduced in Section~\ref{Example2} are continued in this Section. -We apply the functions provided by \RW{} -to the examples' data and analyze the output. - -\subsection{Schools data}\label{School2} -Schools example data (see Section~\ref{School}) are available with the \RW{} package: -\begin{Code} - > data(schools) - > schools - school estimate sd - 1 A 28.39 14.9 - 2 B 7.94 10.2 - 3 C -2.75 16.3 - 4 D 6.82 11.0 - 5 E -0.64 9.4 - 6 F 0.63 11.4 - 7 G 18.01 10.4 - 8 H 12.16 17.6 -\end{Code} -For modeling these data, we use a hierarchical model as proposed by \citeauthor{Gelman:2003} (\citeyear{Gelman:2003}, Section 5.5). -We assume a normal distribution for the observed estimate for each school with -mean \verb+theta+ and inverse-variance \verb+tau.y+. -The inverse-variance is given as $1/\verb+sigma.y+^{2}$ and its prior distribution is uniform on (0,1000). For the mean -\verb+theta+, we employ another normal distribution with mean \verb+mu.theta+ and inverse-variance \verb+tau.theta+. For -their prior distributions, see the following \WinBUGS{} code: - - -\begin{Code} - model { - for (j in 1:J) - { - y[j] ~ dnorm (theta[j], tau.y[j]) - theta[j] ~ dnorm (mu.theta, tau.theta) - tau.y[j] <- pow(sigma.y[j], -2) - } - mu.theta ~ dnorm (0.0, 1.0E-6) - tau.theta <- pow(sigma.theta, -2) - sigma.theta ~ dunif (0, 1000) - } -\end{Code} -This model must be stored in a separate file, e.g.~\file{schools.bug}\footnote{Emacs Speaks Statistics (ESS) -by \cite{rossini04}, a package available with Gnu Emacs \citep{stallmann99}, -recognizes and properly formats Bugs model files that have the .bug extension.}, -in an appropriate directory, say \path{c:/schools/}. -In \R{} the user must prepare the data inputs the \verb+bugs()+ function needs. -This can be a list containing the name of each data vector, e.g. -\begin{Code} - > J <- nrow(schools) - > y <- schools$estimate - > sigma.y <- schools$sd - > data <- list ("J", "y", "sigma.y") -\end{Code} -Using these data and the model file, we can run an MCMC simulation to get estimates for \verb+theta+, -\verb+mu.theta+ and \verb+sigma.theta+. Before running, the user must decide how many chains to be run -(\verb+n.chain = 3+) for how many iterations (\verb+n.iter = 1000+). -If the length of burn-in is not specified, \verb+n.burnin = floor(n.iter/2)+ is used, that is, 500 in this example. -Additionally, the user must specify initial values for the chains, for example by writing a function. This can be done by -\begin{Code} - > inits <- function(){ - + list(theta = rnorm(J, 0, 100), mu.theta = rnorm(1, 0, 100), - + sigma.theta = runif(1, 0, 100)) - + } -\end{Code} -Now, the user can start the MCMC simulation by typing -\begin{Code} - > schools.sim <- bugs(data, inits, model.file = "c:/schools/schools.bug", - + parameters = c("theta", "mu.theta", "sigma.theta"), - + n.chains = 3, n.iter = 1000, - + bugs.directory = "c:/Program Files/WinBUGS14/") -\end{Code} -in \R{}.\label{schoolssim} The argument \verb+bugs.directory+ must point to the directory -where \WinBUGS{} has been installed. -For other available arguments, see Appendix \ref{Doc}. - -The results in objects \verb+schools.sim+ can conveniently be printed by \verb+print(schools.sim)+. -The generic function \verb+print()+ calls the print method for an object of class \verb+bugs+ -provided by \RW{}. -For this example, you will get something like - -\small -\begin{Code} - > print(schools.sim) - Inference for Bugs model at "c:/schools/schools.bug" - 3 chains, each with 1000 iterations (first 500 discarded) - n.sims = 1500 iterations saved - mean sd 2.5% 25% 50% 75% 97.5% Rhat n.eff - theta[1] 11.1 9.1 -3.0 5.0 10.0 16.0 31.8 1.1 39 - theta[2] 7.6 6.6 -4.7 3.3 7.8 11.6 21.1 1.1 42 - theta[3] 5.7 8.4 -12.5 0.6 6.1 10.8 21.8 1.0 150 - theta[4] 7.1 7.0 -6.6 2.7 7.2 11.5 21.0 1.1 42 - theta[5] 5.1 6.8 -9.5 0.7 5.2 9.7 18.1 1.0 83 - theta[6] 5.7 7.3 -9.7 1.0 6.2 10.2 20.0 1.0 56 - theta[7] 10.4 7.3 -2.1 5.3 9.8 15.3 25.5 1.1 27 - theta[8] 8.3 8.4 -6.6 2.8 8.1 12.7 26.2 1.0 64 - mu.theta 7.6 5.9 -3.0 3.7 8.0 11.0 19.5 1.1 35 - sigma.theta 6.7 5.6 0.3 2.8 5.1 9.2 21.2 1.1 46 - deviance 60.8 2.5 57.0 59.1 60.2 62.1 66.6 1.0 170 - pD = 3 and DIC = 63.8 (using the rule, pD = var(deviance)/2) - - For each parameter, n.eff is a crude measure of effective sample size, - and Rhat is the potential scale reduction factor (at convergence, Rhat=1). - DIC is an estimate of expected predictive error (lower deviance is better). -\end{Code} -\normalsize -Additionally, the user can generate a plot of the results by typing \verb+plot(schools.sim)+. -The resulting plot is given in Figure~\ref{plot}. -\begin{figure}[t] -\begin{center} -\fbox{ -\includegraphics[width=0.9\textwidth]{plot} -} \caption{\label{plot}Plot produced by \RW{} package for the schools example. } -\end{center} -\end{figure} -In this plot, the left column shows a quick -summary of inference and convergence ($\widehat{R}$ is close to 1.0 for all parameters, indicating good mixing of -the three chains and thus approximate convergence); and the right column shows inferences for each set of -parameters. As can be seen in the right column, \RW{} uses the parameter names in \WinBUGS{} to structure the -output into scalar, vector, and arrays of parameters, in addition to storing the parameters as a long vector. - -For the interpretation of these results see \citeauthor{Gelman:2003} (\citeyear{Gelman:2003}, Section 5.5). - -\subsection{Leukaemia registration data}\label{Leukaemia2} -The leukaemia registration data (see Section \ref{Leukaemia}) are used to show data modeling and output reading -into \R{} using the \pkg{coda} package. A simple model for these data looks as follows: -\begin{Code} -model{ - beta.0 ~ dgamma(a.0, tau.0) - beta.benz ~ dgamma(a.benz, tau.benz) - a.0 <- 0.575 - tau.0 <- a.0*2 - a.benz <- 0.575 - tau.benz <- a.benz*2 -\end{Code} -\clearpage -\begin{Code} - for (i in 1:I) - { - count[i] ~ dpois(lambda[i]) - lambda[i] <- p[i]*expect[i] - for (j in 1:J) - { - prop[j,i] <- gamma[j,i]*(benz[j] - benzbar) - } - p[i]<- beta.0 + beta.benz*sum(prop[,i]) - } - } -\end{Code} -Here \verb+count+ denotes the number of observed incidences of childhood leukaemia in ward~\verb+i+. These are -assumed to be Poisson distributed with mean \verb+lambda+ depending on the number of expected cases \verb+expect+ -in ward \verb+i+ and an area-specific risk rate \verb+p+. For calculation of this area specific risk rate we use -an intercept \verb+beta.0+ and a term depending on the weighted sum of benzene emissions \verb+benz+ in each grid -cell \verb+j+. The weights are chosen proportional to the amount of area that ward \verb+i+ and grid cell \verb+j+ have -in common. - -In \R{} we can define all these data and then initialize the model. The data needed for this example are -\begin{description} -\item[\tt{benzbar}:] arithmetic mean of all benzene values, -\item[\tt{benz}:] a vector containing benzene emissions of all 2132 grid cells, -\item[\tt{expect}:] expected number of cases of childhood leukaemia in each of the 873 wards, -\item[\tt{count}:] observed number of childhood leukaemia in these wards, -\item[\tt{gamma}:] a $2132\times 873$ matrix containing the amount of area each grid cell and each ward have in common, -\item[\tt{J}:] total number of grid cells, i.e.~2132, and -\item[\tt{I}:] total number of ward cells, i.e.~873. -\end{description} -The parameters we want to store are regression coefficients \verb+beta.0+ and \verb+beta.benz+ as well as -\verb+p+, the area specific relative risk compared to the reference rate. This reference rate was used to -calculate the expected number of cases in each ward. - -Since we want to use the \pkg{coda} package for reading the data into \WinBUGS{}, we specify \verb+codaPkg = TRUE+ -in the \verb+bugs()+ call: -\begin{Code} - > data <- list(benzbar = mean(benz), benz = benz, expect = expect, - + count = count, gamma = gamma, J = J, I = I) - > parameters <- c("beta.0", "beta.benz", "p") - > inits1 <- list(beta.0 = 1, beta.benz = 1) - > inits2 <- list(beta.0 = 0.5, beta.benz = 0.5) - > inits <- list(inits1, inits2) - > model <- bugs(data, inits, parameters, model.file = "c:/model.bug", - + n.chains = 2, n.iter = 8000, n.burnin = 5000, n.thin = 1, - + codaPkg = TRUE, bugs.directory = "c:/Program Files/WinBUGS14/") -\end{Code} - -\clearpage -Starting with, e.g.,\label{codaexample} -\begin{Code} - > library("coda") - > codaobject <- read.bugs(model) - > plot(codaobject) -\end{Code} -it is now possible to use the \pkg{coda} package for output analyses. - - -\section*{Acknowledgments} -The work of Uwe Ligges has been supported by the Deutsche Forschungsgemeinschaft, -Sonderforschungsbereich 475. -The work of Andrew Gelman has been supported by the U.S. National Science Foundation. - -\bibliography{literatur} - -\clearpage -\begin{appendix} -\section[Help page for the function bugs()]{Help page for the function \code{bugs()}\label{Doc}} -\small -This help page has been shortened. -\input{bugs} -\end{appendix} -\end{document} Copied: trunk/R2WinBUGS/vignettes/R2WinBUGS.Rnw (from rev 255, trunk/R2WinBUGS/inst/doc/R2WinBUGS.Rnw) =================================================================== --- trunk/R2WinBUGS/vignettes/R2WinBUGS.Rnw (rev 0) +++ trunk/R2WinBUGS/vignettes/R2WinBUGS.Rnw 2013-04-07 17:24:24 UTC (rev 258) @@ -0,0 +1,506 @@ +%\VignetteIndexEntry{R2WinBUGS} +\documentclass{Z} +\usepackage{RdRW,thumbpdf} +\newcommand{\WinBUGS}{{\proglang{WinBUGS}}{}} +\newcommand{\RW}{{\pkg{R2WinBUGS}}{}} +\renewcommand{\R}{{\proglang{R}}{}} +\setlength{\textheight}{23.5cm} + +\title{\RW{}:\protect\linebreak A Package for Running \WinBUGS{} from \R{}} +\author{Sibylle Sturtz\thanks{\email{st...@st...}}\\Fachbereich Statistik\\Universit\"at Dortmund\\Germany + \And + Uwe Ligges\thanks{\email{li...@st...}}\\Fachbereich Statistik\\Universit\"at Dortmund\\Germany + \And + Andrew Gelman\thanks{\email{ge...@st...}}\\Department of Statistics\\Columbia University\\USA +} +\Plainauthor{Sibylle Sturtz, Uwe Ligges, Andrew Gelman} +\Plaintitle{R2WinBUGS: A Package for Running WinBUGS from R} + +\Abstract{ +The \RW{} package provides convenient functions to call \WinBUGS{} from \R{}. It +automatically writes the data and scripts in a format readable by \WinBUGS{} for processing in batch mode, which +is possible since version 1.4. After the \WinBUGS{} process has finished, it is possible either to read the +resulting data into \R{} by the package itself---which gives a compact graphical summary of inference and +convergence diagnostics---or to use the facilities of the \pkg{coda} package for further analyses of the +output. Examples are given to demonstrate the usage of this package. +} + +\Keywords{\R{}, \WinBUGS{}, interface, MCMC} +\Plainkeywords{R, WinBUGS, interface, MCMC} + +\begin{document} +An earlier version of this vignette has been published by the Journal of Statistical Software:\\ +Sturtz S, Ligges U, Gelman A (2005): +``\RW{}: A Package for Running \WinBUGS{} from \R{}.'' +{\em Journal of Statistical Software}, 12(3), 1--16. + + +\section{Introduction}\label{Introduction} +The usage of Markov chain Monte Carlo (MCMC) methods became very popular within the last decade. \WinBUGS{} +\citep[\textbf{B}ayesian inference \textbf{U}sing \textbf{G}ibbs \textbf{S}ampling, ][] +{Spiegelhalter;Thomas;Best:2003} is a popular software for analyzing complex statistical models using MCMC +methods. This software uses Gibbs sampling \citep{Geman;Geman:1984,Gelfand;Smith:1990,Casella;George:1992} and the +Metropolis algorithm \citep{Metropolis;Rosenbluth;Rosenbluth;Teller;Teller:1953} +to generate a Markov chain by sampling from full conditional +distributions. +The \WinBUGS{} software is available for free +at \url{http://www.mrc-bsu.cam.ac.uk/bugs/}. +An introduction to MCMC methods is given in \cite{Gilks;Richardson;Spiegelhalter:1996}. + +Using \WinBUGS{}, the user must specify the model to run, and to load data and initial values for a specified +number of Markov chains. Then it is possible to run the Markov chain(s) and to save the results for the parameters +the user is interested in. Summary statistics of these data, convergence diagnostics, kernel estimates +etc.\ are available as well. +Nevertheless, some users of this software might be interested in saving the output and reading it into \R{} +\citep{RCore:2004} for further analyses. +\WinBUGS{} 1.4 comes with the ability to run the software in batch mode using scripts. + +The \RW{} package makes use of this feature and provides the tools to call \WinBUGS{} +directly after data manipulation in \R{}. Furthermore, it is possible to +work with the results after importing them back into \R{} again, for example to create posterior predictive simulations or, more generally, graphical displays of data and posterior simulations \citep{gelman:2004}. +Embedding in R can also be useful for frequently changed data or processing a bunch of data sets, +because it is much more convenient to use some \R{} functions (possibly within a loop) +rather than using ``copy \& paste'' to update data in \WinBUGS{} each time; however difficulties have been encountered in this area because both \R{} and \WinBUGS{} can lock up RAM in the Windows operating system. + +\R{} is a ``language for data analysis and graphics'' and an open source and +freely available statistical software package implementing that language, see \url{http://www.R-project.org/}. +Historically, \R{} is an implementation of the award-winning \proglang{S} +language and system \citep{becker:1984r,becker:1988r,chambers:1992,chambers:1998}. +\R{} and \RW{} are available from \emph{CRAN} (Comprehensive \R{} Archive Network), +i.e., \url{http://CRAN.R-Project.org} or one of its mirrors. +\RW{} could be ported to the commercial \proglang{S} implementation +\textsc{S-Plus}. Minor adaptions would be needed since \textsc{S-Plus} +lacks some of \R{}'s functions and capabilities. +If an internet connection is available, \RW{} can be installed by typing +\verb+install.packages("R2WinBUGS")+ at the \R{} command prompt. +Do not forget to load the package with \verb+library("R2WinBUGS")+. + +The package \pkg{coda} by \cite{Plummer;Best;Cowles;Vines:2004} is very useful for the analysis of \WinBUGS{}' +output, the reader might want to install this package as well. The CRAN package \pkg{boa} (Bayesian Output +Analysis Program) by \cite{Smith:2004} has similar aims. +\proglang{JAGS} (Just Another Gibbs Sampler) +by \cite{Plummer:2003} is a program for analysis of Bayesian hierarchical models using Gibbs sampling that aims for +the same functionality as classic \proglang{BUGS}. \proglang{JAGS} is developed to work closely together with \R{} and +the \pkg{coda} package. + +%% Revision 2005-01-10 start +A new and completely revised version of WinBUGS called \proglang{OpenBUGS} \citep{Spiegelhalter;Thomas;Best;Lunn:2004} +was lately published under the terms of the GPL. +\proglang{OpenBUGS} is also expected to run under Linux. +It provides a much more flexible API on which ``BRugs'' is based including +a dynamic link library, incorporating a component loader +that allows \R{} to make use of \proglang{OpenBUGS} components. +OpenBUGS is still in development and suffers frequent crashes. +As OpenBUGS becomes more reliable, +it is planned to merge ``BRugs'' and \RW{} into one \R{} package. +%% Revision 2005-01-10 end + +For other packages and projects on spatial statistics +related to \R{}, follow the link to ``\R{} spatial projects'' at CRAN. + +In this paper, we give two examples, involving educational testing experiments in schools (cf.~Section~\ref{School}), +and incidence of childhood leukaemia depending on benzene emissions (cf.~Section~\ref{Leukaemia}). Details on the +functions of \RW{} are given in Section~\ref{Programming}. These functions automatically write the data and a +script in a format readable by \WinBUGS{} for processing in batch mode, and call \WinBUGS{} from \R{}. After the +\WinBUGS{} process has finished, it is possible either to read the resulting data into \R{} by the package itself +or to use the facilities of the \pkg{coda} package for further analyses of the output. In Section~\ref{Example2}, +we demonstrate how to apply the functions provided by \RW{} on the examples' data, and how to analyze the output +both with package \pkg{coda} and with \RW{}'s methods to \verb+plot()+ and \verb+print()+ the output. + + +\section{Examples}\label{Examples} +In this Section, we introduce two examples which will be continued in Section~\ref{Example2}. + +\subsection{Schools data}\label{School} +The Scholastic Aptitude Test (SAT) measures the aptitude of high-schoolers in order to help colleges to make +admissions decisions. It is divided into two parts, verbal (SAT-V) and mathematical (SAT-M). +Our data comes from the SAT-V (Scholastic Aptitude Test-Verbal) on eight different high schools, from an experiment conducted in the late 1970s. +SAT-V is a standard multiple choice test administered by the Educational Testing Service. +This Service was interested in the effects of coaching programs for each of the selected schools. + +The study included coached and uncoached pupils, about sixty in each of the eight different schools; see +\cite{Rubin:1981}. All of them had already taken the PSAT (Preliminary SAT) which results were used as covariates. +%Even if the test is constructed to be resistant to short-term +%efforts directed specifically toward improving test performance, each of the schools is successful at increasing +%SAT scores. +For each school, the estimated treatment effect and the standard error of the effect estimate are given. +These are calculated by an analysis of covariance adjustment appropriate for a completely randomized experiment +\citep{Rubin:1981}. This example was analyzed using a hierarchical normal model in \cite{Rubin:1981} and +\citeauthor{Gelman:2003} (\citeyear{Gelman:2003}, Section 5.5). + +\subsection{Leukaemia registration data}\label{Leukaemia} +Spatial data usually arises on different, non-nesting spatial scales. One example is childhood leukaemia +registration data analyzed by \cite{Best;Cockings;Bennett;Wakefield;Elliot:2001} +using ecologic regression. Data are given for Greater London bounded by the M25 orbital motorway. +%% Revision 2005-01-10 start +The data are not available as an example in \RW{} but we use the example here +to illustrate +alternative calls to the \verb+bugs()+ function and output analysis using the \pkg{coda} package. +%% Revision 2005-01-10 end + +The observed number of leukaemia cases among children under 15 years old is given at ward level. Census wards are +administrative areas containing approximately 5000 to 10\,000 people. Central London is divided into 873 wards. The +number of incident cases of leukaemia in children is available from 1985 until 1996 from the Office of National +Statistics and the Thames Cancer Registry. A plot of these numbers is given in Figure~\ref{observed}. + +\begin{figure} +\begin{center} +\includegraphics[width=0.85\textwidth]{countssw} +\caption{\label{observed}Observed number of cases of childhood leukaemia in 1985--1996} +\end{center} +\end{figure} + +Additionally, the number of expected cases (cf.~Fig.~\ref{expected}) is calculated on the same +resolution using population numbers for different age-sex-strata and the national leukaemia +rate for the corresponding strata, for details see \cite{Best;Cockings;Bennett;Wakefield;Elliot:2001}. + +\begin{figure} +\begin{center} +\includegraphics[width=0.85\textwidth]{expectedsw} +\caption{\label{expected}Expected number of cases of childhood leukaemia in 1985--1996}%, as obtained from a simple demographic model} +\end{center} +\end{figure} + +It is assumed that benzene emissions have an effect on the incidence rate of leukaemia. Benzene emission rates are +available in tonnes per year from an atmospheric emissions inventory for London +\citep{Buckingham;Clewley;Hutchinson;Sadler;Shah:1997} produced by the London Research Centre. They are provided +at 1km $\times$ 1km grid cells, giving 2132 grid cells in total. +Their spatial distribution is shown in Figure~\ref{benzene}. + +\begin{figure} +\begin{center} +\includegraphics[width=0.9\textwidth]{benzolsw} +\caption{\label{benzene}Benzene emissions in tonnes per year} +\end{center} +\end{figure} + +For further details on the data see \cite{Best;Cockings;Bennett;Wakefield;Elliot:2001}. + +We model these data by Poisson-Gamma models introduced by \cite{Best;Ickstadt;Wolpert:2000} using \WinBUGS{}. +A linking matrix containing information which grid cell belongs to which ward +and to which amount is required. This matrix is calculated using \R{}. +Unfortunately, \WinBUGS{} does not support a list format such as directly produced by \R{}. +Therefore, the data must be provided as a matrix with 2132 rows and 873 columns (or vice versa). +Most of the entries of this matrix are zeroes, but using \verb+dump()+ to export it from \R{} +yields in a file size of 14.2~MB. +Unfortunately, opening a file of such size really slows \WinBUGS{} down, +and it was not even possible on some of our PCs. +Importing data written by our \RW{} package does not make any problems using the batch mode, +probably due to memory management issues in \WinBUGS{}. + + +\section{Implementation}\label{Programming} +The implementation of the \RW{} package is straightforward. +The ``main'' function \verb+bugs()+ is intended to be called by the user. +In principle, it is a wrapper for several other functions called therein step by step as follows: +\begin{enumerate} + \item \verb+bugs.data.inits()+ writes the data files \file{data.txt}, and \file{inits1.txt}, \file{inits2.txt}, ... + into the working directory. These files will be used by \WinBUGS{} during batch processing. + + In particular, input for \WinBUGS{} must not exceed a certain number of digits. + Moreover, it needs an \verb+E+ instead of an \verb+e+ in scientific notation. + Scientific notation is particularly desirable because of the ``number of digits'' limitation. + The default (\verb+digits = 5+) is to, e.g., reformat the number \verb+123456.789+ to \verb@1.23457E+05@. + \item \verb+bugs.script()+ writes the file \file{script.txt} that is used by \WinBUGS{} for batch processing. + \item \verb+bugs.run()+ updates the lengths of the adaptive phases in the \WinBUGS{} registry + (using a function \verb+bugs.update.settings()+), + calls \WinBUGS{}, and runs it in batch mode with \file{script.txt}. + \item \verb+bugs.sims()+ is only called if the argument \verb+codaPkg+ has been set to \verb+FALSE+ (the default). + Otherwise \verb+bugs()+ returns the filenames of stored data. These can, for example, + be imported by package \pkg{coda} (see the example in Section~\ref{Leukaemia2}, page~\pageref{codaexample}), + which provides functions for convergence diagnostics, + calculation of Monte Carlo estimates, trace plots, and so forth. + + The function \verb+bugs.sims()+ reads simulations from \WinBUGS{} into \R{} (not necessarily called by \verb+bugs()+ + itself), formats them, + monitors convergence, performs convergence checks, and computes medians and quantiles. + It also prepares the output for \verb+bugs()+ itself. +\end{enumerate} +These functions are not intended to be called by the user directly. +Arguments are passed from \verb+bugs()+ to the other functions, if appropriate. +A shortened help file of \verb+bugs()+ listing all arguments is given in Appendix~\ref{Doc}; +for the full version type \verb+?bugs+ in \R{} after having installed and loaded the package \RW{} +(see Section~\ref{Introduction}). + +%\newpage +As known from \WinBUGS{}, one must specify the \verb+data+ in form of a list, with list names equal to the names +of data in the corresponding \WinBUGS{} model. Alternatively, it is possible to specify a vector or list of names +(of mode \verb+character+). In that case objects of that names are looked for in the environment in which +\verb+bugs()+ has been called (usually that is the user's Workspace, \verb+.GlobalEnv+). +%% Revision 2005-01-10 start +If data have already been written in a file called \file{data.txt} to the working directory, +it is possible to specify \verb+data = "data.txt"+. +%% Revision 2005-01-10 end +One will usually want to supply initial values. +This can be done either in the form of a function \verb+inits()+ that creates these values, so that +different chains can be automatically initialized at different points (see Section \ref{School2}), or by specifying them +directly (see Section \ref{Leukaemia2}). +If \verb+inits()+ is not specified, +\verb+bugs()+ just uses the starting values created by \WinBUGS{}; but in practice \WinBUGS{} can crash when +reasonable initial values are not specified, and so we recommend constructing a simple \verb+inits()+ function to +simulate reasonable starting points \cite[Section C.2]{Gelman:2003}. It is also necessary to specify which +parameters should be saved for monitoring by specifying \verb+parameters.to.save+. + +The user might also want to change the defaults for the length of the burn-in (\verb+n.burnin+, which defaults to half the length of the chain) +period for every MCMC run and the number of iterations (\verb+n.iter+, default value 3) +that are used to calculate Monte Carlo estimates. +%SS: Achtung: n.iter=n.burn.in + length of stored chain! +The specification of a thinning parameter (\verb+n.thin+) is possible as well; this is useful when the number of parameters is large, to keep the saved output to a reasonably-sized R object. In the default setting, the chains are thinned enough so that approximately 1000 simulation draws are saved. + +By setting the argument \verb+debug = TRUE+, +\WinBUGS{} remains open after the run. +This way it is possible to find errors in the code or the data structure, +or even to work with that software as in a usual run. + +It is possible to run one or more Markov chains. +The number of chains (\verb+n.chains+) must be specified together with the chains' initial values (\verb+inits+). +If more than one Markov chain is requested and \verb+codaPkg+ is set to \verb+FALSE+, the convergence diagnostic +$\hat{R}$ \citep{Brooks;Gelman:1998} is calculated by \verb+bugs.sims()+ for each of the saved parameters. + +%% Revision 2005-01-10 start +Since the communication between \WinBUGS{} and \R{} is based on files, +rather huge files will be saved in the working directory by the \verb+bugs()+ call, +either files to be read in by \verb+bugs()+ itself, or by the \pkg{coda} package. +The user might want to delete those files after the desired contents has been imported into \R{}, +and save those objects, e.g., as compressed \R{} data files. +%% Revision 2005-01-10 end + +The function \verb+bugs()+ returns a rather complex object of class \verb+bugs+, +if called with argument \verb+codaPkg = FALSE+. +In order to look at the structure of such an object, type \verb+str(objectname)+. +For convenience, \RW{} provides methods corresponding to class \verb+bugs+ for +the generic functions \verb+print()+ and \verb+plot()+. + +So that user will not be overwhelmed with information; summaries of the output are provided by the +\verb+print()+ method. That is, some parameters of the \verb+bugs()+ call are summarized, and mean, +standard deviation, several quantiles of the parameters and convergence diagnostics based on \cite{Gelman;Rubin:1992} +are printed. See the example in +Section~\ref{School2}, page~\pageref{schoolssim}, for a typical output. As with \cite{Spiegelhalter;Best;Carlin;vdLinde:2002}, +%\pagebreak + the DIC computed by \verb+bugs.sims()+ is defined as the posterior mean +of the deviance plus $p_D$, the estimated effective number of parameters in the posterior distribution. We define +$p_D$ as half the posterior variance of the deviance and estimate it as half the average of the within-chain +variances of the deviance.\footnote{In contrast, \cite{Spiegelhalter;Best;Carlin;vdLinde:2002}, + and WinBUGS, define $p_D$ as the +posterior mean of the deviance evaluated at the posterior mean of the parameter values. We cannot use that +definition because the deviance function is not available to our program, which calls \WinBUGS{} from the +``outside''. Both definitions of $p_D$---ours and that introduced by \cite{Spiegelhalter;Best;Carlin;vdLinde:2002}---can be +derived from the asymptotic $\chi^2$ distribution of the deviance relative to its minimum \citep[Section 6.7]{Gelman:2003}. +We make no claim that our measure of $p_D$ is superior to that of \cite{Spiegelhalter;Best;Carlin;vdLinde:2002}; +we choose this measure purely because it is computationally possible given what is available to us from the \WinBUGS{} output.} + + +The \verb+plot()+ for objects of class \verb+bugs+ +provides information condensed in some plots conveniently arranged within the same graphics device. +For an example, see Figure~\ref{plot} in Section~\ref{School2}. It is intended to adapt this function to work with MCMC output in general, even if obtained from software other than WinBUGS. + + + +\section{Examples continued}\label{Example2} +The Examples introduced in Section~\ref{Example2} are continued in this Section. +We apply the functions provided by \RW{} +to the examples' data and analyze the output. + +\subsection{Schools data}\label{School2} +Schools example data (see Section~\ref{School}) are available with the \RW{} package: +\begin{Code} + > data(schools) + > schools + school estimate sd + 1 A 28.39 14.9 + 2 B 7.94 10.2 + 3 C -2.75 16.3 + 4 D 6.82 11.0 + 5 E -0.64 9.4 + 6 F 0.63 11.4 + 7 G 18.01 10.4 + 8 H 12.16 17.6 +\end{Code} +For modeling these data, we use a hierarchical model as proposed by \citeauthor{Gelman:2003} (\citeyear{Gelman:2003}, Section 5.5). +We assume a normal distribution for the observed estimate for each school with +mean \verb+theta+ and inverse-variance \verb+tau.y+. +The inverse-variance is given as $1/\verb+sigma.y+^{2}$ and its prior distribution is uniform on (0,1000). For the mean +\verb+theta+, we employ another normal distribution with mean \verb+mu.theta+ and inverse-variance \verb+tau.theta+. For +their prior distributions, see the following \WinBUGS{} code: + + +\begin{Code} + model { + for (j in 1:J) + { + y[j] ~ dnorm (theta[j], tau.y[j]) + theta[j] ~ dnorm (mu.theta, tau.theta) + tau.y[j] <- pow(sigma.y[j], -2) + } + mu.theta ~ dnorm (0.0, 1.0E-6) + tau.theta <- pow(sigma.theta, -2) + sigma.theta ~ dunif (0, 1000) + } +\end{Code} +This model must be stored in a separate file, e.g.~\file{schools.bug}\footnote{Emacs Speaks Statistics (ESS) +by \cite{rossini04}, a package available with Gnu Emacs \citep{stallmann99}, +recognizes and properly formats Bugs model files that have the .bug extension.}, +in an appropriate directory, say \path{c:/schools/}. +In \R{} the user must prepare the data inputs the \verb+bugs()+ function needs. +This can be a list containing the name of each data vector, e.g. +\begin{Code} + > J <- nrow(schools) + > y <- schools$estimate + > sigma.y <- schools$sd + > data <- list ("J", "y", "sigma.y") +\end{Code} +Using these data and the model file, we can run an MCMC simulation to get estimates for \verb+theta+, +\verb+mu.theta+ and \verb+sigma.theta+. Before running, the user must decide how many chains to be run +(\verb+n.chain = 3+) for how many iterations (\verb+n.iter = 1000+). +If the length of burn-in is not specified, \verb+n.burnin = floor(n.iter/2)+ is used, that is, 500 in this example. +Additionally, the user must specify initial values for the chains, for example by writing a function. This can be done by +\begin{Code} + > inits <- function(){ + + list(theta = rnorm(J, 0, 100), mu.theta = rnorm(1, 0, 100), + + sigma.theta = runif(1, 0, 100)) + + } +\end{Code} +Now, the user can start the MCMC simulation by typing +\begin{Code} + > schools.sim <- bugs(data, inits, model.file = "c:/schools/schools.bug", + + parameters = c("theta", "mu.theta", "sigma.theta"), + + n.chains = 3, n.iter = 1000, + + bugs.directory = "c:/Program Files/WinBUGS14/") +\end{Code} +in \R{}.\label{schoolssim} The argument \verb+bugs.directory+ must point to the directory +where \WinBUGS{} has been installed. +For other available arguments, see Appendix \ref{Doc}. + +The results in objects \verb+schools.sim+ can conveniently be printed by \verb+print(schools.sim)+. +The generic function \verb+print()+ calls the print method for an object of class \verb+bugs+ +provided by \RW{}. +For this example, you will get something like + +\small +\begin{Code} + > print(schools.sim) + Inference for Bugs model at "c:/schools/schools.bug" + 3 chains, each with 1000 iterations (first 500 discarded) + n.sims = 1500 iterations saved + mean sd 2.5% 25% 50% 75% 97.5% Rhat n.eff + theta[1] 11.1 9.1 -3.0 5.0 10.0 16.0 31.8 1.1 39 + theta[2] 7.6 6.6 -4.7 3.3 7.8 11.6 21.1 1.1 42 + theta[3] 5.7 8.4 -12.5 0.6 6.1 10.8 21.8 1.0 150 + theta[4] 7.1 7.0 -6.6 2.7 7.2 11.5 21.0 1.1 42 + theta[5] 5.1 6.8 -9.5 0.7 5.2 9.7 18.1 1.0 83 + theta[6] 5.7 7.3 -9.7 1.0 6.2 10.2 20.0 1.0 56 + theta[7] 10.4 7.3 -2.1 5.3 9.8 15.3 25.5 1.1 27 + theta[8] 8.3 8.4 -6.6 2.8 8.1 12.7 26.2 1.0 64 + mu.theta 7.6 5.9 -3.0 3.7 8.0 11.0 19.5 1.1 35 + sigma.theta 6.7 5.6 0.3 2.8 5.1 9.2 21.2 1.1 46 + deviance 60.8 2.5 57.0 59.1 60.2 62.1 66.6 1.0 170 + pD = 3 and DIC = 63.8 (using the rule, pD = var(deviance)/2) + + For each parameter, n.eff is a crude measure of effective sample size, + and Rhat is the potential scale reduction factor (at convergence, Rhat=1). + DIC is an estimate of expected predictive error (lower deviance is better). +\end{Code} +\normalsize +Additionally, the user can generate a plot of the results by typing \verb+plot(schools.sim)+. +The resulting plot is given in Figure~\ref{plot}. +\begin{figure}[t] +\begin{center} +\fbox{ +\includegraphics[width=0.9\textwidth]{plot} +} \caption{\label{plot}Plot produced by \RW{} package for the schools example. } +\end{center} +\end{figure} +In this plot, the left column shows a quick +summary of inference and convergence ($\widehat{R}$ is close to 1.0 for all parameters, indicating good mixing of +the three chains and thus approximate convergence); and the right column shows inferences for each set of +parameters. As can be seen in the right column, \RW{} uses the parameter names in \WinBUGS{} to structure the +output into scalar, vector, and arrays of parameters, in addition to storing the parameters as a long vector. + +For the interpretation of these results see \citeauthor{Gelman:2003} (\citeyear{Gelman:2003}, Section 5.5). + +\subsection{Leukaemia registration data}\label{Leukaemia2} +The leukaemia registration data (see Section \ref{Leukaemia}) are used to show data modeling and output reading +into \R{} using the \pkg{coda} package. A simple model for these data looks as follows: +\begin{Code} +model{ + beta.0 ~ dgamma(a.0, tau.0) + beta.benz ~ dgamma(a.benz, tau.benz) + a.0 <- 0.575 + tau.0 <- a.0*2 + a.benz <- 0.575 + tau.benz <- a.benz*2 +\end{Code} +\clearpage +\begin{Code} + for (i in 1:I) + { + count[i] ~ dpois(lambda[i]) + lambda[i] <- p[i]*expect[i] + for (j in 1:J) + { + prop[j,i] <- gamma[j,i]*(benz[j] - benzbar) + } + p[i]<- beta.0 + beta.benz*sum(prop[,i]) + } + } +\end{Code} +Here \verb+count+ denotes the number of observed incidences of childhood leukaemia in ward~\verb+i+. These are +assumed to be Poisson distributed with mean \verb+lambda+ depending on the number of expected cases \verb+expect+ +in ward \verb+i+ and an area-specific risk rate \verb+p+. For calculation of this area specific risk rate we use +an intercept \verb+beta.0+ and a term depending on the weighted sum of benzene emissions \verb+benz+ in each grid +cell \verb+j+. The weights are chosen proportional to the amount of area that ward \verb+i+ and grid cell \verb+j+ have +in common. + +In \R{} we can define all these data and then initialize the model. The data needed for this example are +\begin{description} +\item[\tt{benzbar}:] arithmetic mean of all benzene values, +\item[\tt{benz}:] a vector containing benzene emissions of all 2132 grid cells, +\item[\tt{expect}:] expected number of cases of childhood leukaemia in each of the 873 wards, +\item[\tt{count}:] observed number of childhood leukaemia in these wards, +\item[\tt{gamma}:] a $2132\times 873$ matrix containing the amount of area each grid cell and each ward have in common, +\item[\tt{J}:] total number of grid cells, i.e.~2132, and +\item[\tt{I}:] total number of ward cells, i.e.~873. +\end{description} +The parameters we want to store are regression coefficients \verb+beta.0+ and \verb+beta.benz+ as well as +\verb+p+, the area specific relative risk compared to the reference rate. This reference rate was used to +calculate the expected number of cases in each ward. + +Since we want to use the \pkg{coda} package for reading the data into \WinBUGS{}, we specify \verb+codaPkg = TRUE+ +in the \verb+bugs()+ call: +\begin{Code} + > data <- list(benzbar = mean(benz), benz = benz, expect = expect, + + count = count, gamma = gamma, J = J, I = I) + > parameters <- c("beta.0", "beta.benz", "p") + > inits1 <- list(beta.0 = 1, beta.benz = 1) + > inits2 <- list(beta.0 = 0.5, beta.benz = 0.5) + > inits <- list(inits1, inits2) + > model <- bugs(data, inits, parameters, model.file = "c:/model.bug", + + n.chains = 2, n.iter = 8000, n.burnin = 5000, n.thin = 1, + + codaPkg = TRUE, bugs.directory = "c:/Program Files/WinBUGS14/") +\end{Code} + +\clearpage +Starting with, e.g.,\label{codaexample} +\begin{Code} + > library("coda") + > codaobject <- read.bugs(model) + > plot(codaobject) +\end{Code} +it is now possible ... [truncated message content] |
From: <li...@us...> - 2013-04-07 17:23:02
|
Revision: 257 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=257&view=rev Author: ligges Date: 2013-04-07 17:22:49 +0000 (Sun, 07 Apr 2013) Log Message: ----------- last committed did not complete, hence retry Added Paths: ----------- trunk/R2WinBUGS/vignettes/R2WinBUGS.Rnw trunk/R2WinBUGS/vignettes/RdRW.sty trunk/R2WinBUGS/vignettes/Z.cls trunk/R2WinBUGS/vignettes/benzolsw.pdf trunk/R2WinBUGS/vignettes/bugs.tex trunk/R2WinBUGS/vignettes/countssw.pdf trunk/R2WinBUGS/vignettes/expectedsw.pdf trunk/R2WinBUGS/vignettes/literatur.bib trunk/R2WinBUGS/vignettes/literatur.bst trunk/R2WinBUGS/vignettes/plot.pdf Removed Paths: ------------- trunk/R2WinBUGS/vignettes/R2WinBUGS.Rnw trunk/R2WinBUGS/vignettes/RdRW.sty trunk/R2WinBUGS/vignettes/Z.cls trunk/R2WinBUGS/vignettes/benzolsw.pdf trunk/R2WinBUGS/vignettes/bugs.tex trunk/R2WinBUGS/vignettes/countssw.pdf trunk/R2WinBUGS/vignettes/expectedsw.pdf trunk/R2WinBUGS/vignettes/literatur.bib trunk/R2WinBUGS/vignettes/literatur.bst trunk/R2WinBUGS/vignettes/plot.pdf Deleted: trunk/R2WinBUGS/vignettes/R2WinBUGS.Rnw =================================================================== --- trunk/R2WinBUGS/vignettes/R2WinBUGS.Rnw 2013-04-07 17:13:29 UTC (rev 256) +++ trunk/R2WinBUGS/vignettes/R2WinBUGS.Rnw 2013-04-07 17:22:49 UTC (rev 257) @@ -1,506 +0,0 @@ -%\VignetteIndexEntry{R2WinBUGS} -\documentclass{Z} -\usepackage{RdRW,thumbpdf} -\newcommand{\WinBUGS}{{\proglang{WinBUGS}}{}} -\newcommand{\RW}{{\pkg{R2WinBUGS}}{}} -\renewcommand{\R}{{\proglang{R}}{}} -\setlength{\textheight}{23.5cm} - -\title{\RW{}:\protect\linebreak A Package for Running \WinBUGS{} from \R{}} -\author{Sibylle Sturtz\thanks{\email{st...@st...}}\\Fachbereich Statistik\\Universit\"at Dortmund\\Germany - \And - Uwe Ligges\thanks{\email{li...@st...}}\\Fachbereich Statistik\\Universit\"at Dortmund\\Germany - \And - Andrew Gelman\thanks{\email{ge...@st...}}\\Department of Statistics\\Columbia University\\USA -} -\Plainauthor{Sibylle Sturtz, Uwe Ligges, Andrew Gelman} -\Plaintitle{R2WinBUGS: A Package for Running WinBUGS from R} - -\Abstract{ -The \RW{} package provides convenient functions to call \WinBUGS{} from \R{}. It -automatically writes the data and scripts in a format readable by \WinBUGS{} for processing in batch mode, which -is possible since version 1.4. After the \WinBUGS{} process has finished, it is possible either to read the -resulting data into \R{} by the package itself---which gives a compact graphical summary of inference and -convergence diagnostics---or to use the facilities of the \pkg{coda} package for further analyses of the -output. Examples are given to demonstrate the usage of this package. -} - -\Keywords{\R{}, \WinBUGS{}, interface, MCMC} -\Plainkeywords{R, WinBUGS, interface, MCMC} - -\begin{document} -An earlier version of this vignette has been published by the Journal of Statistical Software:\\ -Sturtz S, Ligges U, Gelman A (2005): -``\RW{}: A Package for Running \WinBUGS{} from \R{}.'' -{\em Journal of Statistical Software}, 12(3), 1--16. - - -\section{Introduction}\label{Introduction} -The usage of Markov chain Monte Carlo (MCMC) methods became very popular within the last decade. \WinBUGS{} -\citep[\textbf{B}ayesian inference \textbf{U}sing \textbf{G}ibbs \textbf{S}ampling, ][] -{Spiegelhalter;Thomas;Best:2003} is a popular software for analyzing complex statistical models using MCMC -methods. This software uses Gibbs sampling \citep{Geman;Geman:1984,Gelfand;Smith:1990,Casella;George:1992} and the -Metropolis algorithm \citep{Metropolis;Rosenbluth;Rosenbluth;Teller;Teller:1953} -to generate a Markov chain by sampling from full conditional -distributions. -The \WinBUGS{} software is available for free -at \url{http://www.mrc-bsu.cam.ac.uk/bugs/}. -An introduction to MCMC methods is given in \cite{Gilks;Richardson;Spiegelhalter:1996}. - -Using \WinBUGS{}, the user must specify the model to run, and to load data and initial values for a specified -number of Markov chains. Then it is possible to run the Markov chain(s) and to save the results for the parameters -the user is interested in. Summary statistics of these data, convergence diagnostics, kernel estimates -etc.\ are available as well. -Nevertheless, some users of this software might be interested in saving the output and reading it into \R{} -\citep{RCore:2004} for further analyses. -\WinBUGS{} 1.4 comes with the ability to run the software in batch mode using scripts. - -The \RW{} package makes use of this feature and provides the tools to call \WinBUGS{} -directly after data manipulation in \R{}. Furthermore, it is possible to -work with the results after importing them back into \R{} again, for example to create posterior predictive simulations or, more generally, graphical displays of data and posterior simulations \citep{gelman:2004}. -Embedding in R can also be useful for frequently changed data or processing a bunch of data sets, -because it is much more convenient to use some \R{} functions (possibly within a loop) -rather than using ``copy \& paste'' to update data in \WinBUGS{} each time; however difficulties have been encountered in this area because both \R{} and \WinBUGS{} can lock up RAM in the Windows operating system. - -\R{} is a ``language for data analysis and graphics'' and an open source and -freely available statistical software package implementing that language, see \url{http://www.R-project.org/}. -Historically, \R{} is an implementation of the award-winning \proglang{S} -language and system \citep{becker:1984r,becker:1988r,chambers:1992,chambers:1998}. -\R{} and \RW{} are available from \emph{CRAN} (Comprehensive \R{} Archive Network), -i.e., \url{http://CRAN.R-Project.org} or one of its mirrors. -\RW{} could be ported to the commercial \proglang{S} implementation -\textsc{S-Plus}. Minor adaptions would be needed since \textsc{S-Plus} -lacks some of \R{}'s functions and capabilities. -If an internet connection is available, \RW{} can be installed by typing -\verb+install.packages("R2WinBUGS")+ at the \R{} command prompt. -Do not forget to load the package with \verb+library("R2WinBUGS")+. - -The package \pkg{coda} by \cite{Plummer;Best;Cowles;Vines:2004} is very useful for the analysis of \WinBUGS{}' -output, the reader might want to install this package as well. The CRAN package \pkg{boa} (Bayesian Output -Analysis Program) by \cite{Smith:2004} has similar aims. -\proglang{JAGS} (Just Another Gibbs Sampler) -by \cite{Plummer:2003} is a program for analysis of Bayesian hierarchical models using Gibbs sampling that aims for -the same functionality as classic \proglang{BUGS}. \proglang{JAGS} is developed to work closely together with \R{} and -the \pkg{coda} package. - -%% Revision 2005-01-10 start -A new and completely revised version of WinBUGS called \proglang{OpenBUGS} \citep{Spiegelhalter;Thomas;Best;Lunn:2004} -was lately published under the terms of the GPL. -\proglang{OpenBUGS} is also expected to run under Linux. -It provides a much more flexible API on which ``BRugs'' is based including -a dynamic link library, incorporating a component loader -that allows \R{} to make use of \proglang{OpenBUGS} components. -OpenBUGS is still in development and suffers frequent crashes. -As OpenBUGS becomes more reliable, -it is planned to merge ``BRugs'' and \RW{} into one \R{} package. -%% Revision 2005-01-10 end - -For other packages and projects on spatial statistics -related to \R{}, follow the link to ``\R{} spatial projects'' at CRAN. - -In this paper, we give two examples, involving educational testing experiments in schools (cf.~Section~\ref{School}), -and incidence of childhood leukaemia depending on benzene emissions (cf.~Section~\ref{Leukaemia}). Details on the -functions of \RW{} are given in Section~\ref{Programming}. These functions automatically write the data and a -script in a format readable by \WinBUGS{} for processing in batch mode, and call \WinBUGS{} from \R{}. After the -\WinBUGS{} process has finished, it is possible either to read the resulting data into \R{} by the package itself -or to use the facilities of the \pkg{coda} package for further analyses of the output. In Section~\ref{Example2}, -we demonstrate how to apply the functions provided by \RW{} on the examples' data, and how to analyze the output -both with package \pkg{coda} and with \RW{}'s methods to \verb+plot()+ and \verb+print()+ the output. - - -\section{Examples}\label{Examples} -In this Section, we introduce two examples which will be continued in Section~\ref{Example2}. - -\subsection{Schools data}\label{School} -The Scholastic Aptitude Test (SAT) measures the aptitude of high-schoolers in order to help colleges to make -admissions decisions. It is divided into two parts, verbal (SAT-V) and mathematical (SAT-M). -Our data comes from the SAT-V (Scholastic Aptitude Test-Verbal) on eight different high schools, from an experiment conducted in the late 1970s. -SAT-V is a standard multiple choice test administered by the Educational Testing Service. -This Service was interested in the effects of coaching programs for each of the selected schools. - -The study included coached and uncoached pupils, about sixty in each of the eight different schools; see -\cite{Rubin:1981}. All of them had already taken the PSAT (Preliminary SAT) which results were used as covariates. -%Even if the test is constructed to be resistant to short-term -%efforts directed specifically toward improving test performance, each of the schools is successful at increasing -%SAT scores. -For each school, the estimated treatment effect and the standard error of the effect estimate are given. -These are calculated by an analysis of covariance adjustment appropriate for a completely randomized experiment -\citep{Rubin:1981}. This example was analyzed using a hierarchical normal model in \cite{Rubin:1981} and -\citeauthor{Gelman:2003} (\citeyear{Gelman:2003}, Section 5.5). - -\subsection{Leukaemia registration data}\label{Leukaemia} -Spatial data usually arises on different, non-nesting spatial scales. One example is childhood leukaemia -registration data analyzed by \cite{Best;Cockings;Bennett;Wakefield;Elliot:2001} -using ecologic regression. Data are given for Greater London bounded by the M25 orbital motorway. -%% Revision 2005-01-10 start -The data are not available as an example in \RW{} but we use the example here -to illustrate -alternative calls to the \verb+bugs()+ function and output analysis using the \pkg{coda} package. -%% Revision 2005-01-10 end - -The observed number of leukaemia cases among children under 15 years old is given at ward level. Census wards are -administrative areas containing approximately 5000 to 10\,000 people. Central London is divided into 873 wards. The -number of incident cases of leukaemia in children is available from 1985 until 1996 from the Office of National -Statistics and the Thames Cancer Registry. A plot of these numbers is given in Figure~\ref{observed}. - -\begin{figure} -\begin{center} -\includegraphics[width=0.85\textwidth]{countssw} -\caption{\label{observed}Observed number of cases of childhood leukaemia in 1985--1996} -\end{center} -\end{figure} - -Additionally, the number of expected cases (cf.~Fig.~\ref{expected}) is calculated on the same -resolution using population numbers for different age-sex-strata and the national leukaemia -rate for the corresponding strata, for details see \cite{Best;Cockings;Bennett;Wakefield;Elliot:2001}. - -\begin{figure} -\begin{center} -\includegraphics[width=0.85\textwidth]{expectedsw} -\caption{\label{expected}Expected number of cases of childhood leukaemia in 1985--1996}%, as obtained from a simple demographic model} -\end{center} -\end{figure} - -It is assumed that benzene emissions have an effect on the incidence rate of leukaemia. Benzene emission rates are -available in tonnes per year from an atmospheric emissions inventory for London -\citep{Buckingham;Clewley;Hutchinson;Sadler;Shah:1997} produced by the London Research Centre. They are provided -at 1km $\times$ 1km grid cells, giving 2132 grid cells in total. -Their spatial distribution is shown in Figure~\ref{benzene}. - -\begin{figure} -\begin{center} -\includegraphics[width=0.9\textwidth]{benzolsw} -\caption{\label{benzene}Benzene emissions in tonnes per year} -\end{center} -\end{figure} - -For further details on the data see \cite{Best;Cockings;Bennett;Wakefield;Elliot:2001}. - -We model these data by Poisson-Gamma models introduced by \cite{Best;Ickstadt;Wolpert:2000} using \WinBUGS{}. -A linking matrix containing information which grid cell belongs to which ward -and to which amount is required. This matrix is calculated using \R{}. -Unfortunately, \WinBUGS{} does not support a list format such as directly produced by \R{}. -Therefore, the data must be provided as a matrix with 2132 rows and 873 columns (or vice versa). -Most of the entries of this matrix are zeroes, but using \verb+dump()+ to export it from \R{} -yields in a file size of 14.2~MB. -Unfortunately, opening a file of such size really slows \WinBUGS{} down, -and it was not even possible on some of our PCs. -Importing data written by our \RW{} package does not make any problems using the batch mode, -probably due to memory management issues in \WinBUGS{}. - - -\section{Implementation}\label{Programming} -The implementation of the \RW{} package is straightforward. -The ``main'' function \verb+bugs()+ is intended to be called by the user. -In principle, it is a wrapper for several other functions called therein step by step as follows: -\begin{enumerate} - \item \verb+bugs.data.inits()+ writes the data files \file{data.txt}, and \file{inits1.txt}, \file{inits2.txt}, ... - into the working directory. These files will be used by \WinBUGS{} during batch processing. - - In particular, input for \WinBUGS{} must not exceed a certain number of digits. - Moreover, it needs an \verb+E+ instead of an \verb+e+ in scientific notation. - Scientific notation is particularly desirable because of the ``number of digits'' limitation. - The default (\verb+digits = 5+) is to, e.g., reformat the number \verb+123456.789+ to \verb@1.23457E+05@. - \item \verb+bugs.script()+ writes the file \file{script.txt} that is used by \WinBUGS{} for batch processing. - \item \verb+bugs.run()+ updates the lengths of the adaptive phases in the \WinBUGS{} registry - (using a function \verb+bugs.update.settings()+), - calls \WinBUGS{}, and runs it in batch mode with \file{script.txt}. - \item \verb+bugs.sims()+ is only called if the argument \verb+codaPkg+ has been set to \verb+FALSE+ (the default). - Otherwise \verb+bugs()+ returns the filenames of stored data. These can, for example, - be imported by package \pkg{coda} (see the example in Section~\ref{Leukaemia2}, page~\pageref{codaexample}), - which provides functions for convergence diagnostics, - calculation of Monte Carlo estimates, trace plots, and so forth. - - The function \verb+bugs.sims()+ reads simulations from \WinBUGS{} into \R{} (not necessarily called by \verb+bugs()+ - itself), formats them, - monitors convergence, performs convergence checks, and computes medians and quantiles. - It also prepares the output for \verb+bugs()+ itself. -\end{enumerate} -These functions are not intended to be called by the user directly. -Arguments are passed from \verb+bugs()+ to the other functions, if appropriate. -A shortened help file of \verb+bugs()+ listing all arguments is given in Appendix~\ref{Doc}; -for the full version type \verb+?bugs+ in \R{} after having installed and loaded the package \RW{} -(see Section~\ref{Introduction}). - -%\newpage -As known from \WinBUGS{}, one must specify the \verb+data+ in form of a list, with list names equal to the names -of data in the corresponding \WinBUGS{} model. Alternatively, it is possible to specify a vector or list of names -(of mode \verb+character+). In that case objects of that names are looked for in the environment in which -\verb+bugs()+ has been called (usually that is the user's Workspace, \verb+.GlobalEnv+). -%% Revision 2005-01-10 start -If data have already been written in a file called \file{data.txt} to the working directory, -it is possible to specify \verb+data = "data.txt"+. -%% Revision 2005-01-10 end -One will usually want to supply initial values. -This can be done either in the form of a function \verb+inits()+ that creates these values, so that -different chains can be automatically initialized at different points (see Section \ref{School2}), or by specifying them -directly (see Section \ref{Leukaemia2}). -If \verb+inits()+ is not specified, -\verb+bugs()+ just uses the starting values created by \WinBUGS{}; but in practice \WinBUGS{} can crash when -reasonable initial values are not specified, and so we recommend constructing a simple \verb+inits()+ function to -simulate reasonable starting points \cite[Section C.2]{Gelman:2003}. It is also necessary to specify which -parameters should be saved for monitoring by specifying \verb+parameters.to.save+. - -The user might also want to change the defaults for the length of the burn-in (\verb+n.burnin+, which defaults to half the length of the chain) -period for every MCMC run and the number of iterations (\verb+n.iter+, default value 3) -that are used to calculate Monte Carlo estimates. -%SS: Achtung: n.iter=n.burn.in + length of stored chain! -The specification of a thinning parameter (\verb+n.thin+) is possible as well; this is useful when the number of parameters is large, to keep the saved output to a reasonably-sized R object. In the default setting, the chains are thinned enough so that approximately 1000 simulation draws are saved. - -By setting the argument \verb+debug = TRUE+, -\WinBUGS{} remains open after the run. -This way it is possible to find errors in the code or the data structure, -or even to work with that software as in a usual run. - -It is possible to run one or more Markov chains. -The number of chains (\verb+n.chains+) must be specified together with the chains' initial values (\verb+inits+). -If more than one Markov chain is requested and \verb+codaPkg+ is set to \verb+FALSE+, the convergence diagnostic -$\hat{R}$ \citep{Brooks;Gelman:1998} is calculated by \verb+bugs.sims()+ for each of the saved parameters. - -%% Revision 2005-01-10 start -Since the communication between \WinBUGS{} and \R{} is based on files, -rather huge files will be saved in the working directory by the \verb+bugs()+ call, -either files to be read in by \verb+bugs()+ itself, or by the \pkg{coda} package. -The user might want to delete those files after the desired contents has been imported into \R{}, -and save those objects, e.g., as compressed \R{} data files. -%% Revision 2005-01-10 end - -The function \verb+bugs()+ returns a rather complex object of class \verb+bugs+, -if called with argument \verb+codaPkg = FALSE+. -In order to look at the structure of such an object, type \verb+str(objectname)+. -For convenience, \RW{} provides methods corresponding to class \verb+bugs+ for -the generic functions \verb+print()+ and \verb+plot()+. - -So that user will not be overwhelmed with information; summaries of the output are provided by the -\verb+print()+ method. That is, some parameters of the \verb+bugs()+ call are summarized, and mean, -standard deviation, several quantiles of the parameters and convergence diagnostics based on \cite{Gelman;Rubin:1992} -are printed. See the example in -Section~\ref{School2}, page~\pageref{schoolssim}, for a typical output. As with \cite{Spiegelhalter;Best;Carlin;vdLinde:2002}, -%\pagebreak - the DIC computed by \verb+bugs.sims()+ is defined as the posterior mean -of the deviance plus $p_D$, the estimated effective number of parameters in the posterior distribution. We define -$p_D$ as half the posterior variance of the deviance and estimate it as half the average of the within-chain -variances of the deviance.\footnote{In contrast, \cite{Spiegelhalter;Best;Carlin;vdLinde:2002}, - and WinBUGS, define $p_D$ as the -posterior mean of the deviance evaluated at the posterior mean of the parameter values. We cannot use that -definition because the deviance function is not available to our program, which calls \WinBUGS{} from the -``outside''. Both definitions of $p_D$---ours and that introduced by \cite{Spiegelhalter;Best;Carlin;vdLinde:2002}---can be -derived from the asymptotic $\chi^2$ distribution of the deviance relative to its minimum \citep[Section 6.7]{Gelman:2003}. -We make no claim that our measure of $p_D$ is superior to that of \cite{Spiegelhalter;Best;Carlin;vdLinde:2002}; -we choose this measure purely because it is computationally possible given what is available to us from the \WinBUGS{} output.} - - -The \verb+plot()+ for objects of class \verb+bugs+ -provides information condensed in some plots conveniently arranged within the same graphics device. -For an example, see Figure~\ref{plot} in Section~\ref{School2}. It is intended to adapt this function to work with MCMC output in general, even if obtained from software other than WinBUGS. - - - -\section{Examples continued}\label{Example2} -The Examples introduced in Section~\ref{Example2} are continued in this Section. -We apply the functions provided by \RW{} -to the examples' data and analyze the output. - -\subsection{Schools data}\label{School2} -Schools example data (see Section~\ref{School}) are available with the \RW{} package: -\begin{Code} - > data(schools) - > schools - school estimate sd - 1 A 28.39 14.9 - 2 B 7.94 10.2 - 3 C -2.75 16.3 - 4 D 6.82 11.0 - 5 E -0.64 9.4 - 6 F 0.63 11.4 - 7 G 18.01 10.4 - 8 H 12.16 17.6 -\end{Code} -For modeling these data, we use a hierarchical model as proposed by \citeauthor{Gelman:2003} (\citeyear{Gelman:2003}, Section 5.5). -We assume a normal distribution for the observed estimate for each school with -mean \verb+theta+ and inverse-variance \verb+tau.y+. -The inverse-variance is given as $1/\verb+sigma.y+^{2}$ and its prior distribution is uniform on (0,1000). For the mean -\verb+theta+, we employ another normal distribution with mean \verb+mu.theta+ and inverse-variance \verb+tau.theta+. For -their prior distributions, see the following \WinBUGS{} code: - - -\begin{Code} - model { - for (j in 1:J) - { - y[j] ~ dnorm (theta[j], tau.y[j]) - theta[j] ~ dnorm (mu.theta, tau.theta) - tau.y[j] <- pow(sigma.y[j], -2) - } - mu.theta ~ dnorm (0.0, 1.0E-6) - tau.theta <- pow(sigma.theta, -2) - sigma.theta ~ dunif (0, 1000) - } -\end{Code} -This model must be stored in a separate file, e.g.~\file{schools.bug}\footnote{Emacs Speaks Statistics (ESS) -by \cite{rossini04}, a package available with Gnu Emacs \citep{stallmann99}, -recognizes and properly formats Bugs model files that have the .bug extension.}, -in an appropriate directory, say \path{c:/schools/}. -In \R{} the user must prepare the data inputs the \verb+bugs()+ function needs. -This can be a list containing the name of each data vector, e.g. -\begin{Code} - > J <- nrow(schools) - > y <- schools$estimate - > sigma.y <- schools$sd - > data <- list ("J", "y", "sigma.y") -\end{Code} -Using these data and the model file, we can run an MCMC simulation to get estimates for \verb+theta+, -\verb+mu.theta+ and \verb+sigma.theta+. Before running, the user must decide how many chains to be run -(\verb+n.chain = 3+) for how many iterations (\verb+n.iter = 1000+). -If the length of burn-in is not specified, \verb+n.burnin = floor(n.iter/2)+ is used, that is, 500 in this example. -Additionally, the user must specify initial values for the chains, for example by writing a function. This can be done by -\begin{Code} - > inits <- function(){ - + list(theta = rnorm(J, 0, 100), mu.theta = rnorm(1, 0, 100), - + sigma.theta = runif(1, 0, 100)) - + } -\end{Code} -Now, the user can start the MCMC simulation by typing -\begin{Code} - > schools.sim <- bugs(data, inits, model.file = "c:/schools/schools.bug", - + parameters = c("theta", "mu.theta", "sigma.theta"), - + n.chains = 3, n.iter = 1000, - + bugs.directory = "c:/Program Files/WinBUGS14/") -\end{Code} -in \R{}.\label{schoolssim} The argument \verb+bugs.directory+ must point to the directory -where \WinBUGS{} has been installed. -For other available arguments, see Appendix \ref{Doc}. - -The results in objects \verb+schools.sim+ can conveniently be printed by \verb+print(schools.sim)+. -The generic function \verb+print()+ calls the print method for an object of class \verb+bugs+ -provided by \RW{}. -For this example, you will get something like - -\small -\begin{Code} - > print(schools.sim) - Inference for Bugs model at "c:/schools/schools.bug" - 3 chains, each with 1000 iterations (first 500 discarded) - n.sims = 1500 iterations saved - mean sd 2.5% 25% 50% 75% 97.5% Rhat n.eff - theta[1] 11.1 9.1 -3.0 5.0 10.0 16.0 31.8 1.1 39 - theta[2] 7.6 6.6 -4.7 3.3 7.8 11.6 21.1 1.1 42 - theta[3] 5.7 8.4 -12.5 0.6 6.1 10.8 21.8 1.0 150 - theta[4] 7.1 7.0 -6.6 2.7 7.2 11.5 21.0 1.1 42 - theta[5] 5.1 6.8 -9.5 0.7 5.2 9.7 18.1 1.0 83 - theta[6] 5.7 7.3 -9.7 1.0 6.2 10.2 20.0 1.0 56 - theta[7] 10.4 7.3 -2.1 5.3 9.8 15.3 25.5 1.1 27 - theta[8] 8.3 8.4 -6.6 2.8 8.1 12.7 26.2 1.0 64 - mu.theta 7.6 5.9 -3.0 3.7 8.0 11.0 19.5 1.1 35 - sigma.theta 6.7 5.6 0.3 2.8 5.1 9.2 21.2 1.1 46 - deviance 60.8 2.5 57.0 59.1 60.2 62.1 66.6 1.0 170 - pD = 3 and DIC = 63.8 (using the rule, pD = var(deviance)/2) - - For each parameter, n.eff is a crude measure of effective sample size, - and Rhat is the potential scale reduction factor (at convergence, Rhat=1). - DIC is an estimate of expected predictive error (lower deviance is better). -\end{Code} -\normalsize -Additionally, the user can generate a plot of the results by typing \verb+plot(schools.sim)+. -The resulting plot is given in Figure~\ref{plot}. -\begin{figure}[t] -\begin{center} -\fbox{ -\includegraphics[width=0.9\textwidth]{plot} -} \caption{\label{plot}Plot produced by \RW{} package for the schools example. } -\end{center} -\end{figure} -In this plot, the left column shows a quick -summary of inference and convergence ($\widehat{R}$ is close to 1.0 for all parameters, indicating good mixing of -the three chains and thus approximate convergence); and the right column shows inferences for each set of -parameters. As can be seen in the right column, \RW{} uses the parameter names in \WinBUGS{} to structure the -output into scalar, vector, and arrays of parameters, in addition to storing the parameters as a long vector. - -For the interpretation of these results see \citeauthor{Gelman:2003} (\citeyear{Gelman:2003}, Section 5.5). - -\subsection{Leukaemia registration data}\label{Leukaemia2} -The leukaemia registration data (see Section \ref{Leukaemia}) are used to show data modeling and output reading -into \R{} using the \pkg{coda} package. A simple model for these data looks as follows: -\begin{Code} -model{ - beta.0 ~ dgamma(a.0, tau.0) - beta.benz ~ dgamma(a.benz, tau.benz) - a.0 <- 0.575 - tau.0 <- a.0*2 - a.benz <- 0.575 - tau.benz <- a.benz*2 -\end{Code} -\clearpage -\begin{Code} - for (i in 1:I) - { - count[i] ~ dpois(lambda[i]) - lambda[i] <- p[i]*expect[i] - for (j in 1:J) - { - prop[j,i] <- gamma[j,i]*(benz[j] - benzbar) - } - p[i]<- beta.0 + beta.benz*sum(prop[,i]) - } - } -\end{Code} -Here \verb+count+ denotes the number of observed incidences of childhood leukaemia in ward~\verb+i+. These are -assumed to be Poisson distributed with mean \verb+lambda+ depending on the number of expected cases \verb+expect+ -in ward \verb+i+ and an area-specific risk rate \verb+p+. For calculation of this area specific risk rate we use -an intercept \verb+beta.0+ and a term depending on the weighted sum of benzene emissions \verb+benz+ in each grid -cell \verb+j+. The weights are chosen proportional to the amount of area that ward \verb+i+ and grid cell \verb+j+ have -in common. - -In \R{} we can define all these data and then initialize the model. The data needed for this example are -\begin{description} -\item[\tt{benzbar}:] arithmetic mean of all benzene values, -\item[\tt{benz}:] a vector containing benzene emissions of all 2132 grid cells, -\item[\tt{expect}:] expected number of cases of childhood leukaemia in each of the 873 wards, -\item[\tt{count}:] observed number of childhood leukaemia in these wards, -\item[\tt{gamma}:] a $2132\times 873$ matrix containing the amount of area each grid cell and each ward have in common, -\item[\tt{J}:] total number of grid cells, i.e.~2132, and -\item[\tt{I}:] total number of ward cells, i.e.~873. -\end{description} -The parameters we want to store are regression coefficients \verb+beta.0+ and \verb+beta.benz+ as well as -\verb+p+, the area specific relative risk compared to the reference rate. This reference rate was used to -calculate the expected number of cases in each ward. - -Since we want to use the \pkg{coda} package for reading the data into \WinBUGS{}, we specify \verb+codaPkg = TRUE+ -in the \verb+bugs()+ call: -\begin{Code} - > data <- list(benzbar = mean(benz), benz = benz, expect = expect, - + count = count, gamma = gamma, J = J, I = I) - > parameters <- c("beta.0", "beta.benz", "p") - > inits1 <- list(beta.0 = 1, beta.benz = 1) - > inits2 <- list(beta.0 = 0.5, beta.benz = 0.5) - > inits <- list(inits1, inits2) - > model <- bugs(data, inits, parameters, model.file = "c:/model.bug", - + n.chains = 2, n.iter = 8000, n.burnin = 5000, n.thin = 1, - + codaPkg = TRUE, bugs.directory = "c:/Program Files/WinBUGS14/") -\end{Code} - -\clearpage -Starting with, e.g.,\label{codaexample} -\begin{Code} - > library("coda") - > codaobject <- read.bugs(model) - > plot(codaobject) -\end{Code} -it is now possible to use the \pkg{coda} package for output analyses. - - -\section*{Acknowledgments} -The work of Uwe Ligges has been supported by the Deutsche Forschungsgemeinschaft, -Sonderforschungsbereich 475. -The work of Andrew Gelman has been supported by the U.S. National Science Foundation. - -\bibliography{literatur} - -\clearpage -\begin{appendix} -\section[Help page for the function bugs()]{Help page for the function \code{bugs()}\label{Doc}} -\small -This help page has been shortened. -\input{bugs} -\end{appendix} -\end{document} Copied: trunk/R2WinBUGS/vignettes/R2WinBUGS.Rnw (from rev 255, trunk/R2WinBUGS/inst/doc/R2WinBUGS.Rnw) =================================================================== --- trunk/R2WinBUGS/vignettes/R2WinBUGS.Rnw (rev 0) +++ trunk/R2WinBUGS/vignettes/R2WinBUGS.Rnw 2013-04-07 17:22:49 UTC (rev 257) @@ -0,0 +1,506 @@ +%\VignetteIndexEntry{R2WinBUGS} +\documentclass{Z} +\usepackage{RdRW,thumbpdf} +\newcommand{\WinBUGS}{{\proglang{WinBUGS}}{}} +\newcommand{\RW}{{\pkg{R2WinBUGS}}{}} +\renewcommand{\R}{{\proglang{R}}{}} +\setlength{\textheight}{23.5cm} + +\title{\RW{}:\protect\linebreak A Package for Running \WinBUGS{} from \R{}} +\author{Sibylle Sturtz\thanks{\email{st...@st...}}\\Fachbereich Statistik\\Universit\"at Dortmund\\Germany + \And + Uwe Ligges\thanks{\email{li...@st...}}\\Fachbereich Statistik\\Universit\"at Dortmund\\Germany + \And + Andrew Gelman\thanks{\email{ge...@st...}}\\Department of Statistics\\Columbia University\\USA +} +\Plainauthor{Sibylle Sturtz, Uwe Ligges, Andrew Gelman} +\Plaintitle{R2WinBUGS: A Package for Running WinBUGS from R} + +\Abstract{ +The \RW{} package provides convenient functions to call \WinBUGS{} from \R{}. It +automatically writes the data and scripts in a format readable by \WinBUGS{} for processing in batch mode, which +is possible since version 1.4. After the \WinBUGS{} process has finished, it is possible either to read the +resulting data into \R{} by the package itself---which gives a compact graphical summary of inference and +convergence diagnostics---or to use the facilities of the \pkg{coda} package for further analyses of the +output. Examples are given to demonstrate the usage of this package. +} + +\Keywords{\R{}, \WinBUGS{}, interface, MCMC} +\Plainkeywords{R, WinBUGS, interface, MCMC} + +\begin{document} +An earlier version of this vignette has been published by the Journal of Statistical Software:\\ +Sturtz S, Ligges U, Gelman A (2005): +``\RW{}: A Package for Running \WinBUGS{} from \R{}.'' +{\em Journal of Statistical Software}, 12(3), 1--16. + + +\section{Introduction}\label{Introduction} +The usage of Markov chain Monte Carlo (MCMC) methods became very popular within the last decade. \WinBUGS{} +\citep[\textbf{B}ayesian inference \textbf{U}sing \textbf{G}ibbs \textbf{S}ampling, ][] +{Spiegelhalter;Thomas;Best:2003} is a popular software for analyzing complex statistical models using MCMC +methods. This software uses Gibbs sampling \citep{Geman;Geman:1984,Gelfand;Smith:1990,Casella;George:1992} and the +Metropolis algorithm \citep{Metropolis;Rosenbluth;Rosenbluth;Teller;Teller:1953} +to generate a Markov chain by sampling from full conditional +distributions. +The \WinBUGS{} software is available for free +at \url{http://www.mrc-bsu.cam.ac.uk/bugs/}. +An introduction to MCMC methods is given in \cite{Gilks;Richardson;Spiegelhalter:1996}. + +Using \WinBUGS{}, the user must specify the model to run, and to load data and initial values for a specified +number of Markov chains. Then it is possible to run the Markov chain(s) and to save the results for the parameters +the user is interested in. Summary statistics of these data, convergence diagnostics, kernel estimates +etc.\ are available as well. +Nevertheless, some users of this software might be interested in saving the output and reading it into \R{} +\citep{RCore:2004} for further analyses. +\WinBUGS{} 1.4 comes with the ability to run the software in batch mode using scripts. + +The \RW{} package makes use of this feature and provides the tools to call \WinBUGS{} +directly after data manipulation in \R{}. Furthermore, it is possible to +work with the results after importing them back into \R{} again, for example to create posterior predictive simulations or, more generally, graphical displays of data and posterior simulations \citep{gelman:2004}. +Embedding in R can also be useful for frequently changed data or processing a bunch of data sets, +because it is much more convenient to use some \R{} functions (possibly within a loop) +rather than using ``copy \& paste'' to update data in \WinBUGS{} each time; however difficulties have been encountered in this area because both \R{} and \WinBUGS{} can lock up RAM in the Windows operating system. + +\R{} is a ``language for data analysis and graphics'' and an open source and +freely available statistical software package implementing that language, see \url{http://www.R-project.org/}. +Historically, \R{} is an implementation of the award-winning \proglang{S} +language and system \citep{becker:1984r,becker:1988r,chambers:1992,chambers:1998}. +\R{} and \RW{} are available from \emph{CRAN} (Comprehensive \R{} Archive Network), +i.e., \url{http://CRAN.R-Project.org} or one of its mirrors. +\RW{} could be ported to the commercial \proglang{S} implementation +\textsc{S-Plus}. Minor adaptions would be needed since \textsc{S-Plus} +lacks some of \R{}'s functions and capabilities. +If an internet connection is available, \RW{} can be installed by typing +\verb+install.packages("R2WinBUGS")+ at the \R{} command prompt. +Do not forget to load the package with \verb+library("R2WinBUGS")+. + +The package \pkg{coda} by \cite{Plummer;Best;Cowles;Vines:2004} is very useful for the analysis of \WinBUGS{}' +output, the reader might want to install this package as well. The CRAN package \pkg{boa} (Bayesian Output +Analysis Program) by \cite{Smith:2004} has similar aims. +\proglang{JAGS} (Just Another Gibbs Sampler) +by \cite{Plummer:2003} is a program for analysis of Bayesian hierarchical models using Gibbs sampling that aims for +the same functionality as classic \proglang{BUGS}. \proglang{JAGS} is developed to work closely together with \R{} and +the \pkg{coda} package. + +%% Revision 2005-01-10 start +A new and completely revised version of WinBUGS called \proglang{OpenBUGS} \citep{Spiegelhalter;Thomas;Best;Lunn:2004} +was lately published under the terms of the GPL. +\proglang{OpenBUGS} is also expected to run under Linux. +It provides a much more flexible API on which ``BRugs'' is based including +a dynamic link library, incorporating a component loader +that allows \R{} to make use of \proglang{OpenBUGS} components. +OpenBUGS is still in development and suffers frequent crashes. +As OpenBUGS becomes more reliable, +it is planned to merge ``BRugs'' and \RW{} into one \R{} package. +%% Revision 2005-01-10 end + +For other packages and projects on spatial statistics +related to \R{}, follow the link to ``\R{} spatial projects'' at CRAN. + +In this paper, we give two examples, involving educational testing experiments in schools (cf.~Section~\ref{School}), +and incidence of childhood leukaemia depending on benzene emissions (cf.~Section~\ref{Leukaemia}). Details on the +functions of \RW{} are given in Section~\ref{Programming}. These functions automatically write the data and a +script in a format readable by \WinBUGS{} for processing in batch mode, and call \WinBUGS{} from \R{}. After the +\WinBUGS{} process has finished, it is possible either to read the resulting data into \R{} by the package itself +or to use the facilities of the \pkg{coda} package for further analyses of the output. In Section~\ref{Example2}, +we demonstrate how to apply the functions provided by \RW{} on the examples' data, and how to analyze the output +both with package \pkg{coda} and with \RW{}'s methods to \verb+plot()+ and \verb+print()+ the output. + + +\section{Examples}\label{Examples} +In this Section, we introduce two examples which will be continued in Section~\ref{Example2}. + +\subsection{Schools data}\label{School} +The Scholastic Aptitude Test (SAT) measures the aptitude of high-schoolers in order to help colleges to make +admissions decisions. It is divided into two parts, verbal (SAT-V) and mathematical (SAT-M). +Our data comes from the SAT-V (Scholastic Aptitude Test-Verbal) on eight different high schools, from an experiment conducted in the late 1970s. +SAT-V is a standard multiple choice test administered by the Educational Testing Service. +This Service was interested in the effects of coaching programs for each of the selected schools. + +The study included coached and uncoached pupils, about sixty in each of the eight different schools; see +\cite{Rubin:1981}. All of them had already taken the PSAT (Preliminary SAT) which results were used as covariates. +%Even if the test is constructed to be resistant to short-term +%efforts directed specifically toward improving test performance, each of the schools is successful at increasing +%SAT scores. +For each school, the estimated treatment effect and the standard error of the effect estimate are given. +These are calculated by an analysis of covariance adjustment appropriate for a completely randomized experiment +\citep{Rubin:1981}. This example was analyzed using a hierarchical normal model in \cite{Rubin:1981} and +\citeauthor{Gelman:2003} (\citeyear{Gelman:2003}, Section 5.5). + +\subsection{Leukaemia registration data}\label{Leukaemia} +Spatial data usually arises on different, non-nesting spatial scales. One example is childhood leukaemia +registration data analyzed by \cite{Best;Cockings;Bennett;Wakefield;Elliot:2001} +using ecologic regression. Data are given for Greater London bounded by the M25 orbital motorway. +%% Revision 2005-01-10 start +The data are not available as an example in \RW{} but we use the example here +to illustrate +alternative calls to the \verb+bugs()+ function and output analysis using the \pkg{coda} package. +%% Revision 2005-01-10 end + +The observed number of leukaemia cases among children under 15 years old is given at ward level. Census wards are +administrative areas containing approximately 5000 to 10\,000 people. Central London is divided into 873 wards. The +number of incident cases of leukaemia in children is available from 1985 until 1996 from the Office of National +Statistics and the Thames Cancer Registry. A plot of these numbers is given in Figure~\ref{observed}. + +\begin{figure} +\begin{center} +\includegraphics[width=0.85\textwidth]{countssw} +\caption{\label{observed}Observed number of cases of childhood leukaemia in 1985--1996} +\end{center} +\end{figure} + +Additionally, the number of expected cases (cf.~Fig.~\ref{expected}) is calculated on the same +resolution using population numbers for different age-sex-strata and the national leukaemia +rate for the corresponding strata, for details see \cite{Best;Cockings;Bennett;Wakefield;Elliot:2001}. + +\begin{figure} +\begin{center} +\includegraphics[width=0.85\textwidth]{expectedsw} +\caption{\label{expected}Expected number of cases of childhood leukaemia in 1985--1996}%, as obtained from a simple demographic model} +\end{center} +\end{figure} + +It is assumed that benzene emissions have an effect on the incidence rate of leukaemia. Benzene emission rates are +available in tonnes per year from an atmospheric emissions inventory for London +\citep{Buckingham;Clewley;Hutchinson;Sadler;Shah:1997} produced by the London Research Centre. They are provided +at 1km $\times$ 1km grid cells, giving 2132 grid cells in total. +Their spatial distribution is shown in Figure~\ref{benzene}. + +\begin{figure} +\begin{center} +\includegraphics[width=0.9\textwidth]{benzolsw} +\caption{\label{benzene}Benzene emissions in tonnes per year} +\end{center} +\end{figure} + +For further details on the data see \cite{Best;Cockings;Bennett;Wakefield;Elliot:2001}. + +We model these data by Poisson-Gamma models introduced by \cite{Best;Ickstadt;Wolpert:2000} using \WinBUGS{}. +A linking matrix containing information which grid cell belongs to which ward +and to which amount is required. This matrix is calculated using \R{}. +Unfortunately, \WinBUGS{} does not support a list format such as directly produced by \R{}. +Therefore, the data must be provided as a matrix with 2132 rows and 873 columns (or vice versa). +Most of the entries of this matrix are zeroes, but using \verb+dump()+ to export it from \R{} +yields in a file size of 14.2~MB. +Unfortunately, opening a file of such size really slows \WinBUGS{} down, +and it was not even possible on some of our PCs. +Importing data written by our \RW{} package does not make any problems using the batch mode, +probably due to memory management issues in \WinBUGS{}. + + +\section{Implementation}\label{Programming} +The implementation of the \RW{} package is straightforward. +The ``main'' function \verb+bugs()+ is intended to be called by the user. +In principle, it is a wrapper for several other functions called therein step by step as follows: +\begin{enumerate} + \item \verb+bugs.data.inits()+ writes the data files \file{data.txt}, and \file{inits1.txt}, \file{inits2.txt}, ... + into the working directory. These files will be used by \WinBUGS{} during batch processing. + + In particular, input for \WinBUGS{} must not exceed a certain number of digits. + Moreover, it needs an \verb+E+ instead of an \verb+e+ in scientific notation. + Scientific notation is particularly desirable because of the ``number of digits'' limitation. + The default (\verb+digits = 5+) is to, e.g., reformat the number \verb+123456.789+ to \verb@1.23457E+05@. + \item \verb+bugs.script()+ writes the file \file{script.txt} that is used by \WinBUGS{} for batch processing. + \item \verb+bugs.run()+ updates the lengths of the adaptive phases in the \WinBUGS{} registry + (using a function \verb+bugs.update.settings()+), + calls \WinBUGS{}, and runs it in batch mode with \file{script.txt}. + \item \verb+bugs.sims()+ is only called if the argument \verb+codaPkg+ has been set to \verb+FALSE+ (the default). + Otherwise \verb+bugs()+ returns the filenames of stored data. These can, for example, + be imported by package \pkg{coda} (see the example in Section~\ref{Leukaemia2}, page~\pageref{codaexample}), + which provides functions for convergence diagnostics, + calculation of Monte Carlo estimates, trace plots, and so forth. + + The function \verb+bugs.sims()+ reads simulations from \WinBUGS{} into \R{} (not necessarily called by \verb+bugs()+ + itself), formats them, + monitors convergence, performs convergence checks, and computes medians and quantiles. + It also prepares the output for \verb+bugs()+ itself. +\end{enumerate} +These functions are not intended to be called by the user directly. +Arguments are passed from \verb+bugs()+ to the other functions, if appropriate. +A shortened help file of \verb+bugs()+ listing all arguments is given in Appendix~\ref{Doc}; +for the full version type \verb+?bugs+ in \R{} after having installed and loaded the package \RW{} +(see Section~\ref{Introduction}). + +%\newpage +As known from \WinBUGS{}, one must specify the \verb+data+ in form of a list, with list names equal to the names +of data in the corresponding \WinBUGS{} model. Alternatively, it is possible to specify a vector or list of names +(of mode \verb+character+). In that case objects of that names are looked for in the environment in which +\verb+bugs()+ has been called (usually that is the user's Workspace, \verb+.GlobalEnv+). +%% Revision 2005-01-10 start +If data have already been written in a file called \file{data.txt} to the working directory, +it is possible to specify \verb+data = "data.txt"+. +%% Revision 2005-01-10 end +One will usually want to supply initial values. +This can be done either in the form of a function \verb+inits()+ that creates these values, so that +different chains can be automatically initialized at different points (see Section \ref{School2}), or by specifying them +directly (see Section \ref{Leukaemia2}). +If \verb+inits()+ is not specified, +\verb+bugs()+ just uses the starting values created by \WinBUGS{}; but in practice \WinBUGS{} can crash when +reasonable initial values are not specified, and so we recommend constructing a simple \verb+inits()+ function to +simulate reasonable starting points \cite[Section C.2]{Gelman:2003}. It is also necessary to specify which +parameters should be saved for monitoring by specifying \verb+parameters.to.save+. + +The user might also want to change the defaults for the length of the burn-in (\verb+n.burnin+, which defaults to half the length of the chain) +period for every MCMC run and the number of iterations (\verb+n.iter+, default value 3) +that are used to calculate Monte Carlo estimates. +%SS: Achtung: n.iter=n.burn.in + length of stored chain! +The specification of a thinning parameter (\verb+n.thin+) is possible as well; this is useful when the number of parameters is large, to keep the saved output to a reasonably-sized R object. In the default setting, the chains are thinned enough so that approximately 1000 simulation draws are saved. + +By setting the argument \verb+debug = TRUE+, +\WinBUGS{} remains open after the run. +This way it is possible to find errors in the code or the data structure, +or even to work with that software as in a usual run. + +It is possible to run one or more Markov chains. +The number of chains (\verb+n.chains+) must be specified together with the chains' initial values (\verb+inits+). +If more than one Markov chain is requested and \verb+codaPkg+ is set to \verb+FALSE+, the convergence diagnostic +$\hat{R}$ \citep{Brooks;Gelman:1998} is calculated by \verb+bugs.sims()+ for each of the saved parameters. + +%% Revision 2005-01-10 start +Since the communication between \WinBUGS{} and \R{} is based on files, +rather huge files will be saved in the working directory by the \verb+bugs()+ call, +either files to be read in by \verb+bugs()+ itself, or by the \pkg{coda} package. +The user might want to delete those files after the desired contents has been imported into \R{}, +and save those objects, e.g., as compressed \R{} data files. +%% Revision 2005-01-10 end + +The function \verb+bugs()+ returns a rather complex object of class \verb+bugs+, +if called with argument \verb+codaPkg = FALSE+. +In order to look at the structure of such an object, type \verb+str(objectname)+. +For convenience, \RW{} provides methods corresponding to class \verb+bugs+ for +the generic functions \verb+print()+ and \verb+plot()+. + +So that user will not be overwhelmed with information; summaries of the output are provided by the +\verb+print()+ method. That is, some parameters of the \verb+bugs()+ call are summarized, and mean, +standard deviation, several quantiles of the parameters and convergence diagnostics based on \cite{Gelman;Rubin:1992} +are printed. See the example in +Section~\ref{School2}, page~\pageref{schoolssim}, for a typical output. As with \cite{Spiegelhalter;Best;Carlin;vdLinde:2002}, +%\pagebreak + the DIC computed by \verb+bugs.sims()+ is defined as the posterior mean +of the deviance plus $p_D$, the estimated effective number of parameters in the posterior distribution. We define +$p_D$ as half the posterior variance of the deviance and estimate it as half the average of the within-chain +variances of the deviance.\footnote{In contrast, \cite{Spiegelhalter;Best;Carlin;vdLinde:2002}, + and WinBUGS, define $p_D$ as the +posterior mean of the deviance evaluated at the posterior mean of the parameter values. We cannot use that +definition because the deviance function is not available to our program, which calls \WinBUGS{} from the +``outside''. Both definitions of $p_D$---ours and that introduced by \cite{Spiegelhalter;Best;Carlin;vdLinde:2002}---can be +derived from the asymptotic $\chi^2$ distribution of the deviance relative to its minimum \citep[Section 6.7]{Gelman:2003}. +We make no claim that our measure of $p_D$ is superior to that of \cite{Spiegelhalter;Best;Carlin;vdLinde:2002}; +we choose this measure purely because it is computationally possible given what is available to us from the \WinBUGS{} output.} + + +The \verb+plot()+ for objects of class \verb+bugs+ +provides information condensed in some plots conveniently arranged within the same graphics device. +For an example, see Figure~\ref{plot} in Section~\ref{School2}. It is intended to adapt this function to work with MCMC output in general, even if obtained from software other than WinBUGS. + + + +\section{Examples continued}\label{Example2} +The Examples introduced in Section~\ref{Example2} are continued in this Section. +We apply the functions provided by \RW{} +to the examples' data and analyze the output. + +\subsection{Schools data}\label{School2} +Schools example data (see Section~\ref{School}) are available with the \RW{} package: +\begin{Code} + > data(schools) + > schools + school estimate sd + 1 A 28.39 14.9 + 2 B 7.94 10.2 + 3 C -2.75 16.3 + 4 D 6.82 11.0 + 5 E -0.64 9.4 + 6 F 0.63 11.4 + 7 G 18.01 10.4 + 8 H 12.16 17.6 +\end{Code} +For modeling these data, we use a hierarchical model as proposed by \citeauthor{Gelman:2003} (\citeyear{Gelman:2003}, Section 5.5). +We assume a normal distribution for the observed estimate for each school with +mean \verb+theta+ and inverse-variance \verb+tau.y+. +The inverse-variance is given as $1/\verb+sigma.y+^{2}$ and its prior distribution is uniform on (0,1000). For the mean +\verb+theta+, we employ another normal distribution with mean \verb+mu.theta+ and inverse-variance \verb+tau.theta+. For +their prior distributions, see the following \WinBUGS{} code: + + +\begin{Code} + model { + for (j in 1:J) + { + y[j] ~ dnorm (theta[j], tau.y[j]) + theta[j] ~ dnorm (mu.theta, tau.theta) + tau.y[j] <- pow(sigma.y[j], -2) + } + mu.theta ~ dnorm (0.0, 1.0E-6) + tau.theta <- pow(sigma.theta, -2) + sigma.theta ~ dunif (0, 1000) + } +\end{Code} +This model must be stored in a separate file, e.g.~\file{schools.bug}\footnote{Emacs Speaks Statistics (ESS) +by \cite{rossini04}, a package available with Gnu Emacs \citep{stallmann99}, +recognizes and properly formats Bugs model files that have the .bug extension.}, +in an appropriate directory, say \path{c:/schools/}. +In \R{} the user must prepare the data inputs the \verb+bugs()+ function needs. +This can be a list containing the name of each data vector, e.g. +\begin{Code} + > J <- nrow(schools) + > y <- schools$estimate + > sigma.y <- schools$sd + > data <- list ("J", "y", "sigma.y") +\end{Code} +Using these data and the model file, we can run an MCMC simulation to get estimates for \verb+theta+, +\verb+mu.theta+ and \verb+sigma.theta+. Before running, the user must decide how many chains to be run +(\verb+n.chain = 3+) for how many iterations (\verb+n.iter = 1000+). +If the length of burn-in is not specified, \verb+n.burnin = floor(n.iter/2)+ is used, that is, 500 in this example. +Additionally, the user must specify initial values for the chains, for example by writing a function. This can be done by +\begin{Code} + > inits <- function(){ + + list(theta = rnorm(J, 0, 100), mu.theta = rnorm(1, 0, 100), + + sigma.theta = runif(1, 0, 100)) + + } +\end{Code} +Now, the user can start the MCMC simulation by typing +\begin{Code} + > schools.sim <- bugs(data, inits, model.file = "c:/schools/schools.bug", + + parameters = c("theta", "mu.theta", "sigma.theta"), + + n.chains = 3, n.iter = 1000, + + bugs.directory = "c:/Program Files/WinBUGS14/") +\end{Code} +in \R{}.\label{schoolssim} The argument \verb+bugs.directory+ must point to the directory +where \WinBUGS{} has been installed. +For other available arguments, see Appendix \ref{Doc}. + +The results in objects \verb+schools.sim+ can conveniently be printed by \verb+print(schools.sim)+. +The generic function \verb+print()+ calls the print method for an object of class \verb+bugs+ +provided by \RW{}. +For this example, you will get something like + +\small +\begin{Code} + > print(schools.sim) + Inference for Bugs model at "c:/schools/schools.bug" + 3 chains, each with 1000 iterations (first 500 discarded) + n.sims = 1500 iterations saved + mean sd 2.5% 25% 50% 75% 97.5% Rhat n.eff + theta[1] 11.1 9.1 -3.0 5.0 10.0 16.0 31.8 1.1 39 + theta[2] 7.6 6.6 -4.7 3.3 7.8 11.6 21.1 1.1 42 + theta[3] 5.7 8.4 -12.5 0.6 6.1 10.8 21.8 1.0 150 + theta[4] 7.1 7.0 -6.6 2.7 7.2 11.5 21.0 1.1 42 + theta[5] 5.1 6.8 -9.5 0.7 5.2 9.7 18.1 1.0 83 + theta[6] 5.7 7.3 -9.7 1.0 6.2 10.2 20.0 1.0 56 + theta[7] 10.4 7.3 -2.1 5.3 9.8 15.3 25.5 1.1 27 + theta[8] 8.3 8.4 -6.6 2.8 8.1 12.7 26.2 1.0 64 + mu.theta 7.6 5.9 -3.0 3.7 8.0 11.0 19.5 1.1 35 + sigma.theta 6.7 5.6 0.3 2.8 5.1 9.2 21.2 1.1 46 + deviance 60.8 2.5 57.0 59.1 60.2 62.1 66.6 1.0 170 + pD = 3 and DIC = 63.8 (using the rule, pD = var(deviance)/2) + + For each parameter, n.eff is a crude measure of effective sample size, + and Rhat is the potential scale reduction factor (at convergence, Rhat=1). + DIC is an estimate of expected predictive error (lower deviance is better). +\end{Code} +\normalsize +Additionally, the user can generate a plot of the results by typing \verb+plot(schools.sim)+. +The resulting plot is given in Figure~\ref{plot}. +\begin{figure}[t] +\begin{center} +\fbox{ +\includegraphics[width=0.9\textwidth]{plot} +} \caption{\label{plot}Plot produced by \RW{} package for the schools example. } +\end{center} +\end{figure} +In this plot, the left column shows a quick +summary of inference and convergence ($\widehat{R}$ is close to 1.0 for all parameters, indicating good mixing of +the three chains and thus approximate convergence); and the right column shows inferences for each set of +parameters. As can be seen in the right column, \RW{} uses the parameter names in \WinBUGS{} to structure the +output into scalar, vector, and arrays of parameters, in addition to storing the parameters as a long vector. + +For the interpretation of these results see \citeauthor{Gelman:2003} (\citeyear{Gelman:2003}, Section 5.5). + +\subsection{Leukaemia registration data}\label{Leukaemia2} +The leukaemia registration data (see Section \ref{Leukaemia}) are used to show data modeling and output reading +into \R{} using the \pkg{coda} package. A simple model for these data looks as follows: +\begin{Code} +model{ + beta.0 ~ dgamma(a.0, tau.0) + beta.benz ~ dgamma(a.benz, tau.benz) + a.0 <- 0.575 + tau.0 <- a.0*2 + a.benz <- 0.575 + tau.benz <- a.benz*2 +\end{Code} +\clearpage +\begin{Code} + for (i in 1:I) + { + count[i] ~ dpois(lambda[i]) + lambda[i] <- p[i]*expect[i] + for (j in 1:J) + { + prop[j,i] <- gamma[j,i]*(benz[j] - benzbar) + } + p[i]<- beta.0 + beta.benz*sum(prop[,i]) + } + } +\end{Code} +Here \verb+count+ denotes the number of observed incidences of childhood leukaemia in ward~\verb+i+. These are +assumed to be Poisson distributed with mean \verb+lambda+ depending on the number of expected cases \verb+expect+ +in ward \verb+i+ and an area-specific risk rate \verb+p+. For calculation of this area specific risk rate we use +an intercept \verb+beta.0+ and a term depending on the weighted sum of benzene emissions \verb+benz+ in each grid +cell \verb+j+. The weights are chosen proportional to the amount of area that ward \verb+i+ and grid cell \verb+j+ have +in common. + +In \R{} we can define all these data and then initialize the model. The data needed for this example are +\begin{description} +\item[\tt{benzbar}:] arithmetic mean of all benzene values, +\item[\tt{benz}:] a vector containing benzene emissions of all 2132 grid cells, +\item[\tt{expect}:] expected number of cases of childhood leukaemia in each of the 873 wards, +\item[\tt{count}:] observed number of childhood leukaemia in these wards, +\item[\tt{gamma}:] a $2132\times 873$ matrix containing the amount of area each grid cell and each ward have in common, +\item[\tt{J}:] total number of grid cells, i.e.~2132, and +\item[\tt{I}:] total number of ward cells, i.e.~873. +\end{description} +The parameters we want to store are regression coefficients \verb+beta.0+ and \verb+beta.benz+ as well as +\verb+p+, the area specific relative risk compared to the reference rate. This reference rate was used to +calculate the expected number of cases in each ward. + +Since we want to use the \pkg{coda} package for reading the data into \WinBUGS{}, we specify \verb+codaPkg = TRUE+ +in the \verb+bugs()+ call: +\begin{Code} + > data <- list(benzbar = mean(benz), benz = benz, expect = expect, + + count = count, gamma = gamma, J = J, I = I) + > parameters <- c("beta.0", "beta.benz", "p") + > inits1 <- list(beta.0 = 1, beta.benz = 1) + > inits2 <- list(beta.0 = 0.5, beta.benz = 0.5) + > inits <- list(inits1, inits2) + > model <- bugs(data, inits, parameters, model.file = "c:/model.bug", + + n.chains = 2, n.iter = 8000, n.burnin = 5000, n.thin = 1, + + codaPkg = TRUE, bugs.directory = "c:/Program Files/WinBUGS14/") +\end{Code} + +\clearpage +Starting with, e.g.,\label{codaexample} +\begin{Code} + > library("coda") + > codaobject <- read.bugs(model) + > plot(codaobject) +\end{Code} +it is now possible ... [truncated message content] |
From: <li...@us...> - 2013-04-07 17:13:44
|
Revision: 256 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=256&view=rev Author: ligges Date: 2013-04-07 17:13:29 +0000 (Sun, 07 Apr 2013) Log Message: ----------- 1. .path.package() -> system.file() 2. relocation of vignette files 3. increase version number and update version dependencies Modified Paths: -------------- trunk/R2WinBUGS/DESCRIPTION trunk/R2WinBUGS/inst/NEWS trunk/R2WinBUGS/man/attach.all.Rd Added Paths: ----------- trunk/R2WinBUGS/vignettes/ trunk/R2WinBUGS/vignettes/R2WinBUGS.Rnw trunk/R2WinBUGS/vignettes/RdRW.sty trunk/R2WinBUGS/vignettes/Z.cls trunk/R2WinBUGS/vignettes/benzolsw.pdf trunk/R2WinBUGS/vignettes/bugs.tex trunk/R2WinBUGS/vignettes/countssw.pdf trunk/R2WinBUGS/vignettes/expectedsw.pdf trunk/R2WinBUGS/vignettes/literatur.bib trunk/R2WinBUGS/vignettes/literatur.bst trunk/R2WinBUGS/vignettes/plot.pdf Removed Paths: ------------- trunk/R2WinBUGS/inst/doc/R2WinBUGS.Rnw trunk/R2WinBUGS/inst/doc/RdRW.sty trunk/R2WinBUGS/inst/doc/Z.cls trunk/R2WinBUGS/inst/doc/benzolsw.pdf trunk/R2WinBUGS/inst/doc/bugs.tex trunk/R2WinBUGS/inst/doc/countssw.pdf trunk/R2WinBUGS/inst/doc/expectedsw.pdf trunk/R2WinBUGS/inst/doc/literatur.bib trunk/R2WinBUGS/inst/doc/literatur.bst trunk/R2WinBUGS/inst/doc/plot.pdf Modified: trunk/R2WinBUGS/DESCRIPTION =================================================================== --- trunk/R2WinBUGS/DESCRIPTION 2012-07-24 08:42:13 UTC (rev 255) +++ trunk/R2WinBUGS/DESCRIPTION 2013-04-07 17:13:29 UTC (rev 256) @@ -1,7 +1,7 @@ Package: R2WinBUGS Title: Running WinBUGS and OpenBUGS from R / S-PLUS -Date: 2011-03-22 -Version: 2.1-18 +Date: 2013-04-07 +Version: 2.1-19 Author: originally written by Andrew Gelman <ge...@st...>; changes and packaged by Sibylle Sturtz <st...@st...> and Uwe Ligges <li...@st...>. @@ -13,7 +13,7 @@ convergence in a table and graph, and save the simulations in arrays for easy access in R / S-PLUS. In S-PLUS, the openbugs functionality and the windows emulation functionality is not yet available. -Depends: R (>= 2.5.0), coda (>= 0.11-0), boot +Depends: R (>= 2.13.0), coda (>= 0.11-0), boot Suggests: BRugs (>= 0.3-2) SystemRequirements: WinBUGS 1.4 URL: http://www.stat.columbia.edu/~gelman/bugsR/ Modified: trunk/R2WinBUGS/inst/NEWS =================================================================== --- trunk/R2WinBUGS/inst/NEWS 2012-07-24 08:42:13 UTC (rev 255) +++ trunk/R2WinBUGS/inst/NEWS 2013-04-07 17:13:29 UTC (rev 256) @@ -1,6 +1,11 @@ Changes to R2WinBUGS: ===================== +Update 2.1-19 +- fix outdated usage: .path.package -> system.file +- move vignette files around + +Update 2.1-18 - import logit from boot nowadays (seems nobody uses that anyway) Update 2.1-17 Deleted: trunk/R2WinBUGS/inst/doc/R2WinBUGS.Rnw =================================================================== --- trunk/R2WinBUGS/inst/doc/R2WinBUGS.Rnw 2012-07-24 08:42:13 UTC (rev 255) +++ trunk/R2WinBUGS/inst/doc/R2WinBUGS.Rnw 2013-04-07 17:13:29 UTC (rev 256) @@ -1,506 +0,0 @@ -%\VignetteIndexEntry{R2WinBUGS} -\documentclass{Z} -\usepackage{RdRW,thumbpdf} -\newcommand{\WinBUGS}{{\proglang{WinBUGS}}{}} -\newcommand{\RW}{{\pkg{R2WinBUGS}}{}} -\renewcommand{\R}{{\proglang{R}}{}} -\setlength{\textheight}{23.5cm} - -\title{\RW{}:\protect\linebreak A Package for Running \WinBUGS{} from \R{}} -\author{Sibylle Sturtz\thanks{\email{st...@st...}}\\Fachbereich Statistik\\Universit\"at Dortmund\\Germany - \And - Uwe Ligges\thanks{\email{li...@st...}}\\Fachbereich Statistik\\Universit\"at Dortmund\\Germany - \And - Andrew Gelman\thanks{\email{ge...@st...}}\\Department of Statistics\\Columbia University\\USA -} -\Plainauthor{Sibylle Sturtz, Uwe Ligges, Andrew Gelman} -\Plaintitle{R2WinBUGS: A Package for Running WinBUGS from R} - -\Abstract{ -The \RW{} package provides convenient functions to call \WinBUGS{} from \R{}. It -automatically writes the data and scripts in a format readable by \WinBUGS{} for processing in batch mode, which -is possible since version 1.4. After the \WinBUGS{} process has finished, it is possible either to read the -resulting data into \R{} by the package itself---which gives a compact graphical summary of inference and -convergence diagnostics---or to use the facilities of the \pkg{coda} package for further analyses of the -output. Examples are given to demonstrate the usage of this package. -} - -\Keywords{\R{}, \WinBUGS{}, interface, MCMC} -\Plainkeywords{R, WinBUGS, interface, MCMC} - -\begin{document} -An earlier version of this vignette has been published by the Journal of Statistical Software:\\ -Sturtz S, Ligges U, Gelman A (2005): -``\RW{}: A Package for Running \WinBUGS{} from \R{}.'' -{\em Journal of Statistical Software}, 12(3), 1--16. - - -\section{Introduction}\label{Introduction} -The usage of Markov chain Monte Carlo (MCMC) methods became very popular within the last decade. \WinBUGS{} -\citep[\textbf{B}ayesian inference \textbf{U}sing \textbf{G}ibbs \textbf{S}ampling, ][] -{Spiegelhalter;Thomas;Best:2003} is a popular software for analyzing complex statistical models using MCMC -methods. This software uses Gibbs sampling \citep{Geman;Geman:1984,Gelfand;Smith:1990,Casella;George:1992} and the -Metropolis algorithm \citep{Metropolis;Rosenbluth;Rosenbluth;Teller;Teller:1953} -to generate a Markov chain by sampling from full conditional -distributions. -The \WinBUGS{} software is available for free -at \url{http://www.mrc-bsu.cam.ac.uk/bugs/}. -An introduction to MCMC methods is given in \cite{Gilks;Richardson;Spiegelhalter:1996}. - -Using \WinBUGS{}, the user must specify the model to run, and to load data and initial values for a specified -number of Markov chains. Then it is possible to run the Markov chain(s) and to save the results for the parameters -the user is interested in. Summary statistics of these data, convergence diagnostics, kernel estimates -etc.\ are available as well. -Nevertheless, some users of this software might be interested in saving the output and reading it into \R{} -\citep{RCore:2004} for further analyses. -\WinBUGS{} 1.4 comes with the ability to run the software in batch mode using scripts. - -The \RW{} package makes use of this feature and provides the tools to call \WinBUGS{} -directly after data manipulation in \R{}. Furthermore, it is possible to -work with the results after importing them back into \R{} again, for example to create posterior predictive simulations or, more generally, graphical displays of data and posterior simulations \citep{gelman:2004}. -Embedding in R can also be useful for frequently changed data or processing a bunch of data sets, -because it is much more convenient to use some \R{} functions (possibly within a loop) -rather than using ``copy \& paste'' to update data in \WinBUGS{} each time; however difficulties have been encountered in this area because both \R{} and \WinBUGS{} can lock up RAM in the Windows operating system. - -\R{} is a ``language for data analysis and graphics'' and an open source and -freely available statistical software package implementing that language, see \url{http://www.R-project.org/}. -Historically, \R{} is an implementation of the award-winning \proglang{S} -language and system \citep{becker:1984r,becker:1988r,chambers:1992,chambers:1998}. -\R{} and \RW{} are available from \emph{CRAN} (Comprehensive \R{} Archive Network), -i.e., \url{http://CRAN.R-Project.org} or one of its mirrors. -\RW{} could be ported to the commercial \proglang{S} implementation -\textsc{S-Plus}. Minor adaptions would be needed since \textsc{S-Plus} -lacks some of \R{}'s functions and capabilities. -If an internet connection is available, \RW{} can be installed by typing -\verb+install.packages("R2WinBUGS")+ at the \R{} command prompt. -Do not forget to load the package with \verb+library("R2WinBUGS")+. - -The package \pkg{coda} by \cite{Plummer;Best;Cowles;Vines:2004} is very useful for the analysis of \WinBUGS{}' -output, the reader might want to install this package as well. The CRAN package \pkg{boa} (Bayesian Output -Analysis Program) by \cite{Smith:2004} has similar aims. -\proglang{JAGS} (Just Another Gibbs Sampler) -by \cite{Plummer:2003} is a program for analysis of Bayesian hierarchical models using Gibbs sampling that aims for -the same functionality as classic \proglang{BUGS}. \proglang{JAGS} is developed to work closely together with \R{} and -the \pkg{coda} package. - -%% Revision 2005-01-10 start -A new and completely revised version of WinBUGS called \proglang{OpenBUGS} \citep{Spiegelhalter;Thomas;Best;Lunn:2004} -was lately published under the terms of the GPL. -\proglang{OpenBUGS} is also expected to run under Linux. -It provides a much more flexible API on which ``BRugs'' is based including -a dynamic link library, incorporating a component loader -that allows \R{} to make use of \proglang{OpenBUGS} components. -OpenBUGS is still in development and suffers frequent crashes. -As OpenBUGS becomes more reliable, -it is planned to merge ``BRugs'' and \RW{} into one \R{} package. -%% Revision 2005-01-10 end - -For other packages and projects on spatial statistics -related to \R{}, follow the link to ``\R{} spatial projects'' at CRAN. - -In this paper, we give two examples, involving educational testing experiments in schools (cf.~Section~\ref{School}), -and incidence of childhood leukaemia depending on benzene emissions (cf.~Section~\ref{Leukaemia}). Details on the -functions of \RW{} are given in Section~\ref{Programming}. These functions automatically write the data and a -script in a format readable by \WinBUGS{} for processing in batch mode, and call \WinBUGS{} from \R{}. After the -\WinBUGS{} process has finished, it is possible either to read the resulting data into \R{} by the package itself -or to use the facilities of the \pkg{coda} package for further analyses of the output. In Section~\ref{Example2}, -we demonstrate how to apply the functions provided by \RW{} on the examples' data, and how to analyze the output -both with package \pkg{coda} and with \RW{}'s methods to \verb+plot()+ and \verb+print()+ the output. - - -\section{Examples}\label{Examples} -In this Section, we introduce two examples which will be continued in Section~\ref{Example2}. - -\subsection{Schools data}\label{School} -The Scholastic Aptitude Test (SAT) measures the aptitude of high-schoolers in order to help colleges to make -admissions decisions. It is divided into two parts, verbal (SAT-V) and mathematical (SAT-M). -Our data comes from the SAT-V (Scholastic Aptitude Test-Verbal) on eight different high schools, from an experiment conducted in the late 1970s. -SAT-V is a standard multiple choice test administered by the Educational Testing Service. -This Service was interested in the effects of coaching programs for each of the selected schools. - -The study included coached and uncoached pupils, about sixty in each of the eight different schools; see -\cite{Rubin:1981}. All of them had already taken the PSAT (Preliminary SAT) which results were used as covariates. -%Even if the test is constructed to be resistant to short-term -%efforts directed specifically toward improving test performance, each of the schools is successful at increasing -%SAT scores. -For each school, the estimated treatment effect and the standard error of the effect estimate are given. -These are calculated by an analysis of covariance adjustment appropriate for a completely randomized experiment -\citep{Rubin:1981}. This example was analyzed using a hierarchical normal model in \cite{Rubin:1981} and -\citeauthor{Gelman:2003} (\citeyear{Gelman:2003}, Section 5.5). - -\subsection{Leukaemia registration data}\label{Leukaemia} -Spatial data usually arises on different, non-nesting spatial scales. One example is childhood leukaemia -registration data analyzed by \cite{Best;Cockings;Bennett;Wakefield;Elliot:2001} -using ecologic regression. Data are given for Greater London bounded by the M25 orbital motorway. -%% Revision 2005-01-10 start -The data are not available as an example in \RW{} but we use the example here -to illustrate -alternative calls to the \verb+bugs()+ function and output analysis using the \pkg{coda} package. -%% Revision 2005-01-10 end - -The observed number of leukaemia cases among children under 15 years old is given at ward level. Census wards are -administrative areas containing approximately 5000 to 10\,000 people. Central London is divided into 873 wards. The -number of incident cases of leukaemia in children is available from 1985 until 1996 from the Office of National -Statistics and the Thames Cancer Registry. A plot of these numbers is given in Figure~\ref{observed}. - -\begin{figure} -\begin{center} -\includegraphics[width=0.85\textwidth]{countssw} -\caption{\label{observed}Observed number of cases of childhood leukaemia in 1985--1996} -\end{center} -\end{figure} - -Additionally, the number of expected cases (cf.~Fig.~\ref{expected}) is calculated on the same -resolution using population numbers for different age-sex-strata and the national leukaemia -rate for the corresponding strata, for details see \cite{Best;Cockings;Bennett;Wakefield;Elliot:2001}. - -\begin{figure} -\begin{center} -\includegraphics[width=0.85\textwidth]{expectedsw} -\caption{\label{expected}Expected number of cases of childhood leukaemia in 1985--1996}%, as obtained from a simple demographic model} -\end{center} -\end{figure} - -It is assumed that benzene emissions have an effect on the incidence rate of leukaemia. Benzene emission rates are -available in tonnes per year from an atmospheric emissions inventory for London -\citep{Buckingham;Clewley;Hutchinson;Sadler;Shah:1997} produced by the London Research Centre. They are provided -at 1km $\times$ 1km grid cells, giving 2132 grid cells in total. -Their spatial distribution is shown in Figure~\ref{benzene}. - -\begin{figure} -\begin{center} -\includegraphics[width=0.9\textwidth]{benzolsw} -\caption{\label{benzene}Benzene emissions in tonnes per year} -\end{center} -\end{figure} - -For further details on the data see \cite{Best;Cockings;Bennett;Wakefield;Elliot:2001}. - -We model these data by Poisson-Gamma models introduced by \cite{Best;Ickstadt;Wolpert:2000} using \WinBUGS{}. -A linking matrix containing information which grid cell belongs to which ward -and to which amount is required. This matrix is calculated using \R{}. -Unfortunately, \WinBUGS{} does not support a list format such as directly produced by \R{}. -Therefore, the data must be provided as a matrix with 2132 rows and 873 columns (or vice versa). -Most of the entries of this matrix are zeroes, but using \verb+dump()+ to export it from \R{} -yields in a file size of 14.2~MB. -Unfortunately, opening a file of such size really slows \WinBUGS{} down, -and it was not even possible on some of our PCs. -Importing data written by our \RW{} package does not make any problems using the batch mode, -probably due to memory management issues in \WinBUGS{}. - - -\section{Implementation}\label{Programming} -The implementation of the \RW{} package is straightforward. -The ``main'' function \verb+bugs()+ is intended to be called by the user. -In principle, it is a wrapper for several other functions called therein step by step as follows: -\begin{enumerate} - \item \verb+bugs.data.inits()+ writes the data files \file{data.txt}, and \file{inits1.txt}, \file{inits2.txt}, ... - into the working directory. These files will be used by \WinBUGS{} during batch processing. - - In particular, input for \WinBUGS{} must not exceed a certain number of digits. - Moreover, it needs an \verb+E+ instead of an \verb+e+ in scientific notation. - Scientific notation is particularly desirable because of the ``number of digits'' limitation. - The default (\verb+digits = 5+) is to, e.g., reformat the number \verb+123456.789+ to \verb@1.23457E+05@. - \item \verb+bugs.script()+ writes the file \file{script.txt} that is used by \WinBUGS{} for batch processing. - \item \verb+bugs.run()+ updates the lengths of the adaptive phases in the \WinBUGS{} registry - (using a function \verb+bugs.update.settings()+), - calls \WinBUGS{}, and runs it in batch mode with \file{script.txt}. - \item \verb+bugs.sims()+ is only called if the argument \verb+codaPkg+ has been set to \verb+FALSE+ (the default). - Otherwise \verb+bugs()+ returns the filenames of stored data. These can, for example, - be imported by package \pkg{coda} (see the example in Section~\ref{Leukaemia2}, page~\pageref{codaexample}), - which provides functions for convergence diagnostics, - calculation of Monte Carlo estimates, trace plots, and so forth. - - The function \verb+bugs.sims()+ reads simulations from \WinBUGS{} into \R{} (not necessarily called by \verb+bugs()+ - itself), formats them, - monitors convergence, performs convergence checks, and computes medians and quantiles. - It also prepares the output for \verb+bugs()+ itself. -\end{enumerate} -These functions are not intended to be called by the user directly. -Arguments are passed from \verb+bugs()+ to the other functions, if appropriate. -A shortened help file of \verb+bugs()+ listing all arguments is given in Appendix~\ref{Doc}; -for the full version type \verb+?bugs+ in \R{} after having installed and loaded the package \RW{} -(see Section~\ref{Introduction}). - -%\newpage -As known from \WinBUGS{}, one must specify the \verb+data+ in form of a list, with list names equal to the names -of data in the corresponding \WinBUGS{} model. Alternatively, it is possible to specify a vector or list of names -(of mode \verb+character+). In that case objects of that names are looked for in the environment in which -\verb+bugs()+ has been called (usually that is the user's Workspace, \verb+.GlobalEnv+). -%% Revision 2005-01-10 start -If data have already been written in a file called \file{data.txt} to the working directory, -it is possible to specify \verb+data = "data.txt"+. -%% Revision 2005-01-10 end -One will usually want to supply initial values. -This can be done either in the form of a function \verb+inits()+ that creates these values, so that -different chains can be automatically initialized at different points (see Section \ref{School2}), or by specifying them -directly (see Section \ref{Leukaemia2}). -If \verb+inits()+ is not specified, -\verb+bugs()+ just uses the starting values created by \WinBUGS{}; but in practice \WinBUGS{} can crash when -reasonable initial values are not specified, and so we recommend constructing a simple \verb+inits()+ function to -simulate reasonable starting points \cite[Section C.2]{Gelman:2003}. It is also necessary to specify which -parameters should be saved for monitoring by specifying \verb+parameters.to.save+. - -The user might also want to change the defaults for the length of the burn-in (\verb+n.burnin+, which defaults to half the length of the chain) -period for every MCMC run and the number of iterations (\verb+n.iter+, default value 3) -that are used to calculate Monte Carlo estimates. -%SS: Achtung: n.iter=n.burn.in + length of stored chain! -The specification of a thinning parameter (\verb+n.thin+) is possible as well; this is useful when the number of parameters is large, to keep the saved output to a reasonably-sized R object. In the default setting, the chains are thinned enough so that approximately 1000 simulation draws are saved. - -By setting the argument \verb+debug = TRUE+, -\WinBUGS{} remains open after the run. -This way it is possible to find errors in the code or the data structure, -or even to work with that software as in a usual run. - -It is possible to run one or more Markov chains. -The number of chains (\verb+n.chains+) must be specified together with the chains' initial values (\verb+inits+). -If more than one Markov chain is requested and \verb+codaPkg+ is set to \verb+FALSE+, the convergence diagnostic -$\hat{R}$ \citep{Brooks;Gelman:1998} is calculated by \verb+bugs.sims()+ for each of the saved parameters. - -%% Revision 2005-01-10 start -Since the communication between \WinBUGS{} and \R{} is based on files, -rather huge files will be saved in the working directory by the \verb+bugs()+ call, -either files to be read in by \verb+bugs()+ itself, or by the \pkg{coda} package. -The user might want to delete those files after the desired contents has been imported into \R{}, -and save those objects, e.g., as compressed \R{} data files. -%% Revision 2005-01-10 end - -The function \verb+bugs()+ returns a rather complex object of class \verb+bugs+, -if called with argument \verb+codaPkg = FALSE+. -In order to look at the structure of such an object, type \verb+str(objectname)+. -For convenience, \RW{} provides methods corresponding to class \verb+bugs+ for -the generic functions \verb+print()+ and \verb+plot()+. - -So that user will not be overwhelmed with information; summaries of the output are provided by the -\verb+print()+ method. That is, some parameters of the \verb+bugs()+ call are summarized, and mean, -standard deviation, several quantiles of the parameters and convergence diagnostics based on \cite{Gelman;Rubin:1992} -are printed. See the example in -Section~\ref{School2}, page~\pageref{schoolssim}, for a typical output. As with \cite{Spiegelhalter;Best;Carlin;vdLinde:2002}, -%\pagebreak - the DIC computed by \verb+bugs.sims()+ is defined as the posterior mean -of the deviance plus $p_D$, the estimated effective number of parameters in the posterior distribution. We define -$p_D$ as half the posterior variance of the deviance and estimate it as half the average of the within-chain -variances of the deviance.\footnote{In contrast, \cite{Spiegelhalter;Best;Carlin;vdLinde:2002}, - and WinBUGS, define $p_D$ as the -posterior mean of the deviance evaluated at the posterior mean of the parameter values. We cannot use that -definition because the deviance function is not available to our program, which calls \WinBUGS{} from the -``outside''. Both definitions of $p_D$---ours and that introduced by \cite{Spiegelhalter;Best;Carlin;vdLinde:2002}---can be -derived from the asymptotic $\chi^2$ distribution of the deviance relative to its minimum \citep[Section 6.7]{Gelman:2003}. -We make no claim that our measure of $p_D$ is superior to that of \cite{Spiegelhalter;Best;Carlin;vdLinde:2002}; -we choose this measure purely because it is computationally possible given what is available to us from the \WinBUGS{} output.} - - -The \verb+plot()+ for objects of class \verb+bugs+ -provides information condensed in some plots conveniently arranged within the same graphics device. -For an example, see Figure~\ref{plot} in Section~\ref{School2}. It is intended to adapt this function to work with MCMC output in general, even if obtained from software other than WinBUGS. - - - -\section{Examples continued}\label{Example2} -The Examples introduced in Section~\ref{Example2} are continued in this Section. -We apply the functions provided by \RW{} -to the examples' data and analyze the output. - -\subsection{Schools data}\label{School2} -Schools example data (see Section~\ref{School}) are available with the \RW{} package: -\begin{Code} - > data(schools) - > schools - school estimate sd - 1 A 28.39 14.9 - 2 B 7.94 10.2 - 3 C -2.75 16.3 - 4 D 6.82 11.0 - 5 E -0.64 9.4 - 6 F 0.63 11.4 - 7 G 18.01 10.4 - 8 H 12.16 17.6 -\end{Code} -For modeling these data, we use a hierarchical model as proposed by \citeauthor{Gelman:2003} (\citeyear{Gelman:2003}, Section 5.5). -We assume a normal distribution for the observed estimate for each school with -mean \verb+theta+ and inverse-variance \verb+tau.y+. -The inverse-variance is given as $1/\verb+sigma.y+^{2}$ and its prior distribution is uniform on (0,1000). For the mean -\verb+theta+, we employ another normal distribution with mean \verb+mu.theta+ and inverse-variance \verb+tau.theta+. For -their prior distributions, see the following \WinBUGS{} code: - - -\begin{Code} - model { - for (j in 1:J) - { - y[j] ~ dnorm (theta[j], tau.y[j]) - theta[j] ~ dnorm (mu.theta, tau.theta) - tau.y[j] <- pow(sigma.y[j], -2) - } - mu.theta ~ dnorm (0.0, 1.0E-6) - tau.theta <- pow(sigma.theta, -2) - sigma.theta ~ dunif (0, 1000) - } -\end{Code} -This model must be stored in a separate file, e.g.~\file{schools.bug}\footnote{Emacs Speaks Statistics (ESS) -by \cite{rossini04}, a package available with Gnu Emacs \citep{stallmann99}, -recognizes and properly formats Bugs model files that have the .bug extension.}, -in an appropriate directory, say \path{c:/schools/}. -In \R{} the user must prepare the data inputs the \verb+bugs()+ function needs. -This can be a list containing the name of each data vector, e.g. -\begin{Code} - > J <- nrow(schools) - > y <- schools$estimate - > sigma.y <- schools$sd - > data <- list ("J", "y", "sigma.y") -\end{Code} -Using these data and the model file, we can run an MCMC simulation to get estimates for \verb+theta+, -\verb+mu.theta+ and \verb+sigma.theta+. Before running, the user must decide how many chains to be run -(\verb+n.chain = 3+) for how many iterations (\verb+n.iter = 1000+). -If the length of burn-in is not specified, \verb+n.burnin = floor(n.iter/2)+ is used, that is, 500 in this example. -Additionally, the user must specify initial values for the chains, for example by writing a function. This can be done by -\begin{Code} - > inits <- function(){ - + list(theta = rnorm(J, 0, 100), mu.theta = rnorm(1, 0, 100), - + sigma.theta = runif(1, 0, 100)) - + } -\end{Code} -Now, the user can start the MCMC simulation by typing -\begin{Code} - > schools.sim <- bugs(data, inits, model.file = "c:/schools/schools.bug", - + parameters = c("theta", "mu.theta", "sigma.theta"), - + n.chains = 3, n.iter = 1000, - + bugs.directory = "c:/Program Files/WinBUGS14/") -\end{Code} -in \R{}.\label{schoolssim} The argument \verb+bugs.directory+ must point to the directory -where \WinBUGS{} has been installed. -For other available arguments, see Appendix \ref{Doc}. - -The results in objects \verb+schools.sim+ can conveniently be printed by \verb+print(schools.sim)+. -The generic function \verb+print()+ calls the print method for an object of class \verb+bugs+ -provided by \RW{}. -For this example, you will get something like - -\small -\begin{Code} - > print(schools.sim) - Inference for Bugs model at "c:/schools/schools.bug" - 3 chains, each with 1000 iterations (first 500 discarded) - n.sims = 1500 iterations saved - mean sd 2.5% 25% 50% 75% 97.5% Rhat n.eff - theta[1] 11.1 9.1 -3.0 5.0 10.0 16.0 31.8 1.1 39 - theta[2] 7.6 6.6 -4.7 3.3 7.8 11.6 21.1 1.1 42 - theta[3] 5.7 8.4 -12.5 0.6 6.1 10.8 21.8 1.0 150 - theta[4] 7.1 7.0 -6.6 2.7 7.2 11.5 21.0 1.1 42 - theta[5] 5.1 6.8 -9.5 0.7 5.2 9.7 18.1 1.0 83 - theta[6] 5.7 7.3 -9.7 1.0 6.2 10.2 20.0 1.0 56 - theta[7] 10.4 7.3 -2.1 5.3 9.8 15.3 25.5 1.1 27 - theta[8] 8.3 8.4 -6.6 2.8 8.1 12.7 26.2 1.0 64 - mu.theta 7.6 5.9 -3.0 3.7 8.0 11.0 19.5 1.1 35 - sigma.theta 6.7 5.6 0.3 2.8 5.1 9.2 21.2 1.1 46 - deviance 60.8 2.5 57.0 59.1 60.2 62.1 66.6 1.0 170 - pD = 3 and DIC = 63.8 (using the rule, pD = var(deviance)/2) - - For each parameter, n.eff is a crude measure of effective sample size, - and Rhat is the potential scale reduction factor (at convergence, Rhat=1). - DIC is an estimate of expected predictive error (lower deviance is better). -\end{Code} -\normalsize -Additionally, the user can generate a plot of the results by typing \verb+plot(schools.sim)+. -The resulting plot is given in Figure~\ref{plot}. -\begin{figure}[t] -\begin{center} -\fbox{ -\includegraphics[width=0.9\textwidth]{plot} -} \caption{\label{plot}Plot produced by \RW{} package for the schools example. } -\end{center} -\end{figure} -In this plot, the left column shows a quick -summary of inference and convergence ($\widehat{R}$ is close to 1.0 for all parameters, indicating good mixing of -the three chains and thus approximate convergence); and the right column shows inferences for each set of -parameters. As can be seen in the right column, \RW{} uses the parameter names in \WinBUGS{} to structure the -output into scalar, vector, and arrays of parameters, in addition to storing the parameters as a long vector. - -For the interpretation of these results see \citeauthor{Gelman:2003} (\citeyear{Gelman:2003}, Section 5.5). - -\subsection{Leukaemia registration data}\label{Leukaemia2} -The leukaemia registration data (see Section \ref{Leukaemia}) are used to show data modeling and output reading -into \R{} using the \pkg{coda} package. A simple model for these data looks as follows: -\begin{Code} -model{ - beta.0 ~ dgamma(a.0, tau.0) - beta.benz ~ dgamma(a.benz, tau.benz) - a.0 <- 0.575 - tau.0 <- a.0*2 - a.benz <- 0.575 - tau.benz <- a.benz*2 -\end{Code} -\clearpage -\begin{Code} - for (i in 1:I) - { - count[i] ~ dpois(lambda[i]) - lambda[i] <- p[i]*expect[i] - for (j in 1:J) - { - prop[j,i] <- gamma[j,i]*(benz[j] - benzbar) - } - p[i]<- beta.0 + beta.benz*sum(prop[,i]) - } - } -\end{Code} -Here \verb+count+ denotes the number of observed incidences of childhood leukaemia in ward~\verb+i+. These are -assumed to be Poisson distributed with mean \verb+lambda+ depending on the number of expected cases \verb+expect+ -in ward \verb+i+ and an area-specific risk rate \verb+p+. For calculation of this area specific risk rate we use -an intercept \verb+beta.0+ and a term depending on the weighted sum of benzene emissions \verb+benz+ in each grid -cell \verb+j+. The weights are chosen proportional to the amount of area that ward \verb+i+ and grid cell \verb+j+ have -in common. - -In \R{} we can define all these data and then initialize the model. The data needed for this example are -\begin{description} -\item[\tt{benzbar}:] arithmetic mean of all benzene values, -\item[\tt{benz}:] a vector containing benzene emissions of all 2132 grid cells, -\item[\tt{expect}:] expected number of cases of childhood leukaemia in each of the 873 wards, -\item[\tt{count}:] observed number of childhood leukaemia in these wards, -\item[\tt{gamma}:] a $2132\times 873$ matrix containing the amount of area each grid cell and each ward have in common, -\item[\tt{J}:] total number of grid cells, i.e.~2132, and -\item[\tt{I}:] total number of ward cells, i.e.~873. -\end{description} -The parameters we want to store are regression coefficients \verb+beta.0+ and \verb+beta.benz+ as well as -\verb+p+, the area specific relative risk compared to the reference rate. This reference rate was used to -calculate the expected number of cases in each ward. - -Since we want to use the \pkg{coda} package for reading the data into \WinBUGS{}, we specify \verb+codaPkg = TRUE+ -in the \verb+bugs()+ call: -\begin{Code} - > data <- list(benzbar = mean(benz), benz = benz, expect = expect, - + count = count, gamma = gamma, J = J, I = I) - > parameters <- c("beta.0", "beta.benz", "p") - > inits1 <- list(beta.0 = 1, beta.benz = 1) - > inits2 <- list(beta.0 = 0.5, beta.benz = 0.5) - > inits <- list(inits1, inits2) - > model <- bugs(data, inits, parameters, model.file = "c:/model.bug", - + n.chains = 2, n.iter = 8000, n.burnin = 5000, n.thin = 1, - + codaPkg = TRUE, bugs.directory = "c:/Program Files/WinBUGS14/") -\end{Code} - -\clearpage -Starting with, e.g.,\label{codaexample} -\begin{Code} - > library("coda") - > codaobject <- read.bugs(model) - > plot(codaobject) -\end{Code} -it is now possible to use the \pkg{coda} package for output analyses. - - -\section*{Acknowledgments} -The work of Uwe Ligges has been supported by the Deutsche Forschungsgemeinschaft, -Sonderforschungsbereich 475. -The work of Andrew Gelman has been supported by the U.S. National Science Foundation. - -\bibliography{literatur} - -\clearpage -\begin{appendix} -\section[Help page for the function bugs()]{Help page for the function \code{bugs()}\label{Doc}} -\small -This help page has been shortened. -\input{bugs} -\end{appendix} -\end{document} Deleted: trunk/R2WinBUGS/inst/doc/RdRW.sty =================================================================== --- trunk/R2WinBUGS/inst/doc/RdRW.sty 2012-07-24 08:42:13 UTC (rev 255) +++ trunk/R2WinBUGS/inst/doc/RdRW.sty 2013-04-07 17:13:29 UTC (rev 256) @@ -1,363 +0,0 @@ -%%% Rd.sty ... Style for printing the R manual -%%% -%%% Modified 1998/01/05 by Fri...@ci... -%%% Modified 1998/07/07 by Martin Maechler -%%% Modified 1999/11/20 by Brian Ripley -%%% Modified 1999/12/26 by Kurt Hornik -%%% and so on. - -\NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{Rd}{} - -\RequirePackage{ifthen} -\newboolean{Rd@has@ae} -\newboolean{Rd@use@ae} -\newboolean{Rd@use@hyper} -\newboolean{Rd@has@times} -\newboolean{Rd@use@times} -\newboolean{Rd@use@cm-super} -\newboolean{Rd@has@lm} -\newboolean{Rd@use@lm} -\DeclareOption{ae}{\setboolean{Rd@use@ae}{true}} -\DeclareOption{hyper}{\setboolean{Rd@use@hyper}{true}} -\DeclareOption{times}{\setboolean{Rd@use@times}{true}} -\DeclareOption{lm}{\setboolean{Rd@use@lm}{true}} -\DeclareOption{cm-super}{\setboolean{Rd@use@cm-super}{true}} -\ProcessOptions -\RequirePackage{longtable} -\setcounter{LTchunksize}{250} -\ifthenelse{\boolean{Rd@use@hyper}} -{\IfFileExists{hyperref.sty}{}{\setboolean{Rd@use@hyper}{false} - \message{package hyperref not found}}} -{} - -\RequirePackage{bm} % standard boldsymbol -\RequirePackage{alltt} % {verbatim} allowing \.. -\RequirePackage{verbatim} % small example code -\RequirePackage{url} % set urls - -%% See 'upquote.sty' for details. -%% We use \pkg{verbatim} for our ExampleCode environment, which in its -%% \verbatim@font has an explicit \let\do\do@noligs\verbatim@nolig@list -%% rather than (the identical) \@noligs from the LaTeX2e kernel. -%% Hence, we add to \verbatim@font ... suggestion by Bernd Raichle -%% <ra...@In...>. -\RequirePackage{upquote} -\g@addto@macro\verbatim@font\@noligs - -%% \addtolength{\textheight}{12mm} -%% \addtolength{\topmargin}{-9mm} % still fits on US paper -%% \addtolength{\textwidth}{24mm} % still fits on US paper -%% \setlength{\oddsidemargin}{10mm} -%% \setlength{\evensidemargin}{\oddsidemargin} - -\newenvironment{display}[0]% - {\begin{list}{}{\setlength{\leftmargin}{30pt}}\item}% - {\end{list}} -\newcommand{\HTML}{{\normalfont\textsc{html}}} -\newcommand{\R}{{\normalfont\textsf{R}}{}} -\newcommand{\Rdash}{-} - -\def\href#1#2{\special{html:<a href="#1">}{#2}\special{html:</a>}} - -\newcommand{\vneed}[1]{% - \penalty-1000\vskip#1 plus 10pt minus #1\penalty-1000\vspace{-#1}} - -\newcommand{\Rdcontents}[1]{% modified \tableofcontents -- not \chapter -\section*{{#1}\@mkboth{\MakeUppercase#1}{\MakeUppercase#1}} - \@starttoc{toc}} - -\newcommand{\Header}[2]{% - \vneed{1ex} - \markboth{#1}{#1} - \noindent - \nopagebreak - \begin{center} - \ifthenelse{\boolean{Rd@use@hyper}}% - {\def\@currentHref{page.\thepage} - \hypertarget{Rfn.#1}{\index{#1@\texttt{#1}}}% - \myaddcontentsline{toc}{subsection}{#1}% - \pdfbookmark[1]{#1}{Rfn.#1}} - {\addcontentsline{toc}{subsection}{#1} - \index{#1@\texttt{#1}|textbf}} - \hrule - \parbox{0.95\textwidth}{% - \begin{ldescription}[1.5in] - \item[\texttt{#1}] \emph{#2} - \end{ldescription}} - \hrule - \end{center} - \nopagebreak} -% -% -% -% \alias{<alias>}{<header>} -\ifthenelse{\boolean{Rd@use@hyper}} -{\newcommand{\alias}[2]{\hypertarget{Rfn.#1}{\index{#1@\texttt{#1} \textit{(\texttt{#2})}}}}} -{\newcommand{\alias}[2]{\index{#1@\texttt{#1} \textit{(\texttt{#2})}}}} -\ifthenelse{\boolean{Rd@use@hyper}} -{\newcommand{\methalias}[2]{\hypertarget{Rfn.#1}{\relax}}} -{\newcommand{\methalias}[2]{}} -% \keyword{<topic>}{<header>} -\newcommand{\keyword}[2]{\index{$*$Topic{\large\ \textbf{#1}}!#2@\texttt{#2}}} -% -\newcommand{\Itemize}[1]{\begin{itemize}{#1}\end{itemize}} -\newcommand{\Enumerate}[1]{\begin{enumerate}{#1}\end{enumerate}} -\newcommand{\describe}[1]{\begin{description}{#1}\end{description}} - -\newcommand{\Tabular}[2]{% - \par\begin{longtable}{#1} - #2 - \end{longtable}} - -\newlength{\ldescriptionwidth} -\newcommand{\ldescriptionlabel}[1]{% - \settowidth{\ldescriptionwidth}{{#1}}% - \ifdim\ldescriptionwidth>\labelwidth - {\parbox[b]{\labelwidth}% - {\makebox[0pt][l]{#1}\\[1pt]\makebox{}}}% - \else - \makebox[\labelwidth][l]{{#1}}% - \fi - \hfil\relax} -\newenvironment{ldescription}[1][1in]% - {\begin{list}{}% - {\setlength{\labelwidth}{#1}% - \setlength{\leftmargin}{\labelwidth}% - \addtolength{\leftmargin}{\labelsep}% - \renewcommand{\makelabel}{\ldescriptionlabel}}}% - {\end{list}} - -\newenvironment{Rdsection}[1]{% - \ifx\@empty#1\else\subsubsection*{#1}\fi - \begin{list}{}{\setlength{\leftmargin}{0.25in}}\item} - {\end{list}} - -\newenvironment{Arguments}{% - \begin{Rdsection}{Arguments}}{\end{Rdsection}} -\newenvironment{Author}{% - \begin{Rdsection}{Author(s)}}{\end{Rdsection}} -\newenvironment{Description}{% - \begin{Rdsection}{Description}}{\end{Rdsection}} -\newenvironment{Details}{% - \begin{Rdsection}{Details}}{\end{Rdsection}} -\newenvironment{Examples}{% - \begin{Rdsection}{Examples}}{\end{Rdsection}} -\newenvironment{Note}{% - \begin{Rdsection}{Note}}{\end{Rdsection}} -\newenvironment{References}{% - \begin{Rdsection}{References}}{\end{Rdsection}} -\newenvironment{SeeAlso}{% - \begin{Rdsection}{See Also}}{\end{Rdsection}} -\newenvironment{Format}{% - \begin{Rdsection}{Format}}{\end{Rdsection}} -\newenvironment{Source}{% - \begin{Rdsection}{Source}}{\end{Rdsection}} -\newenvironment{Section}[1]{% - \begin{Rdsection}{#1}}{\end{Rdsection}} -\newenvironment{Usage}{% - \begin{Rdsection}{Usage}}{\end{Rdsection}} -\newenvironment{Value}{% - \begin{Rdsection}{Value}}{\end{Rdsection}} - -\newenvironment{ExampleCode}{\small\verbatim}{\endverbatim} - -\ifx\textbackslash\undefined%-- e.g. for MM - \newcommand{\bsl}{\ifmmode\backslash\else$\backslash$\fi} -\else - \newcommand{\bsl}{\ifmmode\backslash\else\textbackslash\fi} -\fi -%fails for index (but is not used there...) -\newcommand{\SIs}{\relax\ifmmode\leftarrow\else$\leftarrow$\fi} -\newcommand{\SIIs}{\relax\ifmmode<\leftarrow\else$<\leftarrow$\fi} -\newcommand{\Sbecomes}{\relax\ifmmode\rightarrow\else$\rightarrow$\fi} -% -\newcommand{\deqn}[2]{\[#1\]} -\newcommand{\eqn}[2]{$#1$} -\newcommand{\bold}[1]{\ifmmode\bm{#1}\else\textbf{#1}\fi} -\newcommand{\file}[1]{`\textsf{#1}'} - -\ifthenelse{\boolean{Rd@use@hyper}} -{\newcommand{\link}[1]{\hyperlink{Rfn.#1}{#1}\index{#1@\texttt{#1}}}} -{\newcommand{\link}[1]{#1\index{#1@\texttt{#1}}}} - -\newcommand{\email}[1]{$\langle${#1}$\rangle$} - -%% \code without `-' ligatures -{\catcode`\-=\active% - \global\def\code{\bgroup% - \catcode`\-=\active \let-\codedash% - \Rd@code}} -\def\codedash{-\discretionary{}{}{}} -\def\Rd@code#1{\texttt{#1}\egroup} - -\def\AsIs{\bgroup\let\do\@makeother\Rd@AsIs@dospecials\Rd@AsIsX} -\def\Rd@AsIs@dospecials{\do\$\do\&\do\#\do\^\do\_\do\%\do\~} -\def\Rd@AsIsX#1{\normalfont #1\egroup} -\let\command=\code -\let\env=\code - -\newcommand\samp{`\bgroup\@noligs\@sampx} -\def\@sampx#1{{\normalfont\texttt{#1}}\egroup'} -\let\option=\samp - -\newcommand{\var}[1]{{\normalfont\textsl{#1}}} - -\newcommand{\dfn}[1]{\textsl{#1}} -\let\Cite=\dfn - -\newcommand{\acronym}[1]{\textsc{\lowercase{#1}}} -\newcommand{\kbd}[1]{\texttt{\textsl{#1}}} - -\newcommand{\strong}[1]{{\normalfont\fontseries{b}\selectfont #1}} -\let\pkg=\strong - -\newcommand{\sQuote}[1]{`#1'} -\newcommand{\dQuote}[1]{``#1''} - -\IfFileExists{ae.sty}{\setboolean{Rd@has@ae}{true}}{} -\ifthenelse{\boolean{Rd@use@ae}\and\boolean{Rd@has@ae}}{% - \usepackage[T1]{fontenc} - \usepackage{ae} - \input{t1aett.fd} - \DeclareFontShape{T1}{aett}{bx}{n}{<->ssub*aett/m/n}{}} - {\message{NOT loading ae}} -\IfFileExists{times.sty}{\setboolean{Rd@has@times}{true}}{} -\ifthenelse{\boolean{Rd@use@times}\and\boolean{Rd@has@times}}{% - \usepackage[T1]{fontenc} - \usepackage{times}} - {\message{NOT loading times}} -\IfFileExists{lmodern.sty}{\setboolean{Rd@has@lm}{true}}{} -\ifthenelse{\boolean{Rd@use@lm}\and\boolean{Rd@has@lm}}{% - \usepackage[T1]{fontenc} - \usepackage{lmodern}} - {\message{NOT loading lmodern}} -\ifthenelse{\boolean{Rd@use@cm-super}}{% - \usepackage[T1]{fontenc}}{} - -\ifthenelse{\boolean{Rd@use@hyper}}{% - \RequirePackage{color} - \def\myaddcontentsline#1#2#3{% - \addtocontents{#1}{\protect\contentsline{#2}{#3}{\thepage}{page.\thepage}}} - \RequirePackage{hyperref} - \DeclareTextCommand{\Rpercent}{PD1}{\045} % percent - %% <NOTE> - %% Formerly in R's hyperref.cfg, possibly to be shared with Sweave.sty - %% as well (but without setting pagebackref as this can give trouble - %% for .bib entries containing URLs with '#' characters). - \definecolor{Blue}{rgb}{0,0,0.8} - \definecolor{Red}{rgb}{0.7,0,0} - \hypersetup{% - hyperindex,% - colorlinks,% - pagebackref,% - linktocpage,% - plainpages=false,% - linkcolor=Blue,% - citecolor=Blue,% - urlcolor=Red,% - pdfstartview=Fit,% - pdfview={XYZ null null null}% - } - %% </NOTE> - \renewcommand\tableofcontents{% - \if@twocolumn - \@restonecoltrue\onecolumn - \else - \@restonecolfalse - \fi - \chapter*{\contentsname - \@mkboth{% - \MakeUppercase\contentsname}{\MakeUppercase\contentsname}}% - \pdfbookmark{Contents}{contents} - \@starttoc{toc}% - \if@restonecol\twocolumn\fi - } - \renewenvironment{theindex} - {\if@twocolumn - \@restonecolfalse - \else - \@restonecoltrue - \fi - \columnseprule \z@ - \columnsep 35\p@ - \twocolumn[\@makeschapterhead{\indexname}]% - \@mkboth{\MakeUppercase\indexname}% - {\MakeUppercase\indexname}% - \pdfbookmark{Index}{index} - \myaddcontentsline{toc}{chapter}{Index} - \thispagestyle{plain}\parindent\z@ - \parskip\z@ \@plus .3\p@\relax - \raggedright - \let\item\@idxitem} - {\if@restonecol\onecolumn\else\clearpage\fi} - }{ - \renewenvironment{theindex} - {\if@twocolumn - \@restonecolfalse - \else - \@restonecoltrue - \fi - \columnseprule \z@ - \columnsep 35\p@ - \twocolumn[\@makeschapterhead{\indexname}]% - \@mkboth{\MakeUppercase\indexname}% - {\MakeUppercase\indexname}% - \addcontentsline{toc}{chapter}{Index} - \thispagestyle{plain}\parindent\z@ - \parskip\z@ \@plus .3\p@\relax - \raggedright - \let\item\@idxitem} - {\if@restonecol\onecolumn\else\clearpage\fi} - } - -% new definitions for R >= 2.0.0 -\ifthenelse{\boolean{Rd@use@hyper}} -{\newcommand{\LinkA}[2]{\hyperlink{Rfn.#2}{#1}\index{#1@\texttt{#1}|textit}}} -{\newcommand{\LinkA}[2]{#1\index{#1@\texttt{#1}|textit}}} -% -% \alias{<alias>}{<header>} -\ifthenelse{\boolean{Rd@use@hyper}} -{\newcommand{\aliasA}[3]{\hypertarget{Rfn.#3}{\index{#1@\texttt{#1} \textit{(\texttt{#2})}}}}} -{\newcommand{\aliasA}[3]{\index{#1@\texttt{#1} \textit{(\texttt{#2})}}}} -\ifthenelse{\boolean{Rd@use@hyper}} -{\newcommand{\methaliasA}[3]{\hypertarget{Rfn.#3}{\relax}}} -{\newcommand{\methaliasA}[3]{}} -\newcommand{\HeaderA}[3]{% - \vneed{1ex} - \markboth{#1}{#1} - \noindent - \nopagebreak - \begin{center} - \ifthenelse{\boolean{Rd@use@hyper}}% - {\def\@currentHref{page.\thepage} - \hypertarget{Rfn.#3}{\index{#1@\texttt{#1}}}% - \myaddcontentsline{toc}{subsection}{#1}% - \pdfbookmark[1]{#1}{Rfn.#3}} - {\addcontentsline{toc}{subsection}{#1} - \index{#1@\texttt{#1}|textbf}} - \hrule - \parbox{0.95\textwidth}{% - \begin{ldescription}[1.5in] - \item[\texttt{#1}] \emph{#2} - \end{ldescription}} - \hrule - \end{center} - \nopagebreak} -\DeclareTextCommandDefault{\Rpercent}{\%{}} -%% for use with the output of encoded_text_to_latex -\ProvideTextCommandDefault{\textdegree}{\ensuremath{{^\circ}}} -\ProvideTextCommandDefault{\textonehalf}{\ensuremath{\frac12}} -\ProvideTextCommandDefault{\textonequarter}{\ensuremath{\frac14}} -\ProvideTextCommandDefault{\textthreequarters}{\ensuremath{\frac34}} -\ProvideTextCommandDefault{\textcent}{\TextSymbolUnavailable\textcent} -\ProvideTextCommandDefault{\textyen}{\TextSymbolUnavailable\textyen} -\ProvideTextCommandDefault{\textcurrency}{\TextSymbolUnavailable\textcurrency} -\ProvideTextCommandDefault{\textbrokenbar}{\TextSymbolUnavailable\textbrokenbar} -\ProvideTextCommandDefault{\texteuro}{\TextSymbolUnavailable\texteuro} -\providecommand{\mathonesuperior}{\ensuremath{^1}} -\providecommand{\mathtwosuperior}{\ensuremath{^2}} -\providecommand{\maththreesuperior}{\ensuremath{^3}} - -\InputIfFileExists{Rd.cfg}{% - \typeout{Reading personal defaults ...}}{} Deleted: trunk/R2WinBUGS/inst/doc/Z.cls =================================================================== --- trunk/R2WinBUGS/inst/doc/Z.cls 2012-07-24 08:42:13 UTC (rev 255) +++ trunk/R2WinBUGS/inst/doc/Z.cls 2013-04-07 17:13:29 UTC (rev 256) @@ -1,183 +0,0 @@ -\def\fileversion{1.0} -\def\filename{Z} -\def\filedate{2004/10/08} -%% -%% Package `Z' to use with LaTeX2e for Z reports -%% Copyright (C) 2004 Achim Zeileis -%% -\NeedsTeXFormat{LaTeX2e} -\ProvidesClass{Z}[\filedate\space\fileversion\space Z class by Achim Zeileis] - -%% options -\LoadClass[10pt,a4paper,twoside]{article} -\newif\if@notitle -\@notitlefalse -\DeclareOption{notitle}{\@notitletrue} -\ProcessOptions - -%% required packages -\RequirePackage{graphicx,a4wide,color,hyperref,ae,fancyvrb,thumbpdf} -\RequirePackage[T1]{fontenc} -\usepackage[authoryear,round,longnamesfirst]{natbib} -\bibpunct{(}{)}{;}{a}{}{,} -\bibliographystyle{literatur} - -%% paragraphs -\setlength{\parskip}{0.7ex plus0.1ex minus0.1ex} -\setlength{\parindent}{0em} - -%% commands -\let\code=\texttt -\let\proglang=\textsf -\newcommand{\E}{\mathsf{E}} -\newcommand{\VAR}{\mathsf{VAR}} -\newcommand{\COV}{\mathsf{COV}} -\newcommand{\Prob}{\mathsf{P}} - -%% for all publications -\newcommand{\Plaintitle}[1]{\def\@Plaintitle{#1}} -\newcommand{\Shorttitle}[1]{\def\@Shorttitle{#1}} -\newcommand{\Plainauthor}[1]{\def\@Plainauthor{#1}} -\newcommand{\Keywords}[1]{\def\@Keywords{#1}} -\newcommand{\Plainkeywords}[1]{\def\@Plainkeywords{#1}} -\newcommand{\Abstract}[1]{\def\@Abstract{#1}} - -%% defaults -\author{Firstname Lastname\\Affiliation} -\title{Title} -\Abstract{---!!!---an abstract is required---!!!---} -\Plainauthor{\@author} -\Plaintitle{\@title} -\Shorttitle{\@title} -\Keywords{---!!!---at least one keyword is required---!!!---} -\Plainkeywords{\@Keywords} - -%% Sweave(-like) -\DefineVerbatimEnvironment{Sinput}{Verbatim}{fontshape=sl} -\DefineVerbatimEnvironment{Soutput}{Verbatim}{} -\DefineVerbatimEnvironment{Scode}{Verbatim}{fontshape=sl} -%\newenvironment{Schunk}{}{} -\DefineVerbatimEnvironment{Code}{Verbatim}{} -\DefineVerbatimEnvironment{CodeInput}{Verbatim}{fontshape=sl} -\DefineVerbatimEnvironment{CodeOutput}{Verbatim}{} -\newenvironment{CodeChunk}{}{} -\setkeys{Gin}{width=0.8\textwidth} - -%% new \maketitle -\def\maketitle{ - \begingroup - \def\thefootnote{\fnsymbol{footnote}} - \def\@makefnmark{\hbox to 0pt{$^{\@thefnmark}$\hss}} - \long\def\@makefntext##1{\parindent 1em\noindent - \hbox to1.8em{\hss $\m@th ^{\@thefnmark}$}##1} - \@maketitle \@thanks - \endgroup - \setcounter{footnote}{0} - \thispagestyle{empty} - \markboth{\centerline{\@Shorttitle}}{\centerline{\@Plainauthor}} - \pagestyle{myheadings} - - \let\maketitle\relax \let\@maketitle\relax - \gdef\@thanks{}\gdef\@author{}\gdef\@title{}\let\thanks\relax -} - -\def\@maketitle{\vbox{\hsize\textwidth \linewidth\hsize - {\centering - {\LARGE\bf \@title\par} - \def\And{\end{tabular}\hfil\linebreak[0]\hfil - \begin{tabular}[t]{c}\large\bf\rule{\z@}{24pt}\ignorespaces}% - \begin{tabular}[t]{c}\large\bf\rule{\z@}{24pt}\@author\end{tabular}% - \vskip 0.3in minus 0.1in - \hrule - \begin{abstract} - \@Abstract - \end{abstract}} - \textit{Keywords}:~\@Keywords. - \vskip 0.1in minus 0.05in - \hrule - \vskip 0.2in minus 0.1in -}} - - -%% sections, subsections, and subsubsections -\newlength{\preXLskip} -\newlength{\preLskip} -\newlength{\preMskip} -\newlength{\preSskip} -\newlength{\postMskip} -\newlength{\postSskip} -\setlength{\preXLskip}{1.8\baselineskip plus 0.5ex minus 0ex} -\setlength{\preLskip}{1.5\baselineskip plus 0.3ex minus 0ex} -\setlength{\preMskip}{1\baselineskip plus 0.2ex minus 0ex} -\setlength{\preSskip}{.8\baselineskip plus 0.2ex minus 0ex} -\setlength{\postMskip}{.5\baselineskip plus 0ex minus 0.1ex} -\setlength{\postSskip}{.3\baselineskip plus 0ex minus 0.1ex} - -\newcommand{\jsssec}[2][default]{\vskip \preXLskip% - \pdfbookmark[1]{#1}{Section.\thesection.#1}% - \refstepcounter{section}% - \centerline{\textbf{\Large \thesection. #2}} \nopagebreak - \vskip \postMskip \nopagebreak} -\newcommand{\jsssecnn}[1]{\vskip \preXLskip% - \centerline{\textbf{\Large #1}} \nopagebreak - \vskip \postMskip \nopagebreak} - -\newcommand{\jsssubsec}[2][default]{\vskip \preMskip% - \pdfbookmark[2]{#1}{Subsection.\thesubsection.#1}% - \refstepcounter{subsection}% - \textbf{\large \thesubsection. #2} \nopagebreak - \vskip \postSskip \nopagebreak} -\newcommand{\jsssubsecnn}[1]{\vskip \preMskip% - \textbf{\large #1} \nopagebreak - \vskip \postSskip \nopagebreak} - -\newcommand{\jsssubsubsec}[2][default]{\vskip \preSskip% - \pdfbookmark[3]{#1}{Subsubsection.\thesubsubsection.#1}% - \refstepcounter{subsubsection}% - {\large \textit{#2}} \nopagebreak - \vskip \postSskip \nopagebreak} -\newcommand{\jsssubsubsecnn}[1]{\vskip \preSskip% - {\textit{\large #1}} \nopagebreak - \vskip \postSskip \nopagebreak} - -\newcommand{\jsssimplesec}[2][default]{\vskip \preLskip% -%% \pdfbookmark[1]{#1}{Section.\thesection.#1}% - \refstepcounter{section}% - \textbf{\large #1} \nopagebreak - \vskip \postSskip \nopagebreak} -\newcommand{\jsssimplesecnn}[1]{\vskip \preLskip% - \textbf{\large #1} \nopagebreak - \vskip \postSskip \nopagebreak} - -\renewcommand{\section}{\secdef \jsssec \jsssecnn} -\renewcommand{\subsection}{\secdef \jsssubsec \jsssubsecnn} -\renewcommand{\subsubsection}{\secdef \jsssubsubsec \jsssubsubsecnn} - -%% colors -\definecolor{Red}{rgb}{0.7,0,0} -\definecolor{Blue}{rgb}{0,0,0.8} -\hypersetup{% - hyperindex = {true}, - colorlinks = {true}, - linktocpage = {true}, - plainpages = {false}, - linkcolor = {Blue}, - citecolor = {Blue}, - urlcolor = {Red}, - pdfstartview = {Fit}, - pdfpagemode = {UseOutlines}, - pdfview = {XYZ null null null} -} - -\AtBeginDocument{ - \hypersetup{% - pdfauthor = {\@Plainauthor}, - pdftitle = {\@Plaintitle}, - pdfkeywords = {\@Plainkeywords} - } -} -\if@notitle - %% \AtBeginDocument{\maketitle} -\else - \AtBeginDocument{\maketitle} -\fi Deleted: trunk/R2WinBUGS/inst/doc/benzolsw.pdf =================================================================== --- trunk/R2WinBUGS/inst/doc/benzolsw.pdf 2012-07-24 08:42:13 UTC (rev 255) +++ trunk/R2WinBUGS/inst/doc/benzolsw.pdf 2013-04-07 17:13:29 UTC (rev 256) @@ -1,871 +0,0 @@ -%PDF-1.1 -%\xBF\xF7\xA2\xFE -1 0 obj -<< /Pages 3 0 R /Type /Catalog >> -endobj -2 0 obj -<< /CreationDate (D:20040419142809) /Creator (R) /ModDate (D:20040419142809) /Producer (R 1.8.1) /Title (R Graphics Output) >> -endobj -3 0 obj -<< /Count 1 /Kids [ 4 0 R ] /MediaBox [ 0 0 432 216 ] /Type /Pages >> -endobj -4 0 obj -<< /Contents 5 0 R /Parent 3 0 R /Resources 6 0 R /Type /Page >> -endobj -5 0 obj -<< /Length 100248 /Filter /FlateDecode >> -stream -x\x9C\x8C\xFDK\xAE.9\xAF\xF6\xEF(\xCE\xA1\xB74ܨ\xEAT\xA3\xE0΅ -ƿ -\xD8O\xDF[⛔N\xBAs\x90\xB9vI\xE9\x93(\xD7 -E\xFA\xF3?\xFEI\xFE\xF7?\xE9\xFB\xF3?\xFD\xF9?\xFF\xEB\xFF\xF3\xE7\xFF\xFC\xF3\xFD\xF3}\xF0O^ퟕ\xFF\xE4\xD4\xF7\xFF\xFD_\xFF\xEB\x9F\xFFߟ\xFF\xE3\xBF\xD2\xEF\x9A\xCEU\xBF\xF8\xDF\xFE\xEBCP\xFE\xFD\xFF\xFE\xBF\xE0h\xFE\xEF\xFF\xFA\xFF\xFF\xCF\xBE?\xFF\xCB\xFD\xF9\xD3\xFA?}\xFC\xC9_\xF9g\xB6?? -\xA8\xFF\xCC\xF4\xE7? -\xE8\xFF\x8C\xC0\xF8\xE7k\xA0+\xC6?\xE5\x83+&m0 n\xF9 |
From: <chr...@us...> - 2012-07-24 08:42:24
|
Revision: 255 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=255&view=rev Author: chris-jackson Date: 2012-07-24 08:42:13 +0000 (Tue, 24 Jul 2012) Log Message: ----------- Depend on OpenBUGS 3.2.2, and find documentation from both source and binary installations. Modified Paths: -------------- trunk/BRugs/configure trunk/BRugs/configure.ac Modified: trunk/BRugs/configure =================================================================== --- trunk/BRugs/configure 2012-07-23 17:47:46 UTC (rev 254) +++ trunk/BRugs/configure 2012-07-24 08:42:13 UTC (rev 255) @@ -1,11 +1,11 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.65 for BRugs 0.7. +# Generated by GNU Autoconf 2.68 for BRugs 0.8. # # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. +# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software +# Foundation, Inc. # # # This configure script is free software; the Free Software Foundation @@ -89,6 +89,7 @@ IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. +as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -213,11 +214,18 @@ # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. + # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV export CONFIG_SHELL - exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} + case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; + esac + exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"} fi if test x$as_have_required = xno; then : @@ -315,7 +323,7 @@ test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p @@ -355,19 +363,19 @@ fi # as_fn_arith -# as_fn_error ERROR [LINENO LOG_FD] -# --------------------------------- +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with status $?, using 1 if that was 0. +# script with STATUS, using 1 if that was 0. as_fn_error () { - as_status=$?; test $as_status -eq 0 && as_status=1 - if test "$3"; then - as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi - $as_echo "$as_me: error: $1" >&2 + $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error @@ -529,7 +537,7 @@ exec 6>&1 # Name of the host. -# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, +# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` @@ -548,8 +556,8 @@ # Identity of this package. PACKAGE_NAME='BRugs' PACKAGE_TARNAME='brugs' -PACKAGE_VERSION='0.7' -PACKAGE_STRING='BRugs 0.7' +PACKAGE_VERSION='0.8' +PACKAGE_STRING='BRugs 0.8' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -680,8 +688,9 @@ fi case $ac_option in - *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; - *) ac_optarg=yes ;; + *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *=) ac_optarg= ;; + *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. @@ -726,7 +735,7 @@ ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error "invalid feature name: $ac_useropt" + as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -752,7 +761,7 @@ ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error "invalid feature name: $ac_useropt" + as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -956,7 +965,7 @@ ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error "invalid package name: $ac_useropt" + as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -972,7 +981,7 @@ ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error "invalid package name: $ac_useropt" + as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1002,8 +1011,8 @@ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; - -*) as_fn_error "unrecognized option: \`$ac_option' -Try \`$0 --help' for more information." + -*) as_fn_error $? "unrecognized option: \`$ac_option' +Try \`$0 --help' for more information" ;; *=*) @@ -1011,7 +1020,7 @@ # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) - as_fn_error "invalid variable name: \`$ac_envvar'" ;; + as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; @@ -1021,7 +1030,7 @@ $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 - : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} + : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac @@ -1029,13 +1038,13 @@ if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` - as_fn_error "missing argument to $ac_option" + as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; - fatal) as_fn_error "unrecognized options: $ac_unrecognized_opts" ;; + fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi @@ -1058,7 +1067,7 @@ [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac - as_fn_error "expected an absolute directory name for --$ac_var: $ac_val" + as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' @@ -1072,8 +1081,8 @@ if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe - $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. - If a cross compiler is detected then cross compile mode will be used." >&2 + $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used" >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi @@ -1088,9 +1097,9 @@ ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || - as_fn_error "working directory cannot be determined" + as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || - as_fn_error "pwd does not report name of working directory" + as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. @@ -1129,11 +1138,11 @@ fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." - as_fn_error "cannot find sources ($ac_unique_file) in $srcdir" + as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( - cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error "$ac_msg" + cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then @@ -1159,7 +1168,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures BRugs 0.7 to adapt to many kinds of systems. +\`configure' configures BRugs 0.8 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1173,7 +1182,7 @@ --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit - -q, --quiet, --silent do not print \`checking...' messages + -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files @@ -1220,15 +1229,15 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of BRugs 0.7:";; + short | recursive ) echo "Configuration of BRugs 0.8:";; esac cat <<\_ACEOF Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) - --with-openbugs=PATH the location of OpenBUGS installed from the source - package, by default /usr/local/lib/OpenBUGS + --with-openbugs=PATH the location of the OpenBUGS installation, by + default /usr/local Some influential environment variables: CC C compiler command @@ -1305,10 +1314,10 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -BRugs configure 0.7 -generated by GNU Autoconf 2.65 +BRugs configure 0.8 +generated by GNU Autoconf 2.68 -Copyright (C) 2009 Free Software Foundation, Inc. +Copyright (C) 2010 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF @@ -1352,7 +1361,7 @@ ac_retval=1 fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile @@ -1398,7 +1407,7 @@ # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_link @@ -1406,8 +1415,8 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by BRugs $as_me 0.7, which was -generated by GNU Autoconf 2.65. Invocation command line was +It was created by BRugs $as_me 0.8, which was +generated by GNU Autoconf 2.68. Invocation command line was $ $0 $@ @@ -1517,11 +1526,9 @@ { echo - cat <<\_ASBOX -## ---------------- ## + $as_echo "## ---------------- ## ## Cache variables. ## -## ---------------- ## -_ASBOX +## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( @@ -1555,11 +1562,9 @@ ) echo - cat <<\_ASBOX -## ----------------- ## + $as_echo "## ----------------- ## ## Output variables. ## -## ----------------- ## -_ASBOX +## ----------------- ##" echo for ac_var in $ac_subst_vars do @@ -1572,11 +1577,9 @@ echo if test -n "$ac_subst_files"; then - cat <<\_ASBOX -## ------------------- ## + $as_echo "## ------------------- ## ## File substitutions. ## -## ------------------- ## -_ASBOX +## ------------------- ##" echo for ac_var in $ac_subst_files do @@ -1590,11 +1593,9 @@ fi if test -s confdefs.h; then - cat <<\_ASBOX -## ----------- ## + $as_echo "## ----------- ## ## confdefs.h. ## -## ----------- ## -_ASBOX +## ----------- ##" echo cat confdefs.h echo @@ -1649,7 +1650,12 @@ ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then - ac_site_file1=$CONFIG_SITE + # We do not want a PATH search for config.site. + case $CONFIG_SITE in #(( + -*) ac_site_file1=./$CONFIG_SITE;; + */*) ac_site_file1=$CONFIG_SITE;; + *) ac_site_file1=./$CONFIG_SITE;; + esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site @@ -1664,7 +1670,11 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 - . "$ac_site_file" + . "$ac_site_file" \ + || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "failed to load site script $ac_site_file +See \`config.log' for more details" "$LINENO" 5; } fi done @@ -1740,7 +1750,7 @@ $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} - as_fn_error "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 + as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## @@ -1754,16 +1764,6 @@ -## Work around the inconsistency between the installation destinations of the 3.2.1 source and binary packages. -## Source installs library in $prefix/lib/OpenBUGS/lib, doc in $prefix/lib/OpenBUGS/doc. -## Binaries install in standards-compliant locations $prefix/lib and $prefix/share/doc/openbugs-version respectively. -## Look in all of these places. -## Return OPENBUGS = $prefix/lib/OpenBUGS for source installations, and -## OPENBUGS = $prefix for binary installations. -## Return OPENBUGSDOC = $prefix/lib/OpenBUGS/doc for source installations, -## and OPENBUGSDOC = $prefix/share/doc/openbugs-version for binary installations. -## If user specifies -with-openbugs, this is interpreted for a source installation. - ## TODO only runs on x86 Linux - give error on other unixes. @@ -1773,7 +1773,7 @@ set dummy OpenBUGS; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_ac_prefix_program+set}" = set; then : +if ${ac_cv_path_ac_prefix_program+:} false; then : $as_echo_n "(cached) " >&6 else case $ac_prefix_program in @@ -1869,21 +1869,29 @@ if test -n "$openbugs_path" ; then OPENBUGS=${openbugs_path} - SOURCEINST=true else if test "$prefix" = "NONE" ; then - as_fn_error "OpenBUGS not found. Install OpenBUGS 3.2.1 or later, or specify its location using, for example, R CMD INSTALL BRugs --configure-args='--with-openbugs=/usr/local/lib/OpenBUGS' " "$LINENO" 5 + as_fn_error $? "OpenBUGS 3.2.2 or later not found. Install it, or specify its location using, for example, R CMD INSTALL BRugs --configure-args='--with-openbugs=/usr/local' " "$LINENO" 5 else - if test -e ${prefix}/lib/OpenBUGS/lib/libOpenBUGS.so ; then - OPENBUGS=${prefix}/lib/OpenBUGS - SOURCEINST=true - else + if test -e ${prefix}/lib/libOpenBUGS.so ; then OPENBUGS=${prefix} - SOURCEINST=false + elif test -e ${prefix}/lib/OpenBUGS/lib/libOpenBUGS.so ; then # for 3.2.1 + OPENBUGS=${prefix} fi fi fi +VERSION=`echo "modelQuit()" | ${OPENBUGS}/bin/OpenBUGS | sed -ne "s/OpenBUGS version \(.*\) rev \(.*\)/\1/p"` +if test `echo ${VERSION} |cut -d. -f1` -lt 3; then + as_fn_error $? "Requires OpenBUGS version 3.2.2 or greater" "$LINENO" 5 +fi +if test `echo ${VERSION} |cut -d. -f1` -eq 3 -a `echo ${VERSION} |cut -d. -f2` -lt 2 ; then + as_fn_error $? "Requires OpenBUGS version 3.2.2 or greater" "$LINENO" 5 +fi +if test `echo ${VERSION} |cut -d. -f1` -eq 3 -a `echo ${VERSION} |cut -d. -f2` -eq 2 -a `echo ${VERSION} |cut -d. -f3` -lt 2 ; then + as_fn_error $? "Requires OpenBUGS version 3.2.2 or greater" "$LINENO" 5 +fi + OLDFLAGS=${LDFLAGS} LDFLAGS="-L${OPENBUGS}/lib -m32" ac_ext=c @@ -1896,7 +1904,7 @@ set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : +if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -1936,7 +1944,7 @@ set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : +if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then @@ -1989,7 +1997,7 @@ set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : +if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -2029,7 +2037,7 @@ set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : +if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -2088,7 +2096,7 @@ set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : +if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -2132,7 +2140,7 @@ set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : +if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then @@ -2186,8 +2194,8 @@ test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "no acceptable C compiler found in \$PATH -See \`config.log' for more details." "$LINENO" 5; } +as_fn_error $? "no acceptable C compiler found in \$PATH +See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 @@ -2301,9 +2309,8 @@ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ as_fn_set_status 77 -as_fn_error "C compiler cannot create executables -See \`config.log' for more details." "$LINENO" 5; }; } +as_fn_error 77 "C compiler cannot create executables +See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -2345,8 +2352,8 @@ else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details." "$LINENO" 5; } +as_fn_error $? "cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 @@ -2403,9 +2410,9 @@ else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "cannot run C compiled programs. +as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. -See \`config.log' for more details." "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5; } fi fi fi @@ -2416,7 +2423,7 @@ ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } -if test "${ac_cv_objext+set}" = set; then : +if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -2456,8 +2463,8 @@ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "cannot compute suffix of object files: cannot compile -See \`config.log' for more details." "$LINENO" 5; } +as_fn_error $? "cannot compute suffix of object files: cannot compile +See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi @@ -2467,7 +2474,7 @@ ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -if test "${ac_cv_c_compiler_gnu+set}" = set; then : +if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -2504,7 +2511,7 @@ ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } -if test "${ac_cv_prog_cc_g+set}" = set; then : +if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag @@ -2582,7 +2589,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if test "${ac_cv_prog_cc_c89+set}" = set; then : +if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no @@ -2680,7 +2687,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for CmdInterpreter in -lOpenBUGS" >&5 $as_echo_n "checking for CmdInterpreter in -lOpenBUGS... " >&6; } -if test "${ac_cv_lib_OpenBUGS_CmdInterpreter+set}" = set; then : +if ${ac_cv_lib_OpenBUGS_CmdInterpreter+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -2714,7 +2721,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_OpenBUGS_CmdInterpreter" >&5 $as_echo "$ac_cv_lib_OpenBUGS_CmdInterpreter" >&6; } -if test "x$ac_cv_lib_OpenBUGS_CmdInterpreter" = x""yes; then : +if test "x$ac_cv_lib_OpenBUGS_CmdInterpreter" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBOPENBUGS 1 _ACEOF @@ -2722,27 +2729,19 @@ LIBS="-lOpenBUGS $LIBS" else - as_fn_error "\"Cannot load OpenBUGS library in ${OPENBUGS}/lib. Run R CMD INSTALL BRugs --configure-args='--with-openbugs=...'\"" "$LINENO" 5 + as_fn_error $? "\"Cannot load OpenBUGS library in ${OPENBUGS}/lib. Run R CMD INSTALL BRugs --configure-args='--with-openbugs=...'\"" "$LINENO" 5 fi LDFLAGS=${OLDFLAGS} -VERSION=`echo "modelQuit()" | ${OPENBUGS}/bin/OpenBUGS | sed -ne "s/OpenBUGS version \(.*\) rev \(.*\)/\1/p"` -if test `echo ${VERSION} |cut -d. -f1` -lt 3; then - as_fn_error "Requires OpenBUGS version 3.2.1 or greater" "$LINENO" 5 -fi -if test `echo ${VERSION} |cut -d. -f1` -eq 3 -a `echo ${VERSION} |cut -d. -f2` -lt 2 ; then - as_fn_error "Requires OpenBUGS version 3.2.1 or greater" "$LINENO" 5 -fi - -if ${SOURCEINST} ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: Found OpenBUGS installation from source package " >&5 -$as_echo "$as_me: Found OpenBUGS installation from source package " >&6;} - OPENBUGSDOC=${OPENBUGS}/doc +if test -d "${OPENBUGS}/share/doc/openbugs-${VERSION}" ; then + OPENBUGSDOC=${OPENBUGS}/share/doc/openbugs-${VERSION} else - { $as_echo "$as_me:${as_lineno-$LINENO}: Found OpenBUGS installation from binary package " >&5 -$as_echo "$as_me: Found OpenBUGS installation from binary package " >&6;} - OPENBUGSDOC=${OPENBUGS}/share/doc/openbugs-${VERSION} + if test -d "${OPENBUGS}/share/doc/openbugs" ; then + OPENBUGSDOC=${OPENBUGS}/share/doc/openbugs + else + as_fn_error $? "OpenBUGS documentation directory not found in ${OPENBUGS}/share/doc" "$LINENO" 5 + fi fi OPENBUGS=${OPENBUGS}/lib @@ -2817,10 +2816,21 @@ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then - test "x$cache_file" != "x/dev/null" && + if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} - cat confcache >$cache_file + if test ! -f "$cache_file" || test -h "$cache_file"; then + cat confcache >"$cache_file" + else + case $cache_file in #( + */* | ?:*) + mv -f confcache "$cache_file"$$ && + mv -f "$cache_file"$$ "$cache_file" ;; #( + *) + mv -f confcache "$cache_file" ;; + esac + fi + fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} @@ -2872,6 +2882,7 @@ ac_libobjs= ac_ltlibobjs= +U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' @@ -2887,7 +2898,7 @@ -: ${CONFIG_STATUS=./config.status} +: "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" @@ -2988,6 +2999,7 @@ IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. +as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -3033,19 +3045,19 @@ (unset CDPATH) >/dev/null 2>&1 && unset CDPATH -# as_fn_error ERROR [LINENO LOG_FD] -# --------------------------------- +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with status $?, using 1 if that was 0. +# script with STATUS, using 1 if that was 0. as_fn_error () { - as_status=$?; test $as_status -eq 0 && as_status=1 - if test "$3"; then - as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi - $as_echo "$as_me: error: $1" >&2 + $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error @@ -3241,7 +3253,7 @@ test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p @@ -3294,8 +3306,8 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by BRugs $as_me 0.7, which was -generated by GNU Autoconf 2.65. Invocation command line was +This file was extended by BRugs $as_me 0.8, which was +generated by GNU Autoconf 2.68. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -3347,11 +3359,11 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -BRugs config.status 0.7 -configured by $0, generated by GNU Autoconf 2.65, +BRugs config.status 0.8 +configured by $0, generated by GNU Autoconf 2.68, with options \\"\$ac_cs_config\\" -Copyright (C) 2009 Free Software Foundation, Inc. +Copyright (C) 2010 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." @@ -3366,11 +3378,16 @@ while test $# != 0 do case $1 in - --*=*) + --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; + --*=) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg= + ac_shift=: + ;; *) ac_option=$1 ac_optarg=$2 @@ -3392,6 +3409,7 @@ $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; @@ -3402,7 +3420,7 @@ ac_cs_silent=: ;; # This is an error. - -*) as_fn_error "unrecognized option: \`$1' + -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" @@ -3453,7 +3471,7 @@ case $ac_config_target in "src/Makevars") CONFIG_FILES="$CONFIG_FILES src/Makevars" ;; - *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done @@ -3474,9 +3492,10 @@ # after its creation but before its name has been assigned to `$tmp'. $debug || { - tmp= + tmp= ac_tmp= trap 'exit_status=$? - { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status + : "${ac_tmp:=$tmp}" + { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } @@ -3484,12 +3503,13 @@ { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && - test -n "$tmp" && test -d "$tmp" + test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") -} || as_fn_error "cannot create a temporary directory in ." "$LINENO" 5 +} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 +ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. @@ -3506,12 +3526,12 @@ fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then - ac_cs_awk_cr='\r' + ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi -echo 'BEGIN {' >"$tmp/subs1.awk" && +echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF @@ -3520,18 +3540,18 @@ echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || - as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 -ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'` + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 +ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || - as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then - as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi @@ -3539,7 +3559,7 @@ rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -cat >>"\$tmp/subs1.awk" <<\\_ACAWK && +cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h @@ -3587,7 +3607,7 @@ rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK -cat >>"\$tmp/subs1.awk" <<_ACAWK && +cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" @@ -3619,21 +3639,29 @@ sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat -fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ - || as_fn_error "could not setup config files machinery" "$LINENO" 5 +fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ + || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF -# VPATH may cause trouble with some makes, so we remove $(srcdir), -# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# VPATH may cause trouble with some makes, so we remove sole $(srcdir), +# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=/{ -s/:*\$(srcdir):*/:/ -s/:*\${srcdir}:*/:/ -s/:*@srcdir@:*/:/ -s/^\([^=]*=[ ]*\):*/\1/ + ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ +h +s/// +s/^/:/ +s/[ ]*$/:/ +s/:\$(srcdir):/:/g +s/:\${srcdir}:/:/g +s/:@srcdir@:/:/g +s/^:*// s/:*$// +x +s/\(=[ ]*\).*/\1/ +G +s/\n// s/^[^=]*=[ ]*$// }' fi @@ -3651,7 +3679,7 @@ esac case $ac_mode$ac_tag in :[FHL]*:*);; - :L* | :C*:*) as_fn_error "invalid tag \`$ac_tag'" "$LINENO" 5;; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac @@ -3670,7 +3698,7 @@ for ac_f do case $ac_f in - -) ac_f="$tmp/stdin";; + -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. @@ -3679,7 +3707,7 @@ [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || - as_fn_error "cannot find input file: \`$ac_f'" "$LINENO" 5;; + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" @@ -3705,8 +3733,8 @@ esac case $ac_tag in - *:-:* | *:-) cat >"$tmp/stdin" \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 ;; + *:-:* | *:-) cat >"$ac_tmp/stdin" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac @@ -3831,23 +3859,24 @@ s&@abs_top_builddir@&$ac_abs_top_builddir&;t t $ac_datarootdir_hack " -eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ + >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && - { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && - { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && + { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ + "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined." >&5 +which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined." >&2;} +which seems to be undefined. Please make sure it is defined" >&2;} - rm -f "$tmp/stdin" + rm -f "$ac_tmp/stdin" case $ac_file in - -) cat "$tmp/out" && rm -f "$tmp/out";; - *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; + -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; + *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; @@ -3862,7 +3891,7 @@ ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || - as_fn_error "write failure creating $CONFIG_STATUS" "$LINENO" 5 + as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. @@ -3883,7 +3912,7 @@ exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. - $ac_cs_success || as_fn_exit $? + $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 @@ -3956,10 +3985,21 @@ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then - test "x$cache_file" != "x/dev/null" && + if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} - cat confcache >$cache_file + if test ! -f "$cache_file" || test -h "$cache_file"; then + cat confcache >"$cache_file" + else + case $cache_file in #( + */* | ?:*) + mv -f confcache "$cache_file"$$ && + mv -f "$cache_file"$$ "$cache_file" ;; #( + *) + mv -f confcache "$cache_file" ;; + esac + fi + fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} @@ -4011,6 +4051,7 @@ ac_libobjs= ac_ltlibobjs= +U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' @@ -4026,7 +4067,7 @@ -: ${CONFIG_STATUS=./config.status} +: "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" @@ -4127,6 +4168,7 @@ IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. +as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -4172,19 +4214,19 @@ (unset CDPATH) >/dev/null 2>&1 && unset CDPATH -# as_fn_error ERROR [LINENO LOG_FD] -# --------------------------------- +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with status $?, using 1 if that was 0. +# script with STATUS, using 1 if that was 0. as_fn_error () { - as_status=$?; test $as_status -eq 0 && as_status=1 - if test "$3"; then - as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi - $as_echo "$as_me: error: $1" >&2 + $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error @@ -4380,7 +4422,7 @@ test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p @@ -4433,8 +4475,8 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by BRugs $as_me 0.7, which was -generated by GNU Autoconf 2.65. Invocation command line was +This file was extended by BRugs $as_me 0.8, which was +generated by GNU Autoconf 2.68. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -4486,11 +4528,11 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -BRugs config.status 0.7 -configured by $0, generated by GNU Autoconf 2.65, +BRugs config.status 0.8 +configured by $0, generated by GNU Autoconf 2.68, with options \\"\$ac_cs_config\\" -Copyright (C) 2009 Free Software Foundation, Inc. +Copyright (C) 2010 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." @@ -4505,11 +4547,16 @@ while test $# != 0 do case $1 in - --*=*) + --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; + --*=) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg= + ac_shift=: + ;; *) ac_option=$1 ac_optarg=$2 @@ -4531,6 +4578,7 @@ $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; @@ -4541,7 +4589,7 @@ ac_cs_silent=: ;; # This is an error. - -*) as_fn_error "unrecognized option: \`$1' + -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" @@ -4593,7 +4641,7 @@ "src/Makevars") CONFIG_FILES="$CONFIG_FILES src/Makevars" ;; "R/unix/zzz.R") CONFIG_FILES="$CONFIG_FILES R/unix/zzz.R" ;; - *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done @@ -4614,9 +4662,10 @@ # after its creation but before its name has been assigned to `$tmp'. $debug || { - tmp= + tmp= ac_tmp= trap 'exit_status=$? - { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status + : "${ac_tmp:=$tmp}" + { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } @@ -4624,12 +4673,13 @@ { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && - test -n "$tmp" && test -d "$tmp" + test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") -} || as_fn_error "cannot create a temporary directory in ." "$LINENO" 5 +} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 +ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. @@ -4646,12 +4696,12 @@ fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then - ac_cs_awk_cr='\r' + ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi -echo 'BEGIN {' >"$tmp/subs1.awk" && +echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF @@ -4660,18 +4710,18 @@ echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || - as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 -ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'` + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 +ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || - as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then - as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi @@ -4679,7 +4729,7 @@ rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -cat >>"\$tmp/subs1.awk" <<\\_ACAWK && +cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h @@ -4727,7 +4777,7 @@ rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK -cat >>"\$tmp/subs1.awk" <<_ACAWK && +cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" @@ -4759,21 +4809,29 @@ sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat -fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ - || as_fn_error "could not setup config files machinery" "$LINENO" 5 +fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ + || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF -# VPATH may cause trouble with some makes, so we remove $(srcdir), -# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# VPATH may cause trouble with some makes, so we remove sole $(srcdir), +# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=/{ -s/:*\$(srcdir):*/:/ -s/:*\${srcdir}:*/:/ -s/:*@srcdir@:*/:/ -s/^\([^=]*=[ ]*\):*/\1/ + ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ +h +s/// +s/^/:/ +s/[ ]*$/:/ +s/:\$(srcdir):/:/g +s/:\${srcdir}:/:/g +s/:@srcdir@:/:/g +s/^:*// s/:*$// +x +s/\(=[ ]*\).*/\1/ +G +s/\n// s/^[^=]*=[ ]*$// }' fi @@ -4791,7 +4849,7 @@ esac case $ac_mode$ac_tag in :[FHL]*:*);; - :L* | :C*:*) as_fn_error "invalid tag \`$ac_tag'" "$LINENO" 5;; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac @@ -4810,7 +4868,7 @@ for ac_f do case $ac_f in - -) ac_f="$tmp/stdin";; + -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. @@ -4819,7 +4877,7 @@ [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || - as_fn_error "cannot find input file: \`$ac_f'" "$LINENO" 5;; + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" @@ -4845,8 +4903,8 @@ esac case $ac_tag in - *:-:* | *:-) cat >"$tmp/stdin" \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 ;; + *:-:* | *:-) cat >"$ac_tmp/stdin" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac @@ -4971,23 +5029,24 @@ s&@abs_top_builddir@&$ac_abs_top_builddir&;t t $ac_datarootdir_hack " -eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ + >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && - { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && - { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && + { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ + "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined." >&5 +which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined." >&2;} +which seems to be undefined. Please make sure it is defined" >&2;} - rm -f "$tmp/stdin" + rm -f "$ac_tmp/stdin" case $ac_file in - -) cat "$tmp/out" && rm -f "$tmp/out";; - *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; + -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; + *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; @@ -5002,7 +5061,7 @@ ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || - as_fn_error "write failure creating $CONFIG_STATUS" "$LINENO" 5 + as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. @@ -5023,7 +5082,7 @@ exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. - $ac_cs_success || as_fn_exit $? + $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 Modified: trunk/BRugs/configure.ac =================================================================== --- trunk/BRugs/configure.ac 2012-07-23 17:47:46 UTC (rev 254) +++ trunk/BRugs/configure.ac 2012-07-24 08:42:13 UTC (rev 255) @@ -1,15 +1,5 @@ -AC_INIT([BRugs], [0.7]) +AC_INIT([BRugs], [0.8]) -## Work around the inconsistency between the installation destinations of the 3.2.1 source and binary packages. -## Source installs library in $prefix/lib/OpenBUGS/lib, doc in $prefix/lib/OpenBUGS/doc. -## Binaries install in standards-compliant locations $prefix/lib and $prefix/share/doc/openbugs-version respectively. -## Look in all of these places. -## Return OPENBUGS = $prefix/lib/OpenBUGS for source installations, and -## OPENBUGS = $prefix for binary installations. -## Return OPENBUGSDOC = $prefix/lib/OpenBUGS/doc for source installations, -## and OPENBUGSDOC = $prefix/share/doc/openbugs-version for binary installations. -## If user specifies -with-openbugs, this is interpreted for a source installation. - ## TODO only runs on x86 Linux - give error on other unixes. AC_PREFIX_DEFAULT(/usr/local) @@ -17,46 +7,48 @@ AC_ARG_WITH([openbugs], AC_HELP_STRING([--with-openbugs=PATH], - [the location of OpenBUGS installed from the source package, by default /usr/local/lib/OpenBUGS]), + [the location of the OpenBUGS installation, by default /usr/local]), [openbugs_path=$withval]) if test [ -n "$openbugs_path" ] ; then OPENBUGS=${openbugs_path} - SOURCEINST=true else if test [ "$prefix" = "NONE" ]; then - AC_MSG_ERROR( [OpenBUGS not found. Install OpenBUGS 3.2.1 or later, or specify its location using, for example, R CMD INSTALL BRugs --configure-args='--with-openbugs=/usr/local/lib/OpenBUGS'] ) + AC_MSG_ERROR( [OpenBUGS 3.2.2 or later not found. Install it, or specify its location using, for example, R CMD INSTALL BRugs --configure-args='--with-openbugs=/usr/local'] ) else - if test [ -e ${prefix}/lib/OpenBUGS/lib/libOpenBUGS.so ] ; then - OPENBUGS=${prefix}/lib/OpenBUGS - SOURCEINST=true - else + if test [ -e ${prefix}/lib/libOpenBUGS.so ] ; then OPENBUGS=${prefix} - SOURCEINST=false + elif test [ -e ${prefix}/lib/OpenBUGS/lib/libOpenBUGS.so ] ; then # for 3.2.1 + OPENBUGS=${prefix} fi fi fi -OLDFLAGS=${LDFLAGS} -LDFLAGS="-L${OPENBUGS}/lib -m32" -AC_CHECK_LIB(OpenBUGS, CmdInterpreter, [], - [AC_MSG_ERROR("Cannot load OpenBUGS library in ${OPENBUGS}/lib. Run R CMD INSTALL BRugs --configure-args='--with-openbugs=...'")]) -LDFLAGS=${OLDFLAGS} - VERSION=`echo "modelQuit()" | ${OPENBUGS}/bin/OpenBUGS | sed -ne "s/OpenBUGS version \(.*\) rev \(.*\)/\1/p"` if test [`echo ${VERSION} |cut -d. -f1` -lt 3]; then - AC_MSG_ERROR([Requires OpenBUGS version 3.2.1 or greater]) + AC_MSG_ERROR([Requires OpenBUGS version 3.2.2 or greater]) fi if test [ `echo ${VERSION} |cut -d. -f1` -eq 3 -a `echo ${VERSION} |cut -d. -f2` -lt 2 ]; then - AC_MSG_ERROR([Requires OpenBUGS version 3.2.1 or greater]) + AC_MSG_ERROR([Requires OpenBUGS version 3.2.2 or greater]) fi +if test [ `echo ${VERSION} |cut -d. -f1` -eq 3 -a `echo ${VERSION} |cut -d. -f2` -eq 2 -a `echo ${VERSION} |cut -d. -f3` -lt 2 ]; then + AC_MSG_ERROR([Requires OpenBUGS version 3.2.2 or greater]) +fi -if [ ${SOURCEINST} ] ; then - AC_MSG_NOTICE( [Found OpenBUGS installation from source package] ) - OPENBUGSDOC=${OPENBUGS}/doc -else - AC_MSG_NOTICE( [Found OpenBUGS installation from binary package] ) +OLDFLAGS=${LDFLAGS} +LDFLAGS="-L${OPENBUGS}/lib -m32" +AC_CHECK_LIB(OpenBUGS, CmdInterpreter, [], + [AC_MSG_ERROR("Cannot load OpenBUGS library in ${OPENBUGS}/lib. Run R CMD INSTALL BRugs --configure-args='--with-openbugs=...'")]) +LDFLAGS=${OLDFLAGS} + +if test [ -d "${OPENBUGS}/share/doc/openbugs-${VERSION}" ] ; then OPENBUGSDOC=${OPENBUGS}/share/doc/openbugs-${VERSION} +else + if test [ -d "${OPENBUGS}/share/doc/openbugs" ] ; then + OPENBUGSDOC=${OPENBUGS}/share/doc/openbugs + else + AC_MSG_ERROR([OpenBUGS documentation directory not found in ${OPENBUGS}/share/doc]) + fi fi OPENBUGS=${OPENBUGS}/lib This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2012-07-23 17:47:56
|
Revision: 254 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=254&view=rev Author: ligges Date: 2012-07-23 17:47:46 +0000 (Mon, 23 Jul 2012) Log Message: ----------- make BRugs OpenBUGS 3.2.2 compatible (and drop back compatibility) and some more fixes for R >= 2.15.1; bump version number Modified Paths: -------------- trunk/BRugs/DESCRIPTION trunk/BRugs/NEWS trunk/BRugs/R/info.modules.R trunk/BRugs/R/info.node.R trunk/BRugs/R/info.updaters.R trunk/BRugs/R/model.setWD.R trunk/BRugs/tests/BRugs.Rout.save trunk/BRugs/tests/examples.Rout.save trunk/BRugs/tests/functions.Rout.save Modified: trunk/BRugs/DESCRIPTION =================================================================== --- trunk/BRugs/DESCRIPTION 2012-07-12 02:22:12 UTC (rev 253) +++ trunk/BRugs/DESCRIPTION 2012-07-23 17:47:46 UTC (rev 254) @@ -1,12 +1,12 @@ Package: BRugs Title: R interface to the OpenBUGS MCMC software -Version: 0.7-5 -Date: 2012-01-06 +Version: 0.8-0 +Date: 2012-07-23 Author: 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. Description: 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. Maintainer: Uwe Ligges <li...@st...> Depends: R (>= 2.11.0), coda Imports: utils, coda -SystemRequirements: OpenBUGS (>= 3.2.1), hence Windows or Linux +SystemRequirements: OpenBUGS (>= 3.2.2), hence Windows or Linux License: GPL-2 URL: http://www.openbugs.info/ Modified: trunk/BRugs/NEWS =================================================================== --- trunk/BRugs/NEWS 2012-07-12 02:22:12 UTC (rev 253) +++ trunk/BRugs/NEWS 2012-07-23 17:47:46 UTC (rev 254) @@ -1,5 +1,20 @@ Changes to BRugs: ===================== + +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 Modified: trunk/BRugs/R/info.modules.R =================================================================== --- trunk/BRugs/R/info.modules.R 2012-07-12 02:22:12 UTC (rev 253) +++ trunk/BRugs/R/info.modules.R 2012-07-23 17:47:46 UTC (rev 254) @@ -5,7 +5,7 @@ command <- "BugsEmbed.Modules" .CmdInterpreter(command) buffer <- file.path(tempdir(), "buffer.txt") - result <- read.fwf(buffer, c(50, 12, 12, 12, 12, 10), skip = 1, as.is=TRUE) + result <- read.table(buffer, skip = 1, as.is=TRUE, sep="\t")[,-1] for(i in c(1,4,5,6)) result[,i] <- gsub(" ", "", result[,i]) names(result) <- c("Module", "Clients", "Version", "Maintainer", "Compiled", "Loaded") Modified: trunk/BRugs/R/info.node.R =================================================================== --- trunk/BRugs/R/info.node.R 2012-07-12 02:22:12 UTC (rev 253) +++ trunk/BRugs/R/info.node.R 2012-07-23 17:47:46 UTC (rev 254) @@ -1,42 +1,42 @@ -"infoNodeValues" <- -function(nodeLabel) -# Get current value of node -{ - nodeLabel <- as.character(nodeLabel) - out <- .OpenBUGS(c("BugsRobjects.SetVariable", "BugsRobjects.GetSize"), - c("CharArray","Integer"), - list(nodeLabel, NA)) - nodeSize <- out[[2]] - if(nodeSize == -1) - stop(nodeLabel, " is not a node in BUGS model") - numChains <- getNumChains() - out <- .OpenBUGS(c("BugsRobjects.SetVariable", "BugsRobjects.GetValues"), - c("CharArray","RealArray"), - list(nodeLabel, double(nodeSize*numChains))) - values <- matrix(out[[2]], nrow=nodeSize, ncol=numChains) - values -} - -infoNodeMethods <- function(nodeLabel) -{ - nodeName <- sQuote(nodeLabel) - command <- paste("BugsEmbed.SetNode(",nodeName,"); BugsEmbed.Methods"); - .CmdInterpreter(command) - buffer <- file.path(tempdir(), "buffer.txt") - result <- read.fwf(buffer, c(25, 25, 25, 25), skip = 1, as.is=TRUE, col.names=c("Node","Type", "Size", "Depth")) - for (i in 1:2) - result[,i] <- gsub(" ", "", result[,i]) - result -} - -infoNodeTypes <- function(nodeLabel) -{ - nodeName <- sQuote(nodeLabel) - command <- paste("BugsEmbed.SetNode(",nodeName,"); BugsEmbed.Types"); - .CmdInterpreter(command) - buffer <- file.path(tempdir(), "buffer.txt") - result <- read.fwf(buffer, c(25, 25), skip = 1, as.is=TRUE, col.names=c("Node","Type")) - for (i in 1:2) - result[,i] <- gsub(" ", "", result[,i]) - result -} +"infoNodeValues" <- +function(nodeLabel) +# Get current value of node +{ + nodeLabel <- as.character(nodeLabel) + out <- .OpenBUGS(c("BugsRobjects.SetVariable", "BugsRobjects.GetSize"), + c("CharArray","Integer"), + list(nodeLabel, NA)) + nodeSize <- out[[2]] + if(nodeSize == -1) + stop(nodeLabel, " is not a node in BUGS model") + numChains <- getNumChains() + out <- .OpenBUGS(c("BugsRobjects.SetVariable", "BugsRobjects.GetValues"), + c("CharArray","RealArray"), + list(nodeLabel, double(nodeSize*numChains))) + values <- matrix(out[[2]], nrow=nodeSize, ncol=numChains) + values +} + +infoNodeMethods <- function(nodeLabel) +{ + nodeName <- sQuote(nodeLabel) + command <- paste("BugsEmbed.SetNode(",nodeName,"); BugsEmbed.Methods"); + .CmdInterpreter(command) + buffer <- file.path(tempdir(), "buffer.txt") + result <- read.table(buffer, sep="\t", skip = 1, as.is=TRUE, col.names=c("empty", "Node", "Type", "Size", "Depth"))[,-1] + for (i in 1:2) + result[,i] <- gsub(" ", "", result[,i]) + result +} + +infoNodeTypes <- function(nodeLabel) +{ + nodeName <- sQuote(nodeLabel) + command <- paste("BugsEmbed.SetNode(",nodeName,"); BugsEmbed.Types"); + .CmdInterpreter(command) + buffer <- file.path(tempdir(), "buffer.txt") + result <- read.table(buffer, sep="\t", skip = 1, as.is=TRUE, col.names=c("empty", "Node", "Type"))[,-1] + for (i in 1:2) + result[,i] <- gsub(" ", "", result[,i]) + result +} Modified: trunk/BRugs/R/info.updaters.R =================================================================== --- trunk/BRugs/R/info.updaters.R 2012-07-12 02:22:12 UTC (rev 253) +++ trunk/BRugs/R/info.updaters.R 2012-07-23 17:47:46 UTC (rev 254) @@ -8,8 +8,8 @@ if (readLines(buffer)[1]=="BugsCmds:NotCompiled") stop("Model not compiled") buffer <- file.path(tempdir(), "Updater types.txt") - result <- read.fwf(buffer, c(25, 50, 10, 10), skip = 1, as.is=TRUE, - row.names=1, col.names=c("Node","Type", "Size","Depth")) + result <- read.table(buffer, sep="\t", skip=1, as.is=TRUE, + row.names=2, col.names=c("empty", "Node", "Type", "Size", "Depth"))[,-1] ## strip leading and trailing spaces for (i in 1:2) { result[,i] <- gsub("^ +", "\\1", result[,i]) @@ -30,8 +30,8 @@ if (readLines(buffer)[1]=="BugsCmds:NotCompiled") stop("Model not compiled") buffer <- file.path(tempdir(), "Updater types.txt") - result <- read.fwf(buffer, c(25, 50, 10, 10), skip = 1, as.is=TRUE, - row.names=1, col.names=c("Node","Type", "Size","Depth")) + result <- read.table(buffer, sep="\t", skip=1, as.is=TRUE, + row.names=2, col.names=c("empty", "Node", "Type", "Size", "Depth"))[,-1] ## strip leading and trailing spaces for (i in 1:2) { result[,i] <- gsub("^ +", "\\1", result[,i]) Modified: trunk/BRugs/R/model.setWD.R =================================================================== --- trunk/BRugs/R/model.setWD.R 2012-07-12 02:22:12 UTC (rev 253) +++ trunk/BRugs/R/model.setWD.R 2012-07-23 17:47:46 UTC (rev 254) @@ -1,3 +1,3 @@ ## Simple alias to mimic the OpenBUGS script command -"modelSetWD" <- setwd +"modelSetWD" <- function(dir) setwd(dir) Modified: trunk/BRugs/tests/BRugs.Rout.save =================================================================== --- trunk/BRugs/tests/BRugs.Rout.save 2012-07-12 02:22:12 UTC (rev 253) +++ trunk/BRugs/tests/BRugs.Rout.save 2012-07-23 17:47:46 UTC (rev 254) @@ -80,7 +80,7 @@ + } Loading required package: coda Loading required package: lattice -Welcome to BRugs connected to OpenBUGS version 3.2.1 +Welcome to BRugs connected to OpenBUGS version 3.2.2 model is syntactically correct data loaded model compiled Modified: trunk/BRugs/tests/examples.Rout.save =================================================================== --- trunk/BRugs/tests/examples.Rout.save 2012-07-12 02:22:12 UTC (rev 253) +++ trunk/BRugs/tests/examples.Rout.save 2012-07-23 17:47:46 UTC (rev 254) @@ -68,7 +68,7 @@ + } Loading required package: coda Loading required package: lattice -Welcome to BRugs connected to OpenBUGS version 3.2.1 +Welcome to BRugs connected to OpenBUGS version 3.2.2 model is syntactically correct data loaded model compiled @@ -89,7 +89,7 @@ model is initialized model is already initialized 5000 updates took 0 s -can not calculate deviance for this model +can not calculate DIC for this model monitor set for variable 'bronchitis' monitor set for variable 'either' monitor set for variable 'lung.cancer' @@ -128,7 +128,7 @@ model is initialized model is already initialized 5000 updates took 0 s -can not calculate deviance for this model +can not calculate DIC for this model monitor set for variable 'Sigma2' monitor set for variable 'rho' monitor set for variable 'tau' @@ -187,7 +187,7 @@ initial values loaded but chain contain uninitialized variables initial values generated, model initialized 5000 updates took 0 s -can not calculate deviance for this model +can not calculate DIC for this model monitor set for variable 'P' monitor set for variable 'lambda' monitor set for variable 'sigma' Modified: trunk/BRugs/tests/functions.Rout.save =================================================================== --- trunk/BRugs/tests/functions.Rout.save 2012-07-12 02:22:12 UTC (rev 253) +++ trunk/BRugs/tests/functions.Rout.save 2012-07-23 17:47:46 UTC (rev 254) @@ -151,7 +151,7 @@ + } Loading required package: coda Loading required package: lattice -Welcome to BRugs connected to OpenBUGS version 3.2.1 +Welcome to BRugs connected to OpenBUGS version 3.2.2 model is syntactically correct data loaded model compiled This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |