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...> - 2011-12-30 15:56:43
|
Revision: 231 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=231&view=rev Author: ligges Date: 2011-12-30 15:56:37 +0000 (Fri, 30 Dec 2011) Log Message: ----------- minor improvements / tidy up Modified Paths: -------------- trunk/BRugs/R/internal.R Modified: trunk/BRugs/R/internal.R =================================================================== --- trunk/BRugs/R/internal.R 2011-12-30 15:55:52 UTC (rev 230) +++ trunk/BRugs/R/internal.R 2011-12-30 15:56:37 UTC (rev 231) @@ -50,8 +50,7 @@ trashDir <- paste(tempDir, "_trash", sep="") extFile <- getOption("BRugsExtFile") cmdFile <- paste(tempDir, "cmds.txt", sep="/") - pkgPath <- searchpaths()[search()=="package:BRugs"] - bugsPath <- paste(pkgPath, "/exec/BugsHelper", sep="") + bugsPath <- system.file("exec", "BugsHelper", package="BRugs") shcmd <- paste(dquote(bugsPath), dquote(tempDir), dquote(trashDir), dquote(extFile), dquote(cmdFile), dquote(ncmds)) for (i in 1:ncmds) { if (cmdtypes[i] %in% c("CharArray","RealArray")) @@ -62,7 +61,7 @@ res <- system(shcmd) handleRes(res) out <- vector(ncmds, mode="list") - for (i in 1:ncmds) { + for (i in seq_along(cmds)){ if (cmdtypes[i] %in% c("Integer","CharArray","RealArray")) out[[i]] <- scan(paste(tempDir,"/output",i,".txt",sep=""), switch(cmdtypes[i], @@ -76,7 +75,7 @@ handleRes <- function(res) { - maintainer <- utils:::packageDescription("BRugs", fields="Maintainer") + maintainer <- maintainer("BRugs") errors <- c("Internal \"trap\" error in OpenBUGS, or non-existent module or procedure called.", "An OpenBUGS procedure was called with the wrong type of argument.", "An OpenBUGS procedure was called with the wrong signature.") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2011-12-30 15:55:58
|
Revision: 230 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=230&view=rev Author: ligges Date: 2011-12-30 15:55:52 +0000 (Fri, 30 Dec 2011) Log Message: ----------- reflect changed StartupMessage from rev 211 in Rout.save files Revision Links: -------------- http://bugs-r.svn.sourceforge.net/bugs-r/?rev=211&view=rev Modified Paths: -------------- trunk/BRugs/tests/BRugs.Rout.save trunk/BRugs/tests/examples.Rout.save trunk/BRugs/tests/functions.Rout.save Modified: trunk/BRugs/tests/BRugs.Rout.save =================================================================== --- trunk/BRugs/tests/BRugs.Rout.save 2011-12-23 03:17:03 UTC (rev 229) +++ trunk/BRugs/tests/BRugs.Rout.save 2011-12-30 15:55:52 UTC (rev 230) @@ -75,7 +75,7 @@ + } Loading required package: coda Loading required package: lattice -Welcome to BRugs running on OpenBUGS version 3.2.1 +Welcome to BRugs connected to OpenBUGS version 3.2.1 model is syntactically correct data loaded model compiled Modified: trunk/BRugs/tests/examples.Rout.save =================================================================== --- trunk/BRugs/tests/examples.Rout.save 2011-12-23 03:17:03 UTC (rev 229) +++ trunk/BRugs/tests/examples.Rout.save 2011-12-30 15:55:52 UTC (rev 230) @@ -66,7 +66,7 @@ + } Loading required package: coda Loading required package: lattice -Welcome to BRugs running on OpenBUGS version 3.2.1 +Welcome to BRugs connected to OpenBUGS version 3.2.1 model is syntactically correct data loaded model compiled Modified: trunk/BRugs/tests/functions.Rout.save =================================================================== --- trunk/BRugs/tests/functions.Rout.save 2011-12-23 03:17:03 UTC (rev 229) +++ trunk/BRugs/tests/functions.Rout.save 2011-12-30 15:55:52 UTC (rev 230) @@ -149,7 +149,7 @@ + } Loading required package: coda Loading required package: lattice -Welcome to BRugs running on OpenBUGS version 3.2.1 +Welcome to BRugs connected to OpenBUGS version 3.2.1 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. |
From: <snt...@us...> - 2011-12-23 03:17:10
|
Revision: 229 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=229&view=rev Author: snthomas99 Date: 2011-12-23 03:17:03 +0000 (Fri, 23 Dec 2011) Log Message: ----------- fixed minor problem in bugs.rd Modified Paths: -------------- trunk/R2OpenBUGS/man/bugs.Rd Modified: trunk/R2OpenBUGS/man/bugs.Rd =================================================================== --- trunk/R2OpenBUGS/man/bugs.Rd 2011-12-22 13:41:05 UTC (rev 228) +++ trunk/R2OpenBUGS/man/bugs.Rd 2011-12-23 03:17:03 UTC (rev 229) @@ -126,7 +126,7 @@ to get the information automatically if not given.} \item{bugs.seed}{Random seed for \pkg{OpenBUGS}. Must be an integer between 1-14. Seed specification changed between WinBUGS and OpenBUGS; see the OpenBUGS documentation for - details}. + details.} \item{summary.only}{If \code{TRUE}, only a parameter summary for very quick analyses is given, temporary created files are not removed in that case.} \item{save.history}{If \code{TRUE} (the default), trace plots are generated at the end.} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2011-12-22 13:41:11
|
Revision: 228 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=228&view=rev Author: ligges Date: 2011-12-22 13:41:05 +0000 (Thu, 22 Dec 2011) Log Message: ----------- mcmc() was not imported from coda although used Modified Paths: -------------- trunk/R2WinBUGS/NAMESPACE Modified: trunk/R2WinBUGS/NAMESPACE =================================================================== --- trunk/R2WinBUGS/NAMESPACE 2011-12-22 13:40:36 UTC (rev 227) +++ trunk/R2WinBUGS/NAMESPACE 2011-12-22 13:41:05 UTC (rev 228) @@ -1,4 +1,4 @@ -importFrom(coda, mcmc.list, as.mcmc.list, read.coda) +importFrom(coda, mcmc, mcmc.list, as.mcmc.list, read.coda) importFrom(boot, logit) export(bugs, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2011-12-22 13:40:42
|
Revision: 227 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=227&view=rev Author: ligges Date: 2011-12-22 13:40:36 +0000 (Thu, 22 Dec 2011) Log Message: ----------- no utf8 in the vignette anymore Modified Paths: -------------- trunk/R2OpenBUGS/inst/doc/bugs.tex Modified: trunk/R2OpenBUGS/inst/doc/bugs.tex =================================================================== --- trunk/R2OpenBUGS/inst/doc/bugs.tex 2011-12-22 10:26:55 UTC (rev 226) +++ trunk/R2OpenBUGS/inst/doc/bugs.tex 2011-12-22 13:40:36 UTC (rev 227) @@ -1,4 +1,3 @@ -\inputencoding{utf8} \HeaderA{bugs}{Run OpenBUGS from R}{bugs} \keyword{interface}{bugs} \keyword{models}{bugs} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2011-12-22 10:27:05
|
Revision: 226 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=226&view=rev Author: ligges Date: 2011-12-22 10:26:55 +0000 (Thu, 22 Dec 2011) Log Message: ----------- moved dependencies to imports Modified Paths: -------------- trunk/R2OpenBUGS/DESCRIPTION trunk/R2OpenBUGS/NAMESPACE trunk/R2OpenBUGS/inst/NEWS trunk/R2OpenBUGS/tests/R2OpenBUGS.Rout.save Modified: trunk/R2OpenBUGS/DESCRIPTION =================================================================== --- trunk/R2OpenBUGS/DESCRIPTION 2011-12-22 10:25:55 UTC (rev 225) +++ trunk/R2OpenBUGS/DESCRIPTION 2011-12-22 10:26:55 UTC (rev 226) @@ -12,8 +12,8 @@ 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), coda (>= 0.11-0), boot +Depends: R (>= 2.11.0) +Imports: coda (>= 0.11-0), boot SystemRequirements: OpenBUGS (>= 3.2.1) Maintainer: Neal Thomas <snt...@ya...> License: GPL-2 -Dialect: R Modified: trunk/R2OpenBUGS/NAMESPACE =================================================================== --- trunk/R2OpenBUGS/NAMESPACE 2011-12-22 10:25:55 UTC (rev 225) +++ trunk/R2OpenBUGS/NAMESPACE 2011-12-22 10:26:55 UTC (rev 226) @@ -1,4 +1,4 @@ -importFrom(coda, mcmc.list, as.mcmc.list, read.coda) +importFrom(coda, mcmc, mcmc.list, as.mcmc.list, read.coda) importFrom(boot, logit) export(bugs, Modified: trunk/R2OpenBUGS/inst/NEWS =================================================================== --- trunk/R2OpenBUGS/inst/NEWS 2011-12-22 10:25:55 UTC (rev 225) +++ trunk/R2OpenBUGS/inst/NEWS 2011-12-22 10:26:55 UTC (rev 226) @@ -9,6 +9,7 @@ - import logit from boot nowadays (seems nobody uses that anyway) - examples from OpenBUGS copied into the package to allow for tests independent of example data location +- moved dependencies to imports Update 3.2-1.2 - Changed handling of default OpenBUGS program location and other changes Modified: trunk/R2OpenBUGS/tests/R2OpenBUGS.Rout.save =================================================================== --- trunk/R2OpenBUGS/tests/R2OpenBUGS.Rout.save 2011-12-22 10:25:55 UTC (rev 225) +++ trunk/R2OpenBUGS/tests/R2OpenBUGS.Rout.save 2011-12-22 10:26:55 UTC (rev 226) @@ -17,16 +17,6 @@ Type 'q()' to quit R. > library("R2OpenBUGS") -Loading required package: coda -Loading required package: lattice -Loading required package: boot - -Attaching package: 'boot' - -The following object(s) are masked from 'package:lattice': - - melanoma - > validateInstallOpenBUGS() The version of OpenBUGS on your computer is being compared to validation results created using OpenBUGS version 3.2.1 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2011-12-22 10:26:04
|
Revision: 225 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=225&view=rev Author: ligges Date: 2011-12-22 10:25:55 +0000 (Thu, 22 Dec 2011) Log Message: ----------- allow for OpenBUGS.pgm == "OpenBUGS" Modified Paths: -------------- trunk/R2OpenBUGS/R/bugs.R trunk/R2OpenBUGS/R/validateInstallOpenBUGS.R Modified: trunk/R2OpenBUGS/R/bugs.R =================================================================== --- trunk/R2OpenBUGS/R/bugs.R 2011-12-22 10:24:24 UTC (rev 224) +++ trunk/R2OpenBUGS/R/bugs.R 2011-12-22 10:25:55 UTC (rev 225) @@ -16,7 +16,8 @@ OpenBUGS.pgm <- findOpenBUGS() if(.Platform$OS.type == "windows" || useWINE) OpenBUGS.pgm <- file.path(OpenBUGS.pgm, "OpenBUGS.exe") -} +} else if(OpenBUGS.pgm == "OpenBUGS") + OpenBUGS.pgm <- Sys.which("OpenBUGS") if(!file.exists(OpenBUGS.pgm)) stop("Cannot find the OpenBUGS program") Modified: trunk/R2OpenBUGS/R/validateInstallOpenBUGS.R =================================================================== --- trunk/R2OpenBUGS/R/validateInstallOpenBUGS.R 2011-12-22 10:24:24 UTC (rev 224) +++ trunk/R2OpenBUGS/R/validateInstallOpenBUGS.R 2011-12-22 10:25:55 UTC (rev 225) @@ -10,12 +10,12 @@ OpenBUGS.pgm <- findOpenBUGS() if(.Platform$OS.type == "windows" | useWINE==TRUE) OpenBUGS.pgm <- file.path(OpenBUGS.pgm, "OpenBUGS.exe") - } +} else if(OpenBUGS.pgm == "OpenBUGS") + OpenBUGS.pgm <- Sys.which("OpenBUGS") if(!file.exists(OpenBUGS.pgm)) stop("Cannot find the OpenBUGS program") - test.models <- c("Air", "Asia", "Beetles", "BiRats", "Camel", "Dugongs", "Dyes", "Equiv", "Eyes", "Line", "OtreesMVN", "Rats", "Stacks", This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2011-12-22 10:24:34
|
Revision: 224 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=224&view=rev Author: ligges Date: 2011-12-22 10:24:24 +0000 (Thu, 22 Dec 2011) Log Message: ----------- fix: accidentally used model files from an outdated BUGS installation Modified Paths: -------------- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Dugongsmodel.txt trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Eyesmodel.txt Modified: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Dugongsmodel.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Dugongsmodel.txt 2011-12-22 10:23:40 UTC (rev 223) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Dugongsmodel.txt 2011-12-22 10:24:24 UTC (rev 224) @@ -4,8 +4,8 @@ Y[i] ~ dnorm(mu[i], tau) mu[i] <- alpha - beta * pow(gamma,x[i]) } - alpha ~ dnorm(0.0, 1.0E-6) - beta ~ dnorm(0.0, 1.0E-6) + alpha ~ dflat()T(0,) + beta ~ dflat()T(0,) gamma ~ dunif(0.5, 1.0) tau ~ dgamma(0.001, 0.001) sigma <- 1 / sqrt(tau) Modified: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Eyesmodel.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Eyesmodel.txt 2011-12-22 10:23:40 UTC (rev 223) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Eyesmodel.txt 2011-12-22 10:24:24 UTC (rev 224) @@ -5,8 +5,8 @@ mu[i] <- lambda[T[i]] T[i] ~ dcat(P[]) } - P[1:2] ~ ddirch(alpha[]) - theta ~ dnorm(0.0, 1.0E-6)I(0.0, ) + P[1:2] ~ ddirich(alpha[]) + theta ~ dunif(0.0, 1000) lambda[2] <- lambda[1] + theta lambda[1] ~ dnorm(0.0, 1.0E-6) tau ~ dgamma(0.001, 0.001) sigma <- 1 / sqrt(tau) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2011-12-22 10:23:54
|
Revision: 223 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=223&view=rev Author: ligges Date: 2011-12-22 10:23:40 +0000 (Thu, 22 Dec 2011) Log Message: ----------- forgot to update vignette Modified Paths: -------------- trunk/R2OpenBUGS/inst/doc/R2OpenBUGS.pdf Modified: trunk/R2OpenBUGS/inst/doc/R2OpenBUGS.pdf =================================================================== --- trunk/R2OpenBUGS/inst/doc/R2OpenBUGS.pdf 2011-12-22 04:19:27 UTC (rev 222) +++ trunk/R2OpenBUGS/inst/doc/R2OpenBUGS.pdf 2011-12-22 10:23:40 UTC (rev 223) @@ -235,7 +235,7 @@ /Type /XObject /Subtype /Form /FormType 1 -/PTEX.FileName (C:/Documents\040and\040Settings/ThomasN/My\040Documents/BUGS/bugsdevel/bugs-r/R2OpenBUGS/inst/doc/countssw.pdf) +/PTEX.FileName (C:/WINDOWS/Temp/RtmpyoY6hC/Rbuild3ef34406/R2OpenBUGS/inst/doc/countssw.pdf) /PTEX.PageNumber 1 /PTEX.InfoDict 58 0 R /BBox [0 0 432 216] @@ -1557,7 +1557,7 @@ /Type /XObject /Subtype /Form /FormType 1 -/PTEX.FileName (C:/Documents\040and\040Settings/ThomasN/My\040Documents/BUGS/bugsdevel/bugs-r/R2OpenBUGS/inst/doc/expectedsw.pdf) +/PTEX.FileName (C:/WINDOWS/Temp/RtmpyoY6hC/Rbuild3ef34406/R2OpenBUGS/inst/doc/expectedsw.pdf) /PTEX.PageNumber 1 /PTEX.InfoDict 66 0 R /BBox [0 0 432 216] @@ -2845,7 +2845,7 @@ /Type /XObject /Subtype /Form /FormType 1 -/PTEX.FileName (C:/Documents\040and\040Settings/ThomasN/My\040Documents/BUGS/bugsdevel/bugs-r/R2OpenBUGS/inst/doc/benzolsw.pdf) +/PTEX.FileName (C:/WINDOWS/Temp/RtmpyoY6hC/Rbuild3ef34406/R2OpenBUGS/inst/doc/benzolsw.pdf) /PTEX.PageNumber 1 /PTEX.InfoDict 85 0 R /BBox [0 0 432 216] @@ -3987,7 +3987,7 @@ /Type /XObject /Subtype /Form /FormType 1 -/PTEX.FileName (C:/Documents\040and\040Settings/ThomasN/My\040Documents/BUGS/bugsdevel/bugs-r/R2OpenBUGS/inst/doc/plot.pdf) +/PTEX.FileName (C:/WINDOWS/Temp/RtmpyoY6hC/Rbuild3ef34406/R2OpenBUGS/inst/doc/plot.pdf) /PTEX.PageNumber 1 /PTEX.InfoDict 132 0 R /BBox [0 0 470 469] @@ -4961,37 +4961,51 @@ /ProcSet [ /PDF /Text ] >> endobj 150 0 obj << -/Length 3574 +/Length 3546 /Filter /FlateDecode >> stream -xڭYo\xE3\xC6\xF9ݿBX\x88\xACf93<\xECC\xB7\xD9\H\xBBi\xD6A\x92 |
From: <snt...@us...> - 2011-12-22 04:19:33
|
Revision: 222 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=222&view=rev Author: snthomas99 Date: 2011-12-22 04:19:27 +0000 (Thu, 22 Dec 2011) Log Message: ----------- fixed email address in DESCRIPTION file Modified Paths: -------------- trunk/R2OpenBUGS/DESCRIPTION Modified: trunk/R2OpenBUGS/DESCRIPTION =================================================================== --- trunk/R2OpenBUGS/DESCRIPTION 2011-12-21 15:46:47 UTC (rev 221) +++ trunk/R2OpenBUGS/DESCRIPTION 2011-12-22 04:19:27 UTC (rev 222) @@ -14,6 +14,6 @@ in R. Depends: R (>= 2.11.0), coda (>= 0.11-0), boot SystemRequirements: OpenBUGS (>= 3.2.1) -Maintainer: Neal Thomas <nea...@ya...> +Maintainer: Neal Thomas <snt...@ya...> License: GPL-2 Dialect: R This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2011-12-21 15:46:59
|
Revision: 221 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=221&view=rev Author: ligges Date: 2011-12-21 15:46:47 +0000 (Wed, 21 Dec 2011) Log Message: ----------- copied example into the package for test runs independent of openBUGS' Examples directory Modified Paths: -------------- trunk/R2OpenBUGS/R/validateInstallOpenBUGS.R trunk/R2OpenBUGS/inst/NEWS trunk/R2OpenBUGS/man/validateInstallOpenBUGS.Rd Added Paths: ----------- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Airdata.txt trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Airinits.txt trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Airinits1.txt trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Airmodel.txt trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Asiadata.txt trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Asiainits.txt trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Asiamodel.txt trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Beetlesdata.txt trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Beetlesinits.txt trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Beetlesmodel.txt trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/BiRatsdata.txt trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/BiRatsinits.txt trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/BiRatsmodel.txt trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Cameldata.txt trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Camelinits.txt trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Camelmodel.txt trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Dugongsdata.txt trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Dugongsinits.txt trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Dugongsmodel.txt trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Dyesdata.txt trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Dyesinits.txt trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Dyesmodel.txt trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Equivdata.txt trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Equivinits.txt trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Equivmodel.txt trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Eyesdata.txt trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Eyesinits.txt trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Eyesmodel.txt trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Linedata.txt trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Lineinits.txt trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Linemodel.txt trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/OtreesMVNdata.txt trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/OtreesMVNinits.txt trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/OtreesMVNmodel.txt trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Ratsdata.txt trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Ratsinits.txt trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Ratsmissdata.txt trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Ratsmodel.txt trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Stacksdata.txt trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Stacksinits.txt trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Stacksmodel.txt trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Surgicaldata.txt trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Surgicalinits.txt trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Surgicalmodel.txt trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Surgicalranddata.txt trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Surgicalrandinits.txt trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Surgicalrandmodel.txt Modified: trunk/R2OpenBUGS/R/validateInstallOpenBUGS.R =================================================================== --- trunk/R2OpenBUGS/R/validateInstallOpenBUGS.R 2011-12-21 10:21:41 UTC (rev 220) +++ trunk/R2OpenBUGS/R/validateInstallOpenBUGS.R 2011-12-21 15:46:47 UTC (rev 221) @@ -1,6 +1,5 @@ validateInstallOpenBUGS <- function( OpenBUGS.pgm=NULL, - OpenBUGS.examples=NULL, useWINE=FALSE, WINE=NULL, newWINE=TRUE, WINEPATH=NULL ) @@ -17,19 +16,6 @@ stop("Cannot find the OpenBUGS program") -if(is.null(OpenBUGS.examples)){ - if(.Platform$OS.type == "windows" | useWINE==TRUE){ - OpenBUGS.examples <- file.path(dirname(OpenBUGS.pgm), 'Examples') - }else { - ## best guess? - OpenBUGS.examples <- gsub("bin/OpenBUGS", "lib/OpenBUGS/Examples", OpenBUGS.pgm) - } -} - -if(!file.exists(OpenBUGS.examples)) - stop("Cannot find Examples in ", OpenBUGS.examples) - - test.models <- c("Air", "Asia", "Beetles", "BiRats", "Camel", "Dugongs", "Dyes", "Equiv", "Eyes", "Line", "OtreesMVN", "Rats", "Stacks", @@ -65,7 +51,7 @@ "results created using OpenBUGS version 3.2.1\n") for (i in seq(along=test.models)) { - exfiles <- dir(OpenBUGS.examples, pattern=test.pattern[i], full.names=TRUE) + exfiles <- dir(system.file("validateInstallOpenBUGS", package="R2OpenBUGS"), pattern=test.pattern[i], full.names=TRUE) ok <- file.copy(exfiles, tempdir()) fit <- round(bugs(data=test.datafile[i], inits=test.inits[i], para=test.params[[test.models[i]]],model.file=test.modelfile[i], Modified: trunk/R2OpenBUGS/inst/NEWS =================================================================== --- trunk/R2OpenBUGS/inst/NEWS 2011-12-21 10:21:41 UTC (rev 220) +++ trunk/R2OpenBUGS/inst/NEWS 2011-12-21 15:46:47 UTC (rev 221) @@ -2,10 +2,13 @@ ====================== Update 3.2-1.3 -- cleanup: removed S-PLUS support completely since that was removed at several other places before +- cleanup: removed S-PLUS support completely since that was removed at several + other places before - fixed the bugs introduced with validInstallOpenBUGS - Changed handling of default OpenBUGS program location in a sensible way now - import logit from boot nowadays (seems nobody uses that anyway) +- examples from OpenBUGS copied into the package to allow for tests independent + of example data location Update 3.2-1.2 - Changed handling of default OpenBUGS program location and other changes Added: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Airdata.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Airdata.txt (rev 0) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Airdata.txt 2011-12-21 15:46:47 UTC (rev 221) @@ -0,0 +1 @@ +list(J = 3, y = c(21, 20, 15), n = c(48, 34, 21), Z = c(10, 30, 50), tau = 0.01234, alpha = 4.48, beta = 0.76) \ No newline at end of file Added: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Airinits.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Airinits.txt (rev 0) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Airinits.txt 2011-12-21 15:46:47 UTC (rev 221) @@ -0,0 +1 @@ + list(theta = c(0.0, 0.0), X = c(0.0, 0.0, 0.0)) \ No newline at end of file Added: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Airinits1.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Airinits1.txt (rev 0) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Airinits1.txt 2011-12-21 15:46:47 UTC (rev 221) @@ -0,0 +1 @@ +list(theta = c(NA, 0.0), theta0 = 0.0, X = c(0.0, 0.0, 0.0)) \ No newline at end of file Added: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Airmodel.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Airmodel.txt (rev 0) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Airmodel.txt 2011-12-21 15:46:47 UTC (rev 221) @@ -0,0 +1,11 @@ + model + { + for(j in 1 : J) { + y[j] ~ dbin(p[j], n[j]) + logit(p[j]) <- theta[1] + theta[2] * X[j] + X[j] ~ dnorm(mu[j], tau) + mu[j] <- alpha + beta * Z[j] + } + theta[1] ~ dnorm(0.0, 0.001) + theta[2] ~ dnorm(0.0, 0.001) + } Added: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Asiadata.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Asiadata.txt (rev 0) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Asiadata.txt 2011-12-21 15:46:47 UTC (rev 221) @@ -0,0 +1,10 @@ +list(asia = 2, dyspnoea = 2, + p.tuberculosis = structure(.Data = c(0.99,0.01,0.95,0.05), .Dim = c(2,2)), + p.bronchitis = structure(.Data = c(0.70,0.30,0.40,0.60), .Dim = c(2,2)), + p.smoking = c(0.50,0.50), + p.lung.cancer = structure(.Data = c(0.99,0.01,0.90,0.10), .Dim = c(2,2)), + p.xray = structure(.Data = c(0.95,0.05,0.02,0.98), .Dim = c(2,2)), + p.dyspnoea = structure(.Data = c(0.9,0.1, + 0.2,0.8, + 0.3,0.7, + 0.1,0.9), .Dim = c(2,2,2))) \ No newline at end of file Added: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Asiainits.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Asiainits.txt (rev 0) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Asiainits.txt 2011-12-21 15:46:47 UTC (rev 221) @@ -0,0 +1 @@ +list(smoking = 1, tuberculosis = 1, lung.cancer = 1, bronchitis = 1, xray = 1) \ No newline at end of file Added: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Asiamodel.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Asiamodel.txt (rev 0) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Asiamodel.txt 2011-12-21 15:46:47 UTC (rev 221) @@ -0,0 +1,10 @@ + model + { + smoking ~ dcat(p.smoking[1:2]) + tuberculosis ~ dcat(p.tuberculosis[asia,1:2]) + lung.cancer ~ dcat(p.lung.cancer[smoking,1:2]) + bronchitis ~ dcat(p.bronchitis[smoking,1:2]) + either <- max(tuberculosis,lung.cancer) + xray ~ dcat(p.xray[either,1:2]) + dyspnoea ~ dcat(p.dyspnoea[either,bronchitis,1:2]) + } Added: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Beetlesdata.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Beetlesdata.txt (rev 0) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Beetlesdata.txt 2011-12-21 15:46:47 UTC (rev 221) @@ -0,0 +1,3 @@ +list( x = c(1.6907, 1.7242, 1.7552, 1.7842, 1.8113, 1.8369, 1.8610, 1.8839), + n = c(59, 60, 62, 56, 63, 59, 62, 60), + r = c(6, 13, 18, 28, 52, 53, 61, 60), N = 8) \ No newline at end of file Added: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Beetlesinits.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Beetlesinits.txt (rev 0) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Beetlesinits.txt 2011-12-21 15:46:47 UTC (rev 221) @@ -0,0 +1 @@ +list(alpha.star=0, beta=0) \ No newline at end of file Added: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Beetlesmodel.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Beetlesmodel.txt (rev 0) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Beetlesmodel.txt 2011-12-21 15:46:47 UTC (rev 221) @@ -0,0 +1,11 @@ + model + { + for( i in 1 : N ) { + r[i] ~ dbin(p[i],n[i]) + logit(p[i]) <- alpha.star + beta * (x[i] - mean(x[])) + rhat[i] <- n[i] * p[i] + } + alpha <- alpha.star - beta * mean(x[]) + beta ~ dnorm(0.0,0.001) + alpha.star ~ dnorm(0.0,0.001) + } Added: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/BiRatsdata.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/BiRatsdata.txt (rev 0) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/BiRatsdata.txt 2011-12-21 15:46:47 UTC (rev 221) @@ -0,0 +1,36 @@ + list(x = c(8.0, 15.0, 22.0, 29.0, 36.0), N = 30, T = 5, + Omega = structure(.Data = c(200, 0, 0, 0.2), .Dim = c(2, 2)), + mean = c(0,0), + prec = structure(.Data = c(1.0E-6, 0, 0, 1.0E-6), .Dim = c(2, 2)), + Y = structure( + .Data = c(151, 199, 246, 283, 320, + 145, 199, 249, 293, 354, + 147, 214, 263, 312, 328, + 155, 200, 237, 272, 297, + 135, 188, 230, 280, 323, + 159, 210, 252, 298, 331, + 141, 189, 231, 275, 305, + 159, 201, 248, 297, 338, + 177, 236, 285, 350, 376, + 134, 182, 220, 260, 296, + 160, 208, 261, 313, 352, + 143, 188, 220, 273, 314, + 154, 200, 244, 289, 325, + 171, 221, 270, 326, 358, + 163, 216, 242, 281, 312, + 160, 207, 248, 288, 324, + 142, 187, 234, 280, 316, + 156, 203, 243, 283, 317, + 157, 212, 259, 307, 336, + 152, 203, 246, 286, 321, + 154, 205, 253, 298, 334, + 139, 190, 225, 267, 302, + 146, 191, 229, 272, 302, + 157, 211, 250, 285, 323, + 132, 185, 237, 286, 331, + 160, 207, 257, 303, 345, + 169, 216, 261, 295, 333, + 157, 205, 248, 289, 316, + 137, 180, 219, 258, 291, + 153, 200, 244, 286, 324), + .Dim = c(30,5))) \ No newline at end of file Added: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/BiRatsinits.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/BiRatsinits.txt (rev 0) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/BiRatsinits.txt 2011-12-21 15:46:47 UTC (rev 221) @@ -0,0 +1,10 @@ + list(mu.beta = c(0,0), tauC = 1, + beta = structure( + .Data = c(100,6,100,6,100,6,100,6,100,6, + 100,6,100,6,100,6,100,6,100,6, + 100,6,100,6,100,6,100,6,100,6, + 100,6,100,6,100,6,100,6,100,6, + 100,6,100,6,100,6,100,6,100,6, + 100,6,100,6,100,6,100,6,100,6), + .Dim = c(30, 2)), + R = structure(.Data = c(1,0,0,1), .Dim = c(2, 2))) \ No newline at end of file Added: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/BiRatsmodel.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/BiRatsmodel.txt (rev 0) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/BiRatsmodel.txt 2011-12-21 15:46:47 UTC (rev 221) @@ -0,0 +1,15 @@ + model + { + for( i in 1 : N ) { + beta[i , 1 : 2] ~ dmnorm(mu.beta[], R[ , ]) + for( j in 1 : T ) { + Y[i, j] ~ dnorm(mu[i , j], tauC) + mu[i, j] <- beta[i, 1] + beta[i, 2] * x[j] + } + } + + mu.beta[1 : 2] ~ dmnorm(mean[], prec[ , ]) + R[1 : 2 , 1 : 2] ~ dwish(Omega[ , ], 2) + tauC ~ dgamma(0.001, 0.001) + sigma <- 1 / sqrt(tauC) + } Added: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Cameldata.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Cameldata.txt (rev 0) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Cameldata.txt 2011-12-21 15:46:47 UTC (rev 221) @@ -0,0 +1,15 @@ +list(N= 12, + Y = structure( + .Data = c(1,1, + 1,-1, + -1,1, + -1, -1, + 2, NA, + 2, NA, + -2, NA, + -2, NA, + NA, 2, + NA, 2, + NA, -2, + NA, -2), + .Dim = c(12, 2))) \ No newline at end of file Added: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Camelinits.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Camelinits.txt (rev 0) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Camelinits.txt 2011-12-21 15:46:47 UTC (rev 221) @@ -0,0 +1,15 @@ +list(tau = structure(.Data = c(0.1,0,0,0.1), .Dim = c(2,2)), + Y = structure( + .Data = c(NA,NA, + NA,NA, + NA,NA, + NA, NA, + NA, 1, + NA, 1, + NA, 1, + NA, 1, + 1, NA, + 1, NA, + 1, NA, + 1, NA), + .Dim = c(12, 2))) \ No newline at end of file Added: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Camelmodel.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Camelmodel.txt (rev 0) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Camelmodel.txt 2011-12-21 15:46:47 UTC (rev 221) @@ -0,0 +1,15 @@ + model + { + for (i in 1 : N){ + Y[i, 1 : 2] ~ dmnorm(mu[], tau[ , ]) + } + mu[1] <- 0 + mu[2] <- 0 + tau[1 : 2,1 : 2] ~ dwish(R[ , ], 2) + R[1, 1] <- 0.001 + R[1, 2] <- 0 + R[2, 1] <- 0; + R[2, 2] <- 0.001 + Sigma2[1 : 2,1 : 2] <- inverse(tau[ , ]) + rho <- Sigma2[1, 2] / sqrt(Sigma2[1, 1] * Sigma2[2, 2]) + } Added: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Dugongsdata.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Dugongsdata.txt (rev 0) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Dugongsdata.txt 2011-12-21 15:46:47 UTC (rev 221) @@ -0,0 +1,6 @@ + list(x = c( 1.0, 1.5, 1.5, 1.5, 2.5, 4.0, 5.0, 5.0, 7.0, + 8.0, 8.5, 9.0, 9.5, 9.5, 10.0, 12.0, 12.0, 13.0, + 13.0, 14.5, 15.5, 15.5, 16.5, 17.0, 22.5, 29.0, 31.5), + Y = c(1.80, 1.85, 1.87, 1.77, 2.02, 2.27, 2.15, 2.26, 2.47, + 2.19, 2.26, 2.40, 2.39, 2.41, 2.50, 2.32, 2.32, 2.43, + 2.47, 2.56, 2.65, 2.47, 2.64, 2.56, 2.70, 2.72, 2.57), N = 27) \ No newline at end of file Added: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Dugongsinits.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Dugongsinits.txt (rev 0) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Dugongsinits.txt 2011-12-21 15:46:47 UTC (rev 221) @@ -0,0 +1 @@ +list(alpha = 1, beta = 1, tau = 1, gamma = 0.9) \ No newline at end of file Added: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Dugongsmodel.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Dugongsmodel.txt (rev 0) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Dugongsmodel.txt 2011-12-21 15:46:47 UTC (rev 221) @@ -0,0 +1,13 @@ + model + { + for( i in 1 : N ) { + Y[i] ~ dnorm(mu[i], tau) + mu[i] <- alpha - beta * pow(gamma,x[i]) + } + alpha ~ dnorm(0.0, 1.0E-6) + beta ~ dnorm(0.0, 1.0E-6) + gamma ~ dunif(0.5, 1.0) + tau ~ dgamma(0.001, 0.001) + sigma <- 1 / sqrt(tau) + U3 <- logit(gamma) + } Added: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Dyesdata.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Dyesdata.txt (rev 0) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Dyesdata.txt 2011-12-21 15:46:47 UTC (rev 221) @@ -0,0 +1,8 @@ +list(batches = 6, samples = 5, + y = structure( + .Data = c(1545, 1440, 1440, 1520, 1580, + 1540, 1555, 1490, 1560, 1495, + 1595, 1550, 1605, 1510, 1560, + 1445, 1440, 1595, 1465, 1545, + 1595, 1630, 1515, 1635, 1625, + 1520, 1455, 1450, 1480, 1445), .Dim = c(6, 5))) \ No newline at end of file Added: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Dyesinits.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Dyesinits.txt (rev 0) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Dyesinits.txt 2011-12-21 15:46:47 UTC (rev 221) @@ -0,0 +1 @@ +list(theta=1500, tau.with=1, tau.btw=1) \ No newline at end of file Added: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Dyesmodel.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Dyesmodel.txt (rev 0) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Dyesmodel.txt 2011-12-21 15:46:47 UTC (rev 221) @@ -0,0 +1,14 @@ + model + { + for(i in 1 : batches) { + mu[i] ~ dnorm(theta, tau.btw) + for(j in 1 : samples) { + y[i , j] ~ dnorm(mu[i], tau.with) + } + } + sigma2.with <- 1 / tau.with + sigma2.btw <- 1 / tau.btw + tau.with ~ dgamma(0.001, 0.001) + tau.btw ~ dgamma(0.001, 0.001) + theta ~ dnorm(0.0, 1.0E-10) + } Added: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Equivdata.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Equivdata.txt (rev 0) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Equivdata.txt 2011-12-21 15:46:47 UTC (rev 221) @@ -0,0 +1,13 @@ +list(N = 10, P = 2, + group = c(1, 1, -1, -1, -1, 1, 1, 1, -1, -1), + Y = structure(.Data = c(1.40, 1.65, + 1.64, 1.57, + 1.44, 1.58, + 1.36, 1.68, + 1.65, 1.69, + 1.08, 1.31, + 1.09, 1.43, + 1.25, 1.44, + 1.25, 1.39, + 1.30, 1.52), .Dim = c(10, 2)), + sign = c(1, -1)) \ No newline at end of file Added: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Equivinits.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Equivinits.txt (rev 0) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Equivinits.txt 2011-12-21 15:46:47 UTC (rev 221) @@ -0,0 +1 @@ +list(mu=0, phi=0, pi=0, tau1= 1, tau2 = 1) \ No newline at end of file Added: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Equivmodel.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Equivmodel.txt (rev 0) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Equivmodel.txt 2011-12-21 15:46:47 UTC (rev 221) @@ -0,0 +1,20 @@ + model + { + for( k in 1 : P ) { + for( i in 1 : N ) { + Y[i , k] ~ dnorm(m[i , k], tau1) + m[i , k] <- mu + sign[T[i , k]] * phi / 2 + sign[k] * pi / 2 + delta[i] + T[i , k] <- group[i] * (k - 1.5) + 1.5 + } + } + for( i in 1 : N ) { + delta[i] ~ dnorm(0.0, tau2) + } + tau1 ~ dgamma(0.001, 0.001) sigma1 <- 1 / sqrt(tau1) + tau2 ~ dgamma(0.001, 0.001) sigma2 <- 1 / sqrt(tau2) + mu ~ dnorm(0.0, 1.0E-6) + phi ~ dnorm(0.0, 1.0E-6) + pi ~ dnorm(0.0, 1.0E-6) + theta <- exp(phi) + equiv <- step(theta - 0.8) - step(theta - 1.2) + } Added: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Eyesdata.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Eyesdata.txt (rev 0) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Eyesdata.txt 2011-12-21 15:46:47 UTC (rev 221) @@ -0,0 +1,10 @@ +list(y = c(529.0, 530.0, 532.0, 533.1, 533.4, 533.6, 533.7, 534.1, 534.8, 535.3, + 535.4, 535.9, 536.1, 536.3, 536.4, 536.6, 537.0, 537.4, 537.5, 538.3, + 538.5, 538.6, 539.4, 539.6, 540.4, 540.8, 542.0, 542.8, 543.0, 543.5, + 543.8, 543.9, 545.3, 546.2, 548.8, 548.7, 548.9, 549.0, 549.4, 549.9, + 550.6, 551.2, 551.4, 551.5, 551.6, 552.8, 552.9,553.2), N = 48, alpha = c(1, 1), + T = c(1, NA, NA, NA, NA, NA, NA, NA, NA, NA, + NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, + NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, + NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, + NA, NA, NA, NA, NA, NA, NA, 2)) \ No newline at end of file Added: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Eyesinits.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Eyesinits.txt (rev 0) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Eyesinits.txt 2011-12-21 15:46:47 UTC (rev 221) @@ -0,0 +1 @@ +list(lambda = c(535, NA), theta = 5, tau = 0.1) \ No newline at end of file Added: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Eyesmodel.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Eyesmodel.txt (rev 0) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Eyesmodel.txt 2011-12-21 15:46:47 UTC (rev 221) @@ -0,0 +1,13 @@ + model + { + for( i in 1 : N ) { + y[i] ~ dnorm(mu[i], tau) + mu[i] <- lambda[T[i]] + T[i] ~ dcat(P[]) + } + P[1:2] ~ ddirch(alpha[]) + theta ~ dnorm(0.0, 1.0E-6)I(0.0, ) + lambda[2] <- lambda[1] + theta + lambda[1] ~ dnorm(0.0, 1.0E-6) + tau ~ dgamma(0.001, 0.001) sigma <- 1 / sqrt(tau) + } Added: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Linedata.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Linedata.txt (rev 0) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Linedata.txt 2011-12-21 15:46:47 UTC (rev 221) @@ -0,0 +1 @@ +list(x = c(1, 2, 3, 4, 5), Y= c(1, 3, 3, 3, 5), xbar = 3, N = 5) \ No newline at end of file Added: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Lineinits.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Lineinits.txt (rev 0) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Lineinits.txt 2011-12-21 15:46:47 UTC (rev 221) @@ -0,0 +1 @@ +list(alpha = 0, beta = 0, tau = 1) \ No newline at end of file Added: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Linemodel.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Linemodel.txt (rev 0) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Linemodel.txt 2011-12-21 15:46:47 UTC (rev 221) @@ -0,0 +1,10 @@ + model + { + for( i in 1 : N ) { + Y[i] ~ dnorm(mu[i],tau) + mu[i] <- alpha + beta * (x[i] - xbar) + } + tau ~ dgamma(0.001,0.001) sigma <- 1 / sqrt(tau) + alpha ~ dnorm(0.0,1.0E-6) + beta ~ dnorm(0.0,1.0E-6) + } Added: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/OtreesMVNdata.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/OtreesMVNdata.txt (rev 0) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/OtreesMVNdata.txt 2011-12-21 15:46:47 UTC (rev 221) @@ -0,0 +1,15 @@ + list(n = 7, K = 5, x = c(118.00, 484.00, 664.00, 1004.00, 1231.00, 1372.00, 1582.00), + Y = structure( + .Data = c(30.00, 58.00, 87.00, 115.00, 120.00, 142.00, 145.00, + 33.00, 69.00, 111.00, 156.00, 172.00, 203.00, 203.00, + 30.00, 51.00, 75.00, 108.00, 115.00, 139.00, 140.00, + 32.00, 62.00, 112.00, 167.00, 179.00, 209.00, 214.00, + 30.00, 49.00, 81.00, 125.00, 142.00, 174.00, 177.00), + .Dim = c(5, 7)), + mean = c(0, 0, 0), + R = structure(.Data = c(0.1, 0, 0, + 0, 0.1, 0, + 0, 0, 0.1), .Dim = c(3, 3)), + prec = structure(.Data = c(1.0E-6, 0, 0, + 0, 1.0E-6, 0, + 0, 0, 1.0E-6), .Dim = c(3, 3))) \ No newline at end of file Added: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/OtreesMVNinits.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/OtreesMVNinits.txt (rev 0) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/OtreesMVNinits.txt 2011-12-21 15:46:47 UTC (rev 221) @@ -0,0 +1,12 @@ + list(theta = structure( + .Data = c(5, 2, -6, + 5, 2, -6, + 5, 2, -6, + 5, 2, -6, + 5, 2, -6), + .Dim = c(5, 3)), + mu = c(5, 2, -6), + tau = structure(.Data = c(0.1, 0, 0, + 0, 0.1, 0, + 0, 0, 0.1), .Dim = c(3, 3)), + tauC = 20) \ No newline at end of file Added: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/OtreesMVNmodel.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/OtreesMVNmodel.txt (rev 0) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/OtreesMVNmodel.txt 2011-12-21 15:46:47 UTC (rev 221) @@ -0,0 +1,18 @@ + model { + for (i in 1:K) { + for (j in 1:n) { + Y[i, j] ~ dnorm(eta[i, j], tauC) + eta[i, j] <- phi[i, 1] / (1 + phi[i, 2] * exp(phi[i, 3] * x[j])) + } + phi[i, 1] <- exp(theta[i, 1]) + phi[i, 2] <- exp(theta[i, 2]) - 1 + phi[i, 3] <- -exp(theta[i, 3]) + theta[i, 1:3] ~ dmnorm(mu[1:3], tau[1:3, 1:3]) + } + mu[1:3] ~ dmnorm(mean[1:3], prec[1:3, 1:3]) + tau[1:3, 1:3] ~ dwish(R[1:3, 1:3], 3) + sigma2[1:3, 1:3] <- inverse(tau[1:3, 1:3]) + for (i in 1 : 3) {sigma[i] <- sqrt(sigma2[i, i]) } + tauC ~ dgamma(1.0E-3, 1.0E-3) + sigmaC <- 1 / sqrt(tauC) + } Added: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Ratsdata.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Ratsdata.txt (rev 0) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Ratsdata.txt 2011-12-21 15:46:47 UTC (rev 221) @@ -0,0 +1,33 @@ +list(x = c(8.0, 15.0, 22.0, 29.0, 36.0), xbar = 22, N = 30, T = 5, + Y = structure( + .Data = c(151, 199, 246, 283, 320, + 145, 199, 249, 293, 354, + 147, 214, 263, 312, 328, + 155, 200, 237, 272, 297, + 135, 188, 230, 280, 323, + 159, 210, 252, 298, 331, + 141, 189, 231, 275, 305, + 159, 201, 248, 297, 338, + 177, 236, 285, 350, 376, + 134, 182, 220, 260, 296, + 160, 208, 261, 313, 352, + 143, 188, 220, 273, 314, + 154, 200, 244, 289, 325, + 171, 221, 270, 326, 358, + 163, 216, 242, 281, 312, + 160, 207, 248, 288, 324, + 142, 187, 234, 280, 316, + 156, 203, 243, 283, 317, + 157, 212, 259, 307, 336, + 152, 203, 246, 286, 321, + 154, 205, 253, 298, 334, + 139, 190, 225, 267, 302, + 146, 191, 229, 272, 302, + 157, 211, 250, 285, 323, + 132, 185, 237, 286, 331, + 160, 207, 257, 303, 345, + 169, 216, 261, 295, 333, + 157, 205, 248, 289, 316, + 137, 180, 219, 258, 291, + 153, 200, 244, 286, 324), + .Dim = c(30,5))) \ No newline at end of file Added: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Ratsinits.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Ratsinits.txt (rev 0) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Ratsinits.txt 2011-12-21 15:46:47 UTC (rev 221) @@ -0,0 +1,6 @@ +list(alpha = c(250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, + 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250), + beta = c(6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6), + alpha.c = 150, beta.c = 10, + tau.c = 1, alpha.tau = 1, beta.tau = 1) \ No newline at end of file Added: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Ratsmissdata.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Ratsmissdata.txt (rev 0) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Ratsmissdata.txt 2011-12-21 15:46:47 UTC (rev 221) @@ -0,0 +1,33 @@ + list(x = c(8.0, 15.0, 22.0, 29.0, 36.0), xbar = 22, N = 30, T = 5, + Y = structure( + .Data = c(151, 199, 246, 283, 320, + 145, 199, 249, 293, 354, + 147, 214, 263, 312, 328, + 155, 200, 237, 272, 297, + 135, 188, 230, 280, 323, + 159, 210, 252, 298, NA, + 141, 189, 231, 275, NA, + 159, 201, 248, 297, NA, + 177, 236, 285, 350, NA, + 134, 182, 220, 260, NA, + 160, 208, 261, 313, NA, + 143, 188, 220, NA, NA, + 154, 200, 244, NA, NA, + 171, 221, 270, NA, NA, + 163, 216, 242, NA, NA, + 160, 207, 248, NA, NA, + 142, 187, 234, NA, NA, + 156, 203, 243, NA, NA, + 157, 212, 259, NA, NA, + 152, 203, 246, NA, NA, + 154, 205, 253, NA, NA, + 139, 190, NA, NA, NA, + 146, 191, NA, NA, NA, + 157, 211, NA, NA, NA, + 132, 185, NA, NA, NA, + 160, NA, NA, NA, NA, + 169, NA, NA, NA, NA, + 157, NA, NA, NA, NA, + 137, NA, NA, NA, NA, + 153, NA, NA, NA, NA), + .Dim = c(30,5))) \ No newline at end of file Added: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Ratsmodel.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Ratsmodel.txt (rev 0) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Ratsmodel.txt 2011-12-21 15:46:47 UTC (rev 221) @@ -0,0 +1,18 @@ + model + { + for( i in 1 : N ) { + for( j in 1 : T ) { + Y[i , j] ~ dnorm(mu[i , j],tau.c) + mu[i , j] <- alpha[i] + beta[i] * (x[j] - xbar) + } + alpha[i] ~ dnorm(alpha.c,alpha.tau) + beta[i] ~ dnorm(beta.c,beta.tau) + } + tau.c ~ dgamma(0.001,0.001) + sigma <- 1 / sqrt(tau.c) + alpha.c ~ dnorm(0.0,1.0E-6) + alpha.tau ~ dgamma(0.001,0.001) + beta.c ~ dnorm(0.0,1.0E-6) + beta.tau ~ dgamma(0.001,0.001) + alpha0 <- alpha.c - xbar * beta.c + } Added: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Stacksdata.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Stacksdata.txt (rev 0) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Stacksdata.txt 2011-12-21 15:46:47 UTC (rev 221) @@ -0,0 +1,23 @@ +list(p = 3, N = 21, + Y = c(42, 37, 37, 28, 18, 18, 19, 20, 15, 14, 14, 13, 11, 12, 8, 7, 8, 8, 9, 15, 15), + x = structure(.Data = c( 80, 27, 89, + 80, 27, 88, + 75, 25, 90, + 62, 24, 87, + 62, 22, 87, + 62, 23, 87, + 62, 24, 93, + 62, 24, 93, + 58, 23, 87, + 58, 18, 80, + 58, 18, 89, + 58, 17, 88, + 58, 18, 82, + 58, 19, 93, + 50, 18, 89, + 50, 18, 86, + 50, 19, 72, + 50, 19, 79, + 50, 20, 80, + 56, 20, 82, + 70, 20, 91), .Dim = c(21, 3))) \ No newline at end of file Added: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Stacksinits.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Stacksinits.txt (rev 0) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Stacksinits.txt 2011-12-21 15:46:47 UTC (rev 221) @@ -0,0 +1 @@ +list(beta0 = 10, beta=c(0,0, 0), tau = 0.1, phi = 0.1) \ No newline at end of file Added: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Stacksmodel.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Stacksmodel.txt (rev 0) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Stacksmodel.txt 2011-12-21 15:46:47 UTC (rev 221) @@ -0,0 +1,35 @@ + model + { + # Standardise x's and coefficients + for (j in 1 : p) { + b[j] <- beta[j] / sd(x[ , j ]) + for (i in 1 : N) { + z[i, j] <- (x[i, j] - mean(x[, j])) / sd(x[ , j]) + } + } + b0 <- beta0 - b[1] * mean(x[, 1]) - b[2] * mean(x[, 2]) - b[3] * mean(x[, 3]) + + # Model + d <- 4; # degrees of freedom for t + for (i in 1 : N) { + Y[i] ~ dnorm(mu[i], tau) + # Y[i] ~ ddexp(mu[i], tau) + # Y[i] ~ dt(mu[i], tau, d) + + mu[i] <- beta0 + beta[1] * z[i, 1] + beta[2] * z[i, 2] + beta[3] * z[i, 3] + stres[i] <- (Y[i] - mu[i]) / sigma + outlier[i] <- step(stres[i] - 2.5) + step(-(stres[i] + 2.5) ) + } + # Priors + beta0 ~ dnorm(0, 0.00001) + for (j in 1 : p) { + beta[j] ~ dnorm(0, 0.00001) # coeffs independent + # beta[j] ~ dnorm(0, phi) # coeffs exchangeable (ridge regression) + } + tau ~ dgamma(1.0E-3, 1.0E-3) + phi ~ dgamma(1.0E-2,1.0E-2) + # standard deviation of error distribution + sigma <- sqrt(1 / tau) # normal errors + # sigma <- sqrt(2) / tau # double exponential errors + # sigma <- sqrt(d / (tau * (d - 2))); # t errors on d degrees of freedom + } Added: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Surgicaldata.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Surgicaldata.txt (rev 0) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Surgicaldata.txt 2011-12-21 15:46:47 UTC (rev 221) @@ -0,0 +1,3 @@ +list(n = c(47, 148, 119, 810, 211, 196, 148, 215, 207, 97, 256, 360), + r = c(0, 18, 8, 46, 8, 13, 9, 31, 14, 8, 29, 24), + N = 12) \ No newline at end of file Added: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Surgicalinits.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Surgicalinits.txt (rev 0) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Surgicalinits.txt 2011-12-21 15:46:47 UTC (rev 221) @@ -0,0 +1 @@ + list(p = c(0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1)) \ No newline at end of file Added: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Surgicalmodel.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Surgicalmodel.txt (rev 0) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Surgicalmodel.txt 2011-12-21 15:46:47 UTC (rev 221) @@ -0,0 +1,7 @@ + model + { + for( i in 1 : N ) { + p[i] ~ dbeta(1.0, 1.0) + r[i] ~ dbin(p[i], n[i]) + } + } Added: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Surgicalranddata.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Surgicalranddata.txt (rev 0) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Surgicalranddata.txt 2011-12-21 15:46:47 UTC (rev 221) @@ -0,0 +1,3 @@ +list(n = c(47, 148, 119, 810, 211, 196, 148, 215, 207, 97, 256, 360), + r = c(0, 18, 8, 46, 8, 13, 9, 31, 14, 8, 29, 24), + N = 12) \ No newline at end of file Added: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Surgicalrandinits.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Surgicalrandinits.txt (rev 0) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Surgicalrandinits.txt 2011-12-21 15:46:47 UTC (rev 221) @@ -0,0 +1,2 @@ +list(b = c( 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1), + tau = 1, mu = 0) \ No newline at end of file Added: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Surgicalrandmodel.txt =================================================================== --- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Surgicalrandmodel.txt (rev 0) +++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/Surgicalrandmodel.txt 2011-12-21 15:46:47 UTC (rev 221) @@ -0,0 +1,12 @@ + model + { + for( i in 1 : N ) { + b[i] ~ dnorm(mu,tau) + r[i] ~ dbin(p[i],n[i]) + logit(p[i]) <- b[i] + } + pop.mean <- exp(mu) / (1 + exp(mu)) + mu ~ dnorm(0.0,1.0E-6) + sigma <- 1 / sqrt(tau) + tau ~ dgamma(0.001,0.001) + } Modified: trunk/R2OpenBUGS/man/validateInstallOpenBUGS.Rd =================================================================== --- trunk/R2OpenBUGS/man/validateInstallOpenBUGS.Rd 2011-12-21 10:21:41 UTC (rev 220) +++ trunk/R2OpenBUGS/man/validateInstallOpenBUGS.Rd 2011-12-21 15:46:47 UTC (rev 221) @@ -9,7 +9,6 @@ \usage{ validateInstallOpenBUGS( OpenBUGS.pgm=NULL, - OpenBUGS.examples=NULL, useWINE=FALSE, WINE=NULL, newWINE=TRUE, WINEPATH=NULL ) @@ -17,9 +16,6 @@ \arguments{ \item{OpenBUGS.pgm}{See \code{\link{bugs}}.} - \item{OpenBUGS.examples}{A directory with the OpenBUGS examples - (text versions of model, data, and inits). If \code{NULL}, we try to derive the location - of the 'Examples' directory from the \code{OpenBUGS.pgm} directory.} \item{useWINE}{logical; attempt to use the Wine emulator to run \pkg{OpenBUGS}. Default is \code{FALSE}. If WINE is used, the arguments \code{OpenBUGS.pgm} and \code{working.directory} must be given in form of Linux paths rather than Windows paths (if not \code{NULL}).} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2011-12-21 10:21:52
|
Revision: 220 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=220&view=rev Author: ligges Date: 2011-12-21 10:21:41 +0000 (Wed, 21 Dec 2011) Log Message: ----------- too quick: we have to keep the S-PLKUS part.... Modified Paths: -------------- trunk/R2WinBUGS/R/monitor.R Modified: trunk/R2WinBUGS/R/monitor.R =================================================================== --- trunk/R2WinBUGS/R/monitor.R 2011-12-21 10:18:19 UTC (rev 219) +++ trunk/R2WinBUGS/R/monitor.R 2011-12-21 10:21:41 UTC (rev 220) @@ -30,6 +30,9 @@ confshrink = conv.p$confshrink, n.eff = conv.p$n.eff) } else if (trans[i]=="logit"){ + if (!is.R()){ + logit <- function (x) { log(x /(1- x)) } + } conv.p <- conv.par(logit(ai), n.chains, Rupper.keep=Rupper.keep) conv.p <- list(quantiles = invlogit(conv.p$quantiles), confshrink = conv.p$confshrink, n.eff = conv.p$n.eff) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2011-12-21 10:18:25
|
Revision: 219 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=219&view=rev Author: ligges Date: 2011-12-21 10:18:19 +0000 (Wed, 21 Dec 2011) Log Message: ----------- forgotten NEWS entry for logit from boot Modified Paths: -------------- trunk/R2OpenBUGS/inst/NEWS trunk/R2WinBUGS/inst/NEWS Modified: trunk/R2OpenBUGS/inst/NEWS =================================================================== --- trunk/R2OpenBUGS/inst/NEWS 2011-12-21 10:16:13 UTC (rev 218) +++ trunk/R2OpenBUGS/inst/NEWS 2011-12-21 10:18:19 UTC (rev 219) @@ -5,6 +5,7 @@ - cleanup: removed S-PLUS support completely since that was removed at several other places before - fixed the bugs introduced with validInstallOpenBUGS - Changed handling of default OpenBUGS program location in a sensible way now +- import logit from boot nowadays (seems nobody uses that anyway) Update 3.2-1.2 - Changed handling of default OpenBUGS program location and other changes Modified: trunk/R2WinBUGS/inst/NEWS =================================================================== --- trunk/R2WinBUGS/inst/NEWS 2011-12-21 10:16:13 UTC (rev 218) +++ trunk/R2WinBUGS/inst/NEWS 2011-12-21 10:18:19 UTC (rev 219) @@ -1,6 +1,8 @@ Changes to R2WinBUGS: ===================== +- import logit from boot nowadays (seems nobody uses that anyway) + Update 2.1-17 - fix as.bugs.array as reported by S. McKay Curtis This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2011-12-21 10:16:19
|
Revision: 218 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=218&view=rev Author: ligges Date: 2011-12-21 10:16:13 +0000 (Wed, 21 Dec 2011) Log Message: ----------- We have to import logit from boot nowadays Modified Paths: -------------- trunk/R2WinBUGS/DESCRIPTION trunk/R2WinBUGS/NAMESPACE trunk/R2WinBUGS/R/monitor.R Modified: trunk/R2WinBUGS/DESCRIPTION =================================================================== --- trunk/R2WinBUGS/DESCRIPTION 2011-12-21 10:13:19 UTC (rev 217) +++ trunk/R2WinBUGS/DESCRIPTION 2011-12-21 10:16:13 UTC (rev 218) @@ -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) +Depends: R (>= 2.5.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/NAMESPACE =================================================================== --- trunk/R2WinBUGS/NAMESPACE 2011-12-21 10:13:19 UTC (rev 217) +++ trunk/R2WinBUGS/NAMESPACE 2011-12-21 10:16:13 UTC (rev 218) @@ -1,4 +1,5 @@ importFrom(coda, mcmc.list, as.mcmc.list, read.coda) +importFrom(boot, logit) export(bugs, attach.all, Modified: trunk/R2WinBUGS/R/monitor.R =================================================================== --- trunk/R2WinBUGS/R/monitor.R 2011-12-21 10:13:19 UTC (rev 217) +++ trunk/R2WinBUGS/R/monitor.R 2011-12-21 10:16:13 UTC (rev 218) @@ -30,9 +30,6 @@ confshrink = conv.p$confshrink, n.eff = conv.p$n.eff) } else if (trans[i]=="logit"){ - if (!is.R()){ - logit <- function (x) { log(x /(1- x)) } - } conv.p <- conv.par(logit(ai), n.chains, Rupper.keep=Rupper.keep) conv.p <- list(quantiles = invlogit(conv.p$quantiles), confshrink = conv.p$confshrink, n.eff = conv.p$n.eff) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2011-12-21 10:13:31
|
Revision: 217 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=217&view=rev Author: ligges Date: 2011-12-21 10:13:19 +0000 (Wed, 21 Dec 2011) Log Message: ----------- - cleanup: removed S-PLUS support completely since that was removed at several other places before - fixed the bugs introduced with validInstallOpenBUGS - Changed handling of default OpenBUGS program location in a sensible way now - still needed: valid maintainer address, testing on Linux Modified Paths: -------------- trunk/R2OpenBUGS/DESCRIPTION trunk/R2OpenBUGS/NAMESPACE trunk/R2OpenBUGS/R/attach.all.R trunk/R2OpenBUGS/R/bugs.R trunk/R2OpenBUGS/R/bugs.data.R trunk/R2OpenBUGS/R/bugs.inits.R trunk/R2OpenBUGS/R/bugs.plot.inferences.R trunk/R2OpenBUGS/R/bugs.plot.summary.R trunk/R2OpenBUGS/R/bugs.run.R trunk/R2OpenBUGS/R/bugs.sims.R trunk/R2OpenBUGS/R/bugs.update.settings.R trunk/R2OpenBUGS/R/findOpenBUGS.R trunk/R2OpenBUGS/R/monitor.R trunk/R2OpenBUGS/R/plot.bugs.R trunk/R2OpenBUGS/R/read.bugs.R trunk/R2OpenBUGS/R/validateInstallOpenBUGS.R trunk/R2OpenBUGS/R/wineutils.R trunk/R2OpenBUGS/R/write.model.R trunk/R2OpenBUGS/inst/NEWS trunk/R2OpenBUGS/inst/doc/bugs.tex trunk/R2OpenBUGS/man/bugs.Rd trunk/R2OpenBUGS/man/validateInstallOpenBUGS.Rd trunk/R2OpenBUGS/man/write.model.Rd trunk/R2OpenBUGS/tests/R2OpenBUGS.Rout.save Modified: trunk/R2OpenBUGS/DESCRIPTION =================================================================== --- trunk/R2OpenBUGS/DESCRIPTION 2011-12-19 13:12:00 UTC (rev 216) +++ trunk/R2OpenBUGS/DESCRIPTION 2011-12-21 10:13:19 UTC (rev 217) @@ -1,7 +1,7 @@ Package: R2OpenBUGS Title: Running OpenBUGS from R -Date: 2011-12-15 -Version: 3.2-1.2 +Date: 2011-12-20 +Version: 3.2-1.3 Author: originally written as R2WinBUGS by Andrew Gelman <ge...@st...>; changes and packaged by Sibylle Sturtz <st...@st...> and Uwe Ligges <li...@st...>. @@ -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), coda (>= 0.11-0) +Depends: R (>= 2.11.0), coda (>= 0.11-0), boot SystemRequirements: OpenBUGS (>= 3.2.1) Maintainer: Neal Thomas <nea...@ya...> License: GPL-2 Modified: trunk/R2OpenBUGS/NAMESPACE =================================================================== --- trunk/R2OpenBUGS/NAMESPACE 2011-12-19 13:12:00 UTC (rev 216) +++ trunk/R2OpenBUGS/NAMESPACE 2011-12-21 10:13:19 UTC (rev 217) @@ -1,4 +1,5 @@ importFrom(coda, mcmc.list, as.mcmc.list, read.coda) +importFrom(boot, logit) export(bugs, attach.all, Modified: trunk/R2OpenBUGS/R/attach.all.R =================================================================== --- trunk/R2OpenBUGS/R/attach.all.R 2011-12-19 13:12:00 UTC (rev 216) +++ trunk/R2OpenBUGS/R/attach.all.R 2011-12-21 10:13:19 UTC (rev 217) @@ -1,5 +1,4 @@ attach.all <- function(x, overwrite = NA, name = "attach.all"){ - if(is.R()){ rem <- names(x) %in% ls(.GlobalEnv) if(!any(rem)) overwrite <- FALSE rem <- names(x)[rem] @@ -17,12 +16,6 @@ } if(overwrite) remove(list=rem, envir=.GlobalEnv) attach(x, name=name) - } else { - ## next line is a dirty trick for R'd codetools check in R-2.5.0 - ## (should be removed after codetoold have been improved): - attach.default <- get("attach.default") - attach.default(x, name = name) - } } attach.bugs <- function (x, overwrite = NA){ @@ -36,17 +29,9 @@ } detach.all <- function(name = "attach.all"){ - if (is.R()){ do.call("detach", list(name=name)) - } else { - do.call("detach", list(what=name)) - } } detach.bugs <- function(){ - if (is.R()){ detach.all("bugs.sims") - } else { - invisible(detach.all("bugs.sims")) - } } Modified: trunk/R2OpenBUGS/R/bugs.R =================================================================== --- trunk/R2OpenBUGS/R/bugs.R 2011-12-19 13:12:00 UTC (rev 216) +++ trunk/R2OpenBUGS/R/bugs.R 2011-12-21 10:13:19 UTC (rev 217) @@ -14,11 +14,11 @@ if(is.null(OpenBUGS.pgm)){ OpenBUGS.pgm <- findOpenBUGS() - if(.Platform$OS.type == "windows" | useWINE==TRUE) + if(.Platform$OS.type == "windows" || useWINE) OpenBUGS.pgm <- file.path(OpenBUGS.pgm, "OpenBUGS.exe") - } +} -if(!file.exists(OpenBUGS.pgm) && OpenBUGS.pgm!='OpenBUGS') +if(!file.exists(OpenBUGS.pgm)) stop("Cannot find the OpenBUGS program") ## Is OpenBUGS.pgm defined in Windows (where second character is : @@ -28,7 +28,7 @@ } ### check options for unix/linux - if(.Platform$OS.type != "windows" && useWINE==FALSE){ + if(.Platform$OS.type != "windows" && !useWINE){ if(debug)stop("The debug option is not available with linux/unix") if(save.history)("History plots (save.history) are not available with linux/unix") } @@ -54,8 +54,6 @@ ## Wine if(useWINE) { - if(!is.R()) - stop("Non-Windows platforms not yet supported in R2OpenBUGS for S-PLUS") ## Attempt to find wine and winepath if(is.null(WINE)) WINE <- findUnixBinary(x="wine") if(is.null(WINEPATH)) WINEPATH <- findUnixBinary(x="winepath") @@ -80,15 +78,9 @@ ## model.file is not a file name but a model function if(is.function(model.file)){ temp <- tempfile("model") - temp <- - if(is.R() || .Platform$OS.type != "windows"){ - paste(temp, "txt", sep=".") - } else { - gsub("\\.tmp$", ".txt", temp) - } + temp <- paste(temp, "txt", sep=".") write.model(model.file, con=temp, digits=digits) model.file <- gsub("\\\\", "/", temp) - if(!is.R()) on.exit(file.remove(model.file), add=TRUE) } if(inTempDir && basename(model.file) == model.file) try(file.copy(file.path(savedWD, model.file), model.file, overwrite = TRUE)) Modified: trunk/R2OpenBUGS/R/bugs.data.R =================================================================== --- trunk/R2OpenBUGS/R/bugs.data.R 2011-12-19 13:12:00 UTC (rev 216) +++ trunk/R2OpenBUGS/R/bugs.data.R 2011-12-21 10:13:19 UTC (rev 217) @@ -1,239 +1,13 @@ "bugs.data" <- function(data, dir = getwd(), digits = 5, data.file = "data.txt"){ if(is.numeric(unlist(data))) - if(is.R()) { write.datafile(lapply(data, formatC, digits = digits, format = "E"), file.path(dir, data.file)) - } - else { - writeDatafileS4(data, towhere = data.file) - } else { - if(is.R()) { data.list <- lapply(as.list(data), get, pos = parent.frame(2)) names(data.list) <- as.list(data) write.datafile(lapply(data.list, formatC, digits = digits, format = "E"), file.path(dir, data.file)) - } - else { - data.list <- lapply(as.list(data), get, where = parent.frame(2)) - names(data.list) <- unlist(data) - writeDatafileS4(data.list, towhere = data.file) - } } return(data.file) } - - -if(is.R()){ - ## need some fake functions for codetools - toSingleS4 <- function(...) - stop("This function is not intended to be called in R!") - "writeDatafileS4" <- toSingleS4 -} else { - -### The rest of this file is for S-PLUS only... - - -"writeDatafileS4" <- -# -# Writes to file "towhere" text defining a list containing "DATA" in a form compatable with OpenBUGS. -# Required arguments: -# DATA - either a data frame or else a list consisting of any combination of scalars, vectors, arrays or data frames (but not lists). -# If a list, all list elements that are not data.frames must be named. Names of data.frames in DATA are ignored. -# Optional arguments: -# towhere - file to receive output. Is clipboard by default, which is convenient for pasting into a OpenBUGS ODC file. -# fill - If numeric, number of columns for output. If FALSE, output will be on one line. If TRUE (default), number of -# columns is given by .Options$width. -# Value: -# Text defining a list is output to file "towhere". -# Details: -# The function performs considerable checking of DATA argument. Since OpenBUGS requires numeric input, no factors or character vectors -# are allowed. All data must be named, either as named elements of DATA (if it is a list) or else using the names given in data frames. -# Data frames may contain matrices. -# Arrays of any dimension are rearranged to be in row-major order, as required by OpenBUGS. Scientific notation is also handled properly. -# In particular, the number will consist of a mantissa _containing a decimal point_ followed by "E", then either "+" or "-", and finally -# a _two-digit_ number. S-Plus does not always provide a decimal point in the mantissa, uses "e" instead of "E", followed by -# either a "+" or "-" and then _three_ digits. -# Written by Terry Elrod. Disclaimer: This function is used at the user's own risk. -# Please send comments to Ter...@UA.... -# Revision history: 2002-11-19. Fixed to handle missing values properly. -function(DATA, towhere = "clipboard", fill = TRUE) -{ - formatDataS4 = - # - # Prepared DATA for input to OpenBUGS. - function(DATA) - { - if(!is.list(DATA)) - stop("DATA must be a named list or data frame.") - dlnames <- names(DATA) - if(is.data.frame(DATA)) - DATA <- as.list(DATA) - # - # Checking for lists in DATA.... - lind <- sapply(DATA, is.list) - # Checking for data frames in DATA.... - dfind <- sapply(DATA, is.data.frame) - # Any lists that are not data frames?... - if(any(lind & !dfind)) stop("DATA may not contain lists.") - # Checking for unnamed elements of list that are not data frames.... - if(any(dlnames[!dfind] == "")) stop( - "When DATA is a list, all its elements that are not data frames must be named." - ) - # Checking for duplicate names.... - dupnames <- unique(dlnames[duplicated(dlnames)]) - if(length(dupnames) > 0) - stop(paste( - "The following names are used more than once in DATA:", - paste(dupnames, collapse = ", "))) - if(any(dfind)) { - dataold <- DATA - DATA <- vector("list", 0) - for(i in seq(along = dataold)) { - if(dfind[i]) - DATA <- c(DATA, as.list(dataold[[i]])) - else DATA <- c(DATA, dataold[i]) - } - dataold <- NULL - } - dlnames <- names(DATA) - dupnames <- unique(dlnames[duplicated(dlnames)]) - # Checking for duplicated names again (now that columns of data frames are included).... - if(length(dupnames) > 0) stop(paste( - "The following names are used more than once in DATA (at least once within a data frame):", - paste(dupnames, collapse = ", "))) - # Checking for factors.... - factorind <- sapply(DATA, is.factor) - if(any(factorind)) - stop(paste( - "DATA may not include factors. One or more factor variables were detected:", - paste(dlnames[factorind], collapse = ", "))) - # Checking for character vectors.... - charind <- sapply(DATA, is.character) - if(any(charind)) - stop(paste( - "OpenBUGS does not handle character data. One or more character variables were detected:", - paste(dlnames[charind], collapse = ", "))) - # Checking for complex vectors.... - complexind <- sapply(DATA, is.complex) - if(any(complexind)) - stop(paste( - "OpenBUGS does not handle complex data. One or more complex variables were detected:", - paste(dlnames[complexind], collapse = ", "))) - # Checking for values farther from zero than 1E+38 (which is limit of single precision).... - toobigind <- sapply(DATA, function(x) - { - y <- abs(x[!is.na(x)]) - any(y[y > 0] > 9.9999999999999998e+37) - } - ) - if(any(toobigind)) - stop(paste( - "OpenBUGS works in single precision. The following variables contain data outside the range +/-1.0E+38: ", - paste(dlnames[toobigind], collapse = ", "), - ".\n", sep = "")) - # Checking for values in range +/-1.0E-38 (which is limit of single precision).... - toosmallind <- sapply(DATA, function(x) - { - y <- abs(x[!is.na(x)]) - any(y[y > 0] < 9.9999999999999996e-39) - } - ) - n <- length(dlnames) - data.string <- as.list(rep(NA, n)) - for(i in 1:n) { - if(length(DATA[[i]]) == 1) { - ac <- toSingleS4(DATA[[i]]) - data.string[[i]] <- paste(names(DATA)[i], "=", - ac, sep = "") - next - } - if(is.vector(DATA[[i]]) & length(DATA[[i]]) > 1) { - ac <- toSingleS4(DATA[[i]]) - data.string[[i]] <- paste(names(DATA)[i], "=c(", - paste(ac, collapse = ", "), ")", sep = - "") - next - } - if(is.array(DATA[[i]])) { - ac <- toSingleS4(aperm(DATA[[i]])) - data.string[[i]] <- paste(names(DATA)[i], - "= structure(.Data= c(", paste(ac, - collapse = ", "), "), \n .Dim=c(", - paste(as.character(dim(DATA[[i]])), - collapse = ", "), "))", sep = "") - } - } - data.tofile <- paste("list(", paste(unlist(data.string), - collapse = ", "), ")", sep = "") - if(any(toosmallind)) - warning(paste( - "OpenBUGS works in single precision. The following variables contained nonzero data", - "\ninside the range +/-1.0E-38 that were set to zero: ", - paste(dlnames[toosmallind], collapse = ", "), - ".\n", sep = "")) - return(data.tofile) - } - rslt <- formatDataS4(DATA) - cat(rslt, file = towhere, fill = fill) - invisible(0) -} - - -toSingleS4 <- -# -# Takes numeric vector and removes digit of exponent in scientific notation (if any) -# -# Written by Terry Elrod. Disclaimer: This function is used at the user's own risk. -# Please send comments to Ter...@UA.... -# Revision history: 2002-11-19. Fixed to handle missing values properly. -function(x) -{ - xdim <- dim(x) - x <- as.character(as.single(x)) - - # First to look for positives: - pplus <- regMatchPos(x, "e\\+0") - pplusind <- apply(pplus, 1, function(y) - (!any(is.na(y)))) - if(any(pplusind)) { - # Making sure that periods are in mantissa... - init <- substring(x[pplusind], 1, pplus[ - pplusind, 1] - 1) - #...preceeding exponent - pper <- regMatchPos(init, "\\.") - pperind <- apply(pper, 1, function(y) - (all(is.na(y)))) - if(any(pperind)) - init[pperind] <- paste(init[pperind], - ".0", sep = "") - # Changing the format of the exponent... - x[pplusind] <- paste(init, "E+", substring( - x[pplusind], pplus[pplusind, 2] + 1), - sep = "") - } - # Then to look for negatives: - pminus <- regMatchPos(x, "e\\-0") - pminusind <- apply(pminus, 1, function(y) - (!any(is.na(y)))) - if(any(pminusind)) { - # Making sure that periods are in mantissa... - init <- substring(x[pminusind], 1, pminus[ - pminusind, 1] - 1) - #...preceeding exponent - pper <- regMatchPos(init, "\\.") - pperind <- apply(pper, 1, function(y) - (all(is.na(y)))) - if(any(pperind)) - init[pperind] <- paste(init[pperind], - ".0", sep = "") - # Changing the format of the exponent... - x[pminusind] <- paste(init, "E-", substring( - x[pminusind], pminus[pminusind, 2] + - 1), sep = "") - } - x -} - -} Modified: trunk/R2OpenBUGS/R/bugs.inits.R =================================================================== --- trunk/R2OpenBUGS/R/bugs.inits.R 2011-12-19 13:12:00 UTC (rev 216) +++ trunk/R2OpenBUGS/R/bugs.inits.R 2011-12-21 10:13:19 UTC (rev 217) @@ -4,18 +4,11 @@ if(!is.null(inits)) { for(i in 1:n.chains) { if(is.function(inits)) - if(is.R()) { write.datafile(lapply(inits(), formatC, digits = digits, format = "E"), inits.files[i]) - } else { - writeDatafileS4(inits(), towhere = inits.files[i]) - } - else if(is.R()) { + else write.datafile(lapply(inits[[i]], formatC, digits = digits, format = "E"), inits.files[i]) - } else { - writeDatafileS4(inits[[i]], towhere = inits.files[i]) - } } } return(inits.files) Modified: trunk/R2OpenBUGS/R/bugs.plot.inferences.R =================================================================== --- trunk/R2OpenBUGS/R/bugs.plot.inferences.R 2011-12-19 13:12:00 UTC (rev 216) +++ trunk/R2OpenBUGS/R/bugs.plot.inferences.R 2011-12-21 10:13:19 UTC (rev 217) @@ -29,16 +29,8 @@ height <- .6 par (mar=c(0,0,1,0)) - ## if in Splus, suppress printing of warnings during the plotting. - ## otherwise a warning is generated - if (!is.R()){ - warn.settings <- options("warn")[[1]] - options (warn = -1) - } plot (c(0,1), c(-n.roots-.5,-.4), ann=FALSE, bty="n", xaxt="n", yaxt="n", type="n") - if (!is.R()) - options(warn = warn.settings) W <- max(strwidth(rootnames, cex=cex.names)) B <- (1-W)/3.8 Modified: trunk/R2OpenBUGS/R/bugs.plot.summary.R =================================================================== --- trunk/R2OpenBUGS/R/bugs.plot.summary.R 2011-12-19 13:12:00 UTC (rev 216) +++ trunk/R2OpenBUGS/R/bugs.plot.summary.R 2011-12-21 10:13:19 UTC (rev 217) @@ -30,11 +30,7 @@ J[J==max(J)] <- max(J)-1 total <- ceiling(sum(J+.5)) } - if (is.R()){ pos <- -1 - } else { - pos <- -1.5 - } ypos <- NULL id <- NULL ystart <- NULL @@ -44,25 +40,12 @@ ystart <- numeric(n.roots) for (k in 1:n.roots){ ystart[k] <- pos - if (is.R()) { ypos <- c(ypos, pos - seq(0, J[k]-1)) - } else { - # In S-PLUS, increase the vertical spacing - ypos <- c(ypos, pos - 1.5*seq(0, J[k]-1)) - } id <- c(id, 1:J[k]) - if (is.R()) { pos <- pos - J[k] -.5 - } else { - pos <- pos - 1.5*J[k] -0.75 - } if (k>1) jj <- c(jj, sum(J0[1:(k-1)]) + (1:J[k])) } - if (is.R()){ bottom <- min(ypos)-1 - } else { - bottom <- min(ypos)-1.5 - } med <- numeric(sum(J)) i80 <- matrix( , sum(J), 2) i80.chains <- array (NA, c(sum(J), n.chains, 2)) @@ -78,16 +61,8 @@ a <- -b * p.rng[1] par (mar=c(0,0,1,3)) - # if in Splus, suppress printing of warnings during the plotting. - # otherwise a warning is generated - if (!is.R()){ - warn.settings <- options("warn")[[1]] - options (warn = -1) - } plot (c(0,1), c(min(bottom, -max.length)-3,2.5), ann=FALSE, bty="n", xaxt="n", yaxt="n", type="n") - if (!is.R()) - options(warn = warn.settings) W <- max(strwidth(unlist(dimnames(summ)[[1]]), cex=cex.names)) B <- (1-W)/3.6 @@ -126,16 +101,7 @@ for (j in 1:sum(J)){ name <- dimnames(summ)[[1]][jj[j]] if (id[j]==1) - if (is.R()) { text (0, ypos[j], name, adj=0, cex=cex.names) - } else { - # in S-PLUS, strwidth is an upper bound on the length of the string, - # so we must align the brackets differently than in R - pos <- as.vector(regexpr("[[]", name)) - text (0, ypos[j], substring(name, 1, pos-1), adj=0, cex=cex.names) - text (strwidth(substring(name,1,pos-1),cex=cex.names), - ypos[j], substring(name, pos, nchar(name)), adj=0, cex=cex.names) - } else { pos <- as.vector(regexpr("[[]", name)) text (strwidth(substring(name,1,pos-1),cex=cex.names), Modified: trunk/R2OpenBUGS/R/bugs.run.R =================================================================== --- trunk/R2OpenBUGS/R/bugs.run.R 2011-12-19 13:12:00 UTC (rev 216) +++ trunk/R2OpenBUGS/R/bugs.run.R 2011-12-21 10:13:19 UTC (rev 217) @@ -4,18 +4,11 @@ newWINE=TRUE, WINEPATH=NULL) { - if(useWINE && !is.R()) - stop("Non-Windows platforms not yet supported in R2OpenBUGS for S-PLUS") - - ## Update the lengths of the adaptive phases in the Bugs updaters +## Update the lengths of the adaptive phases in the Bugs updaters # try(bugs.update.settings(n.burnin, bugs.directory)) # # ## Return the lengths of the adaptive phases to their original settings -# if(is.R()) { # .fileCopy <- file.copy -# } else { -# .fileCopy <- splus.file.copy -# } # on.exit(try(.fileCopy(file.path(bugs.directory, "System/Rsrc/Registry_Rsave.odc"), # file.path(bugs.directory, "System/Rsrc/Registry.odc"), # overwrite=TRUE))) @@ -41,12 +34,8 @@ ## !!!! need to check these conditions ## Stop and print an error message if Bugs did not run correctly - if(is.R()) { tmp <- scan("CODAchain1.txt", character(), quiet=TRUE, sep="\n") - } else { - tmp <- scan("CODAchain1.txt", character(), sep="\n") - } - tmp<-tmp[1:min(100,length(tmp))] + tmp <- tmp[1:min(100,length(tmp))] if(length(grep("OpenBUGS did not run correctly", tmp)) > 0) stop(paste("Look at the log file in ",getwd(), " and\ntry again with 'debug=TRUE' to figure out what went wrong within OpenBUGS.")) } Modified: trunk/R2OpenBUGS/R/bugs.sims.R =================================================================== --- trunk/R2OpenBUGS/R/bugs.sims.R 2011-12-19 13:12:00 UTC (rev 216) +++ trunk/R2OpenBUGS/R/bugs.sims.R 2011-12-21 10:13:19 UTC (rev 217) @@ -5,16 +5,8 @@ sims.files <- paste ("CODAchain", 1:n.chains, ".txt", sep="") ## read in the names of the parameters and the indices of their samples index <- read.table("CODAindex.txt", header = FALSE, sep = " ") - ## in Splus, read.table interprets the first row of the file as row names, - ## while in R it does not - if(is.R()) { - parameter.names <- as.vector(index[, 1]) - n.keep <- index[1, 3] - index[1, 2] + 1 - } - else { - parameter.names <- row.names(index) - n.keep <- index[1, 2] - index[1, 1] + 1 - } + parameter.names <- as.vector(index[, 1]) + n.keep <- index[1, 3] - index[1, 2] + 1 n.parameters <- length(parameter.names) n.sims <- n.keep*n.chains sims <- matrix( , n.sims, n.parameters) @@ -58,11 +50,7 @@ rank.long <- unlist(long.short) for (i in 1:n.chains){ - if(is.R()) { sims.i <- scan(sims.files[i], quiet = TRUE)[2 * (1:(n.keep * n.parameters))] - } else { - sims.i <- scan(sims.files[i])[2 * (1:(n.keep * n.parameters))] - } sims[(n.keep*(i-1)+1):(n.keep*i), ] <- sims.i sims.array[,i,] <- sims.i } @@ -125,7 +113,6 @@ LOG <- bugs.log("log.txt")$DIC if(any(is.na(LOG))) { ## Something went wrong --> Use Gelman's tweak deviance <- all$sims.array[, , dim(sims.array)[3], drop = FALSE] - if(!is.R()) dimnames(deviance) <- NULL dim(deviance) <- dim(deviance)[1:2] pD <- numeric(n.chains) DIC <- numeric(n.chains) @@ -144,5 +131,3 @@ } all } - -if(!is.R()) .subset <- function(x, index) x[index] Modified: trunk/R2OpenBUGS/R/bugs.update.settings.R =================================================================== --- trunk/R2OpenBUGS/R/bugs.update.settings.R 2011-12-19 13:12:00 UTC (rev 216) +++ trunk/R2OpenBUGS/R/bugs.update.settings.R 2011-12-21 10:13:19 UTC (rev 217) @@ -1,7 +1,6 @@ "bugs.update.settings" <- function (n.burnin, bugs.directory) { - if(is.R()) { .fileCopy <- file.copy .regexpr <- function(...) regexpr(..., useBytes = TRUE) .sub <- function(...) sub(..., useBytes = TRUE) @@ -10,12 +9,6 @@ function(...) writeBin(..., useBytes = TRUE) else writeBin - } else { - .fileCopy <- splus.file.copy - .regexpr <- regexpr - .sub <- sub - .writeBin <- writeBin - } char.burnin <- as.character(n.burnin - 1) @@ -46,15 +39,3 @@ .writeBin(registry, file.path(bugs.directory, "System/Rsrc/Registry.odc"), endian="little") } - - -splus.file.copy <- function(from, to, overwrite=FALSE) -{ - if(!file.exists(from)) - stop("File: ", from, " does not exist") - if(!overwrite && file.exists(to)) - stop("File: ", to, " already exists and overwrite is FALSE") - n <- file.info(from)$size - z <- writeBin(readBin(from, what="integer", size=1, n=n), to, size=1) - invisible(z) -} Modified: trunk/R2OpenBUGS/R/findOpenBUGS.R =================================================================== --- trunk/R2OpenBUGS/R/findOpenBUGS.R 2011-12-19 13:12:00 UTC (rev 216) +++ trunk/R2OpenBUGS/R/findOpenBUGS.R 2011-12-21 10:13:19 UTC (rev 217) @@ -8,7 +8,7 @@ return(dir) if(.Platform$OS.type != "windows") - return('/usr/local/bin/OpenBUGS') + return(Sys.which('OpenBUGS')) deps <- utils:::packageDescription("R2OpenBUGS", fields="SystemRequirements") version.req <- gsub(".*OpenBUGS ?\\(>= ?(.+)\\).*", "\\1", deps) Modified: trunk/R2OpenBUGS/R/monitor.R =================================================================== --- trunk/R2OpenBUGS/R/monitor.R 2011-12-19 13:12:00 UTC (rev 216) +++ trunk/R2OpenBUGS/R/monitor.R 2011-12-21 10:13:19 UTC (rev 217) @@ -30,9 +30,6 @@ confshrink = conv.p$confshrink, n.eff = conv.p$n.eff) } else if (trans[i]=="logit"){ - if (!is.R()){ - logit <- function (x) { log(x /(1- x)) } - } conv.p <- conv.par(logit(ai), n.chains, Rupper.keep=Rupper.keep) conv.p <- list(quantiles = invlogit(conv.p$quantiles), confshrink = conv.p$confshrink, n.eff = conv.p$n.eff) Modified: trunk/R2OpenBUGS/R/plot.bugs.R =================================================================== --- trunk/R2OpenBUGS/R/plot.bugs.R 2011-12-19 13:12:00 UTC (rev 216) +++ trunk/R2OpenBUGS/R/plot.bugs.R 2011-12-21 10:13:19 UTC (rev 217) @@ -2,10 +2,7 @@ mar.old <- par("mar") pty.old <- par(pty = "m") mfrow.old <- par("mfrow") - if (is.R()) layout(matrix(c(1,2),1,2)) - else - par(mfrow = c(1,2)) bugs.plot.summary (x, ...) bugs.plot.inferences (x, display.parallel, ...) @@ -17,42 +14,5 @@ header <- paste(header, x$n.chains, " chains, each with ", x$n.iter, " iterations (first ", x$n.burnin, " discarded)", sep = "") mtext(header, outer = TRUE, line = -1, cex = 0.7) - if (is.R()) par(pty = pty.old[[1]], mar = mar.old, mfrow = mfrow.old) - else invisible(par(pty = pty.old[[1]], mar = mar.old, mfrow = mfrow.old)) + par(pty = pty.old[[1]], mar = mar.old, mfrow = mfrow.old) } - -if (!is.R()) { - -strwidth <-function(s, units = c("user", "inches", "figure"), cex = NULL) { - s<-as.character(s) - if (!missing(cex)) { - oldcex <- par(cex=cex) - on.exit(par(oldcex)) - } - units <- match.arg(units) - if (units == "user") { - nchar(s) * par("cxy")[1] - } else if (units == "inches") { - nchar(s) * par("cin")[1] - } else if (units == "figure") { - nchar(s) * par("cin")[1] / par("fin")[1] - } -} - -strheight <- function(s, units = "user", cex = NULL) { - s<-as.character(s) - if (!missing(cex)) { - oldcex <- par(cex=cex) - on.exit(par(oldcex)) - } - units <- match.arg(units) - if (units == "user") { - par("cxy")[2] - } else if (units == "inches") { - par("cin")[2] - } else if (units == "figure") { - par("cin")[2] / par("fin")[2] - } -} - -} #ends if (!is.R()) Modified: trunk/R2OpenBUGS/R/read.bugs.R =================================================================== --- trunk/R2OpenBUGS/R/read.bugs.R 2011-12-19 13:12:00 UTC (rev 216) +++ trunk/R2OpenBUGS/R/read.bugs.R 2011-12-21 10:13:19 UTC (rev 217) @@ -1,6 +1,4 @@ read.bugs <- function(codafiles, ...){ - if(!is.R() && !require("coda")) - 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/R2OpenBUGS/R/validateInstallOpenBUGS.R =================================================================== --- trunk/R2OpenBUGS/R/validateInstallOpenBUGS.R 2011-12-19 13:12:00 UTC (rev 216) +++ trunk/R2OpenBUGS/R/validateInstallOpenBUGS.R 2011-12-21 10:13:19 UTC (rev 217) @@ -13,14 +13,17 @@ OpenBUGS.pgm <- file.path(OpenBUGS.pgm, "OpenBUGS.exe") } -if(!file.exists(OpenBUGS.pgm) && OpenBUGS.pgm!='OpenBUGS') +if(!file.exists(OpenBUGS.pgm)) stop("Cannot find the OpenBUGS program") if(is.null(OpenBUGS.examples)){ if(.Platform$OS.type == "windows" | useWINE==TRUE){ OpenBUGS.examples <- file.path(dirname(OpenBUGS.pgm), 'Examples') - }else OpenBUGS.examples <-'/usr/local/lib/OpenBUGS/doc/Examples' + }else { + ## best guess? + OpenBUGS.examples <- gsub("bin/OpenBUGS", "lib/OpenBUGS/Examples", OpenBUGS.pgm) + } } if(!file.exists(OpenBUGS.examples)) Modified: trunk/R2OpenBUGS/R/wineutils.R =================================================================== --- trunk/R2OpenBUGS/R/wineutils.R 2011-12-19 13:12:00 UTC (rev 216) +++ trunk/R2OpenBUGS/R/wineutils.R 2011-12-21 10:13:19 UTC (rev 217) @@ -26,7 +26,6 @@ native2win <- function(x, useWINE=.Platform$OS.type != "windows", newWINE=TRUE, WINEPATH=NULL) { - if (is.R()){ ## Translate Unix path to Windows (wine) path if(useWINE) { if(newWINE) { @@ -39,9 +38,6 @@ } else { x } - } else { #S-PLUS - gsub("\\\\", "/", x) - } } win2native <- function(x, useWINE=.Platform$OS.type != "windows", Modified: trunk/R2OpenBUGS/R/write.model.R =================================================================== --- trunk/R2OpenBUGS/R/write.model.R 2011-12-19 13:12:00 UTC (rev 216) +++ trunk/R2OpenBUGS/R/write.model.R 2011-12-21 10:13:19 UTC (rev 217) @@ -1,26 +1,11 @@ write.model <- function(model, con = "model.bug", digits = 5) { - if (is.R()){ - model.text <- c("model", replaceScientificNotationR(body(model), digits = digits)) - # "[\+\-]?\d*\.?[Ee]?[\+\-]?\d*" - } else { - ## In S-PLUS the source code of a function can be obtained with - ## as.character(function_name). This omits the "function_name <- function()" piece - model.text <- paste("model", as.character(model)) - } + model.text <- c("model", replaceScientificNotationR(body(model), digits = digits)) + # "[\+\-]?\d*\.?[Ee]?[\+\-]?\d*" model.text <- gsub("%_%", "", model.text) - if (!is.R()){ - ## In S-PLUS, scientific notation is different than it is in OpenBUGS. - ## Change the format of any numbers in scientific notation. - model.text <- replaceScientificNotationS(model.text) - - ## remove the "invisible()" line. - model.text <- gsub("invisible[ ]*\\([ ]*\\)", "", model.text) - } writeLines(model.text, con = con) } - replaceScientificNotationR <- function(bmodel, digits = 5){ env <- new.env() assign("rSNRidCounter", 0, envir=env) @@ -47,37 +32,3 @@ } bmodel } - - - -replaceScientificNotationS <- function(text){ -## Change the format of any numbers in "text" that are in S-PLUS -## scientific notation to OpenBUGS scientific notation - - ## First, handle the positive exponents - ## Find the first instance - ## Note that the number may or may not have a decimal point. - sciNoteLoc <- regexpr("[0-9]*\\.{0,1}[0-9]*e\\+0[0-9]{2}", text) - - ## For every instance, replace the number - while(sciNoteLoc > -1){ - sciNoteEnd <- sciNoteLoc + attr(sciNoteLoc, "match.length")-1 - sciNote <- substring(text, sciNoteLoc, sciNoteEnd) - text <- gsub(sciNote, toSingleS4(sciNote), text) - sciNoteLoc <- regexpr("[0-9]*\\.{0,1}[0-9]*e\\+0[0-9]{2}", text) - } - - ## Then, handle the negative exponents - ## Find the first instance - sciNoteLoc <- regexpr("[0-9]*\\.{0,1}[0-9]*e\\-0[0-9]{2}", text) - - ## For every instance, replace the number - while(sciNoteLoc > -1){ - sciNoteEnd <- sciNoteLoc + attr(sciNoteLoc, "match.length")-1 - sciNote <- substring(text, sciNoteLoc, sciNoteEnd) - text <- gsub(sciNote, toSingleS4(sciNote), text) - sciNoteLoc <- regexpr("[0-9]*\\.{0,1}[0-9]*e\\-0[0-9]{2}", text) - } - - text -} Modified: trunk/R2OpenBUGS/inst/NEWS =================================================================== --- trunk/R2OpenBUGS/inst/NEWS 2011-12-19 13:12:00 UTC (rev 216) +++ trunk/R2OpenBUGS/inst/NEWS 2011-12-21 10:13:19 UTC (rev 217) @@ -1,6 +1,11 @@ Changes to R2OpenBUGS: ====================== +Update 3.2-1.3 +- cleanup: removed S-PLUS support completely since that was removed at several other places before +- fixed the bugs introduced with validInstallOpenBUGS +- Changed handling of default OpenBUGS program location in a sensible way now + Update 3.2-1.2 - Changed handling of default OpenBUGS program location and other changes required for cran compliance Modified: trunk/R2OpenBUGS/inst/doc/bugs.tex =================================================================== --- trunk/R2OpenBUGS/inst/doc/bugs.tex 2011-12-19 13:12:00 UTC (rev 216) +++ trunk/R2OpenBUGS/inst/doc/bugs.tex 2011-12-21 10:13:19 UTC (rev 217) @@ -1,25 +1,25 @@ \inputencoding{utf8} -\HeaderA{bugs}{Run OpenBUGS from R or S-PLUS}{bugs} +\HeaderA{bugs}{Run OpenBUGS from R}{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 \pkg{OpenBUGS} script, calls the model, and -saves the simulations for easy access in \R{} or S-PLUS. +saves the simulations for easy access in \R{}. \end{Description} % \begin{Usage} \begin{verbatim} bugs(data, inits, parameters.to.save, n.iter, model.file="model.txt", - n.chains=3, n.burnin=floor(n.iter / 2), n.thin=1, + n.chains=3, n.burnin=floor(n.iter / 2), n.thin=1, saveExec=FALSE,restart=FALSE, debug=FALSE, DIC=TRUE, digits=5, codaPkg=FALSE, OpenBUGS.pgm=NULL, working.directory=NULL, clearWD=FALSE, useWINE=FALSE, WINE=NULL, newWINE=TRUE, WINEPATH=NULL, bugs.seed=1, summary.only=FALSE, - save.history=(.Platform$OS.type == "windows" | useWINE==TRUE), - over.relax = FALSE) + save.history=(.Platform$OS.type == "windows" | useWINE==TRUE), + over.relax = FALSE) \end{verbatim} \end{Usage} % @@ -28,15 +28,15 @@ \item[\code{data}] either a named list (names corresponding to variable names in the \code{model.file}) of the data for the \pkg{OpenBUGS} model, \emph{or} a vector or list of the names of the data objects used by -the model. If \code{data} is a one element character vector (such as \code{"data.txt"}), -it is assumed that data have already been written to the working directory into that file, +the model. If \code{data} is a one element character vector (such as \code{"data.txt"}), +it is assumed that data have already been written to the working directory into that file, 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 \pkg{OpenBUGS} model, \emph{or} a function creating (possibly random) initial values. Alternatively, if \code{inits=NULL}, initial values are generated -by \pkg{OpenBUGS}. If \code{inits} is a character vector with \code{n.chains} elements, -it is assumed that inits have already been written to the working directory into those files, +by \pkg{OpenBUGS}. If \code{inits} is a character vector with \code{n.chains} elements, +it is assumed that inits have already been written to the working directory into those files, e.g. by the function \code{\LinkA{bugs.inits}{bugs.inits}}. \item[\code{parameters.to.save}] character vector of the names of the parameters to save which should be monitored @@ -45,8 +45,8 @@ The old convention allowing model.file to be named \file{.bug} has been eliminated because the new \pkg{OpenBUGS} feature that allows the program image to be saved and later restarted uses the .bug extension for the saved -images. -Alternatively, \code{model.file} can be an R function that contains a BUGS model that is written to a +images. +Alternatively, \code{model.file} can be an R function that contains a BUGS model that is written to a temporary model file (see \code{\LinkA{tempfile}{tempfile}}) using \code{\LinkA{write.model}{write.model}}. \item[\code{n.chains}] number of Markov chains (default: 3) \item[\code{n.iter}] number of total iterations per chain (including burn in; @@ -54,26 +54,26 @@ \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. The default is +\item[\code{n.thin}] Thinning rate. Must be a positive integer. The default is \code{n.thin} = 1. The thinning is implemented in the OpenBUGS update phase, so thinned samples are never stored, and they are not counted in \code{n.burnin} or -\code{n.iter}. Setting \code{n.thin}=2, doubles the number of iterations OpenBUGS +\code{n.iter}. Setting \code{n.thin}=2, doubles the number of iterations OpenBUGS performs, but does not change \code{n.iter} or \code{n.burnin}. Thinning implemented in this manner is not captured in summaries created by packages such as \pkg{coda}. \item[\code{saveExec}] If TRUE, a re-startable image of the OpenBUGS execution is saved with \code{basename(model.file)} and extension .bug in the working -directory, which must be specified. The .bug files can be large, so +directory, which must be specified. The .bug files can be large, so users should monitor them carefully and remove them when not needed. \item[\code{restart}] If TRUE, execution resumes with the final status from the previous execution stored in the .bug file in the working directory. If \code{n.burnin=0},additional iterations are performed and all iterations since the previous burnin are used (including those from past executions). If -\code{n.burnin>0}, a new burnin is performed, and the previous iterations are +\code{n.burnin>0}, a new burnin is performed, and the previous iterations are discarded, but execution continues from the status at the end of the previous -execution. When \code{restart=TRUE}, only \code{n.burnin}, \code{n.iter}, -and \code{saveExec} inputs -should be changed from the call creating the .bug file, otherwise +execution. When \code{restart=TRUE}, only \code{n.burnin}, \code{n.iter}, +and \code{saveExec} inputs +should be changed from the call creating the .bug file, otherwise failed or erratic results may be produced. Note the default has \code{n.burnin>0}. \item[\code{debug}] if \code{FALSE} (default), \pkg{OpenBUGS} is closed automatically @@ -89,15 +89,15 @@ is returned, if \code{TRUE} file names of \pkg{OpenBUGS} output are returned for easy access by the \pkg{coda} package through function \code{\LinkA{read.bugs}{read.bugs}}. -A \code{bugs} object can be converted to an \code{mcmc.list} object as -used by the \pkg{coda} package with the method \code{\LinkA{as.mcmc.list}{as.mcmc.list}} +A \code{bugs} object can be converted to an \code{mcmc.list} object as +used by the \pkg{coda} package with the method \code{\LinkA{as.mcmc.list}{as.mcmc.list}} (for which a method is provided by R2OpenBUGS). \item[\code{OpenBUGS.pgm}] For Windows or WINE execution, the full path to the OpenBUGS executable. For linux execution, the full path to the OpenBUGS shell script (not -required if OpenBUGS is in the user's PATH variable). -If \code{NULL} (unset) and the environment variable \code{OpenBUGS\_PATH} is set the latter will be used as the default. +required if OpenBUGS is in the user's PATH variable). +If \code{NULL} (unset) and the environment variable \code{OpenBUGS\_PATH} is set the latter will be used as the default. If \code{NULL} (unset), the environment variable \code{OpenBUGS\_PATH} is unset and the global option \code{R2OpenBUGS.pgm} is not \code{NULL} the latter will be used as the default. -If nothing of the former is set and OS is Windows, the most recent OpenBUGS version +If nothing of the former is set and OS is Windows, the most recent OpenBUGS version registered in the Windows registry will be used as the default. \item[\code{working.directory}] sets working directory during execution of @@ -113,17 +113,17 @@ \pkg{OpenBUGS}. Default is \code{FALSE}. If WINE is used, the arguments \code{OpenBUGS.pgm} and \code{working.directory} must be given in form of Linux paths rather than Windows paths (if not \code{NULL}). \item[\code{WINE}] Character, path to \file{wine} binary file, it is -tried hard (by a guess and the utilities \code{which} and \code{locate}) +tried hard (by a guess and the utilities \code{which} and \code{locate}) to get the information automatically if not given. \item[\code{newWINE}] Use new versions of Wine that have \file{winepath} utility \item[\code{WINEPATH}] Character, path to \file{winepath} binary file, it is -tried hard (by a guess and the utilities \code{which} and \code{locate}) +tried hard (by a guess and the utilities \code{which} and \code{locate}) to get the information automatically if not given. -\item[\code{bugs.seed}] Random seed for \pkg{OpenBUGS}. Must be an integer between 1-14. Seed -specification changed between WinBUGS and OpenBUGS; see the OpenBUGS documentation for +\item[\code{bugs.seed}] Random seed for \pkg{OpenBUGS}. Must be an integer between 1-14. Seed +specification changed between WinBUGS and OpenBUGS; see the OpenBUGS documentation for details. -\item[\code{summary.only}] If \code{TRUE}, only a parameter summary for very quick analyses is given, +\item[\code{summary.only}] If \code{TRUE}, only a parameter summary for very quick analyses is given, temporary created files are not removed in that case. \item[\code{save.history}] If \code{TRUE} (the default), trace plots are generated at the end. \item[\code{over.relax}] If \code{TRUE}, over-relaxed form of MCMC is used if available from OpenBUGS. @@ -136,13 +136,13 @@ \item Write a \pkg{BUGS} model in an ASCII file (hint: use \code{\LinkA{write.model}{write.model}}). -\item Go into \R{} / S-PLUS. +\item Go into \R{}. \item Prepare the inputs for the \code{bugs} function and run it (see Example section). -\item An \pkg{OpenBUGS} window will pop up and \R{} / S-PLUS will freeze +\item An \pkg{OpenBUGS} window will pop up and \R{} will freeze up. The model will now run in \pkg{OpenBUGS}. It might take awhile. You will see things happening in the Log window within \pkg{OpenBUGS}. When -\pkg{OpenBUGS} is done, its window will close and \R{} / S-PLUS will work +\pkg{OpenBUGS} is done, its window will close and \R{} will work again. \item If an error message appears, re-run with \code{debug=TRUE}. @@ -174,7 +174,7 @@ Windows path style (e.g. ``c:/Program Files/OpenBUGS/'') or native (Unix) style (e.g. ``/path/to/wine/folder/dosdevices/c:/Program -Files/OpenBUGS/OpenBUGS321/OpenBUGS.exe''). +Files/OpenBUGS/OpenBUGS321/OpenBUGS.exe''). \end{Details} % @@ -278,7 +278,7 @@ parameters <- c("theta", "mu.theta", "sigma.theta") -## Not run: +## Not run: ## You may need to specify "OpenBUGS.pgm" ## also you need write access in the working directory: schools.sim <- bugs(data, inits, parameters, model.file, Modified: trunk/R2OpenBUGS/man/bugs.Rd =================================================================== --- trunk/R2OpenBUGS/man/bugs.Rd 2011-12-19 13:12:00 UTC (rev 216) +++ trunk/R2OpenBUGS/man/bugs.Rd 2011-12-21 10:13:19 UTC (rev 217) @@ -102,7 +102,7 @@ If none of the former are set and OS is Windows, the most recent OpenBUGS version registered in the Windows registry will be used as the default. - For linux OS, the default location is /usr/local/bin/OpenBUGS. + For other operating systems, the location is guessed by \code{Sys.which("OpenBUGS")}. } \item{working.directory}{sets working directory during execution of this function; \pkg{OpenBUGS}' in- and output will be stored in this Modified: trunk/R2OpenBUGS/man/validateInstallOpenBUGS.Rd =================================================================== --- trunk/R2OpenBUGS/man/validateInstallOpenBUGS.Rd 2011-12-19 13:12:00 UTC (rev 216) +++ trunk/R2OpenBUGS/man/validateInstallOpenBUGS.Rd 2011-12-21 10:13:19 UTC (rev 217) @@ -18,11 +18,8 @@ \arguments{ \item{OpenBUGS.pgm}{See \code{\link{bugs}}.} \item{OpenBUGS.examples}{A directory with the OpenBUGS examples - (text versions of model, data, and inits). If \code{NULL}, for - Windows and WINE execution, 'Examples' directory is searched in the - \code{OpenBUGS.pgm} directory. For linux execution, the - directory is /usr/local/lib/OpenBUGS/doc/Examples, which is the default - location for the OpenBUGS linux installer.} + (text versions of model, data, and inits). If \code{NULL}, we try to derive the location + of the 'Examples' directory from the \code{OpenBUGS.pgm} directory.} \item{useWINE}{logical; attempt to use the Wine emulator to run \pkg{OpenBUGS}. Default is \code{FALSE}. If WINE is used, the arguments \code{OpenBUGS.pgm} and \code{working.directory} must be given in form of Linux paths rather than Windows paths (if not \code{NULL}).} Modified: trunk/R2OpenBUGS/man/write.model.Rd =================================================================== --- trunk/R2OpenBUGS/man/write.model.Rd 2011-12-19 13:12:00 UTC (rev 216) +++ trunk/R2OpenBUGS/man/write.model.Rd 2011-12-21 10:13:19 UTC (rev 217) @@ -44,10 +44,8 @@ sigma.theta ~ dunif (0, 1000) } -if (is.R()){ # for R ## some temporary filename: filename <- file.path(tempdir(), "schoolsmodel.bug") -} ## write model file: write.model(schoolsmodel, filename) Modified: trunk/R2OpenBUGS/tests/R2OpenBUGS.Rout.save =================================================================== --- trunk/R2OpenBUGS/tests/R2OpenBUGS.Rout.save 2011-12-19 13:12:00 UTC (rev 216) +++ trunk/R2OpenBUGS/tests/R2OpenBUGS.Rout.save 2011-12-21 10:13:19 UTC (rev 217) @@ -1,5 +1,5 @@ -R Under development (unstable) (2011-08-25 r56795) +R version 2.14.0 (2011-10-31) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i386-pc-mingw32/i386 (32-bit) @@ -19,6 +19,14 @@ > library("R2OpenBUGS") Loading required package: coda Loading required package: lattice +Loading required package: boot + +Attaching package: 'boot' + +The following object(s) are masked from 'package:lattice': + + melanoma + > validateInstallOpenBUGS() The version of OpenBUGS on your computer is being compared to validation results created using OpenBUGS version 3.2.1 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <snt...@us...> - 2011-12-19 13:12:12
|
Revision: 216 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=216&view=rev Author: snthomas99 Date: 2011-12-19 13:12:00 +0000 (Mon, 19 Dec 2011) Log Message: ----------- updated documentation and default pgm location code for cran release of 3.2.1-2 Modified Paths: -------------- trunk/R2OpenBUGS/DESCRIPTION trunk/R2OpenBUGS/R/bugs.R trunk/R2OpenBUGS/R/findOpenBUGS.R trunk/R2OpenBUGS/R/validateInstallOpenBUGS.R trunk/R2OpenBUGS/inst/NEWS trunk/R2OpenBUGS/man/R2WinBUGS-package.Rd trunk/R2OpenBUGS/man/as.bugs.array.Rd trunk/R2OpenBUGS/man/bugs.Rd trunk/R2OpenBUGS/man/bugs.sims.Rd trunk/R2OpenBUGS/man/validateInstallOpenBUGS.Rd trunk/R2OpenBUGS/man/write.model.Rd Modified: trunk/R2OpenBUGS/DESCRIPTION =================================================================== --- trunk/R2OpenBUGS/DESCRIPTION 2011-09-21 01:08:35 UTC (rev 215) +++ trunk/R2OpenBUGS/DESCRIPTION 2011-12-19 13:12:00 UTC (rev 216) @@ -1,19 +1,19 @@ Package: R2OpenBUGS -Title: Running OpenBUGS from R / S-PLUS -Date: 2011-08-25 +Title: Running OpenBUGS from R +Date: 2011-12-15 Version: 3.2-1.2 Author: originally written as R2WinBUGS 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. Adapted to R2OpenBUGS from R2WinBUGS by Neal Thomas. + Adapted to R2OpenBUGS from R2WinBUGS by Neal Thomas. 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 R. Depends: R (>= 2.11.0), coda (>= 0.11-0) SystemRequirements: OpenBUGS (>= 3.2.1) -Maintainer: Neal Thomas <nea...@pf...> +Maintainer: Neal Thomas <nea...@ya...> License: GPL-2 -Dialect: R, S-PLUS +Dialect: R Modified: trunk/R2OpenBUGS/R/bugs.R =================================================================== --- trunk/R2OpenBUGS/R/bugs.R 2011-09-21 01:08:35 UTC (rev 215) +++ trunk/R2OpenBUGS/R/bugs.R 2011-12-19 13:12:00 UTC (rev 216) @@ -3,30 +3,36 @@ n.chains=3, n.burnin=floor(n.iter / 2), n.thin=1, saveExec=FALSE,restart=FALSE, debug=FALSE, DIC=TRUE, digits=5, codaPkg=FALSE, - OpenBUGS.pgm=NULL, working.directory=NULL, + OpenBUGS.pgm=NULL, + working.directory=NULL, clearWD=FALSE, useWINE=FALSE, WINE=NULL, newWINE=TRUE, WINEPATH=NULL, bugs.seed=1, summary.only=FALSE, save.history=(.Platform$OS.type == "windows" | useWINE==TRUE), over.relax = FALSE) { - ### check options for unix/linux - if(.Platform$OS.type != "windows" & useWINE==FALSE){ - if(debug)stop("The debug option is not available with linux/unix") - if(save.history)("History plots (save.history) is not available with linux/unix") - } - if(is.null(OpenBUGS.pgm)) - OpenBUGS.pgm <- file.path(findOpenBUGS(), "OpenBUGS.exe") - if((.Platform$OS.type == "windows" | useWINE) & !file.exists(OpenBUGS.pgm)) - stop("OpenBUGS executable was not found" ) +if(is.null(OpenBUGS.pgm)){ + OpenBUGS.pgm <- findOpenBUGS() + if(.Platform$OS.type == "windows" | useWINE==TRUE) + OpenBUGS.pgm <- file.path(OpenBUGS.pgm, "OpenBUGS.exe") + } +if(!file.exists(OpenBUGS.pgm) && OpenBUGS.pgm!='OpenBUGS') + stop("Cannot find the OpenBUGS program") + ## Is OpenBUGS.pgm defined in Windows (where second character is : ## i.e. C:\Program...) or Unix style path? if(useWINE && (substr(OpenBUGS.pgm, 2, 2) == ":")) { OpenBUGS.pgm <- win2native(OpenBUGS.pgm, newWINE=newWINE, WINEPATH=WINEPATH) } + ### check options for unix/linux + if(.Platform$OS.type != "windows" && useWINE==FALSE){ + if(debug)stop("The debug option is not available with linux/unix") + if(save.history)("History plots (save.history) are not available with linux/unix") + } + if(! bugs.seed %in% 1:14) stop("OpenBUGS seed must be integer in 1:14") Modified: trunk/R2OpenBUGS/R/findOpenBUGS.R =================================================================== --- trunk/R2OpenBUGS/R/findOpenBUGS.R 2011-09-21 01:08:35 UTC (rev 215) +++ trunk/R2OpenBUGS/R/findOpenBUGS.R 2011-12-19 13:12:00 UTC (rev 216) @@ -8,7 +8,7 @@ return(dir) if(.Platform$OS.type != "windows") - return(NA) + return('/usr/local/bin/OpenBUGS') deps <- utils:::packageDescription("R2OpenBUGS", fields="SystemRequirements") version.req <- gsub(".*OpenBUGS ?\\(>= ?(.+)\\).*", "\\1", deps) Modified: trunk/R2OpenBUGS/R/validateInstallOpenBUGS.R =================================================================== --- trunk/R2OpenBUGS/R/validateInstallOpenBUGS.R 2011-09-21 01:08:35 UTC (rev 215) +++ trunk/R2OpenBUGS/R/validateInstallOpenBUGS.R 2011-12-19 13:12:00 UTC (rev 216) @@ -7,13 +7,22 @@ { ## Selected examples which take a few seconds in total to run +if(is.null(OpenBUGS.pgm)){ + OpenBUGS.pgm <- findOpenBUGS() + if(.Platform$OS.type == "windows" | useWINE==TRUE) + OpenBUGS.pgm <- file.path(OpenBUGS.pgm, "OpenBUGS.exe") + } -if(is.null(OpenBUGS.pgm)) - OpenBUGS.pgm <- file.path(findOpenBUGS(), "OpenBUGS.exe") +if(!file.exists(OpenBUGS.pgm) && OpenBUGS.pgm!='OpenBUGS') + stop("Cannot find the OpenBUGS program") -if(is.null(OpenBUGS.examples)) - OpenBUGS.examples <- file.path(dirname(OpenBUGS.pgm), 'Examples') +if(is.null(OpenBUGS.examples)){ + if(.Platform$OS.type == "windows" | useWINE==TRUE){ + OpenBUGS.examples <- file.path(dirname(OpenBUGS.pgm), 'Examples') + }else OpenBUGS.examples <-'/usr/local/lib/OpenBUGS/doc/Examples' +} + if(!file.exists(OpenBUGS.examples)) stop("Cannot find Examples in ", OpenBUGS.examples) Modified: trunk/R2OpenBUGS/inst/NEWS =================================================================== --- trunk/R2OpenBUGS/inst/NEWS 2011-09-21 01:08:35 UTC (rev 215) +++ trunk/R2OpenBUGS/inst/NEWS 2011-12-19 13:12:00 UTC (rev 216) @@ -2,7 +2,7 @@ ====================== Update 3.2-1.2 --Changed handling of default OpenBUGS program location and other changes +- Changed handling of default OpenBUGS program location and other changes required for cran compliance - Fixed bug in validInstallOpenBUGS with user-supplied program location Modified: trunk/R2OpenBUGS/man/R2WinBUGS-package.Rd =================================================================== --- trunk/R2OpenBUGS/man/R2WinBUGS-package.Rd 2011-09-21 01:08:35 UTC (rev 215) +++ trunk/R2OpenBUGS/man/R2WinBUGS-package.Rd 2011-12-19 13:12:00 UTC (rev 216) @@ -4,13 +4,13 @@ \docType{package} -\title{Running OpenBUGS from R / S-PLUS} +\title{Running OpenBUGS from R} \description{ \pkg{R2OpenBUGS} Call a \pkg{BUGS} model, summarize inferences and convergence in a table and graph, and save the -simulations in arrays for easy access in \R / S-PLUS. The main command is \code{\link{bugs}}. +simulations in arrays for easy access in \R. The main command is \code{\link{bugs}}. } Modified: trunk/R2OpenBUGS/man/as.bugs.array.Rd =================================================================== --- trunk/R2OpenBUGS/man/as.bugs.array.Rd 2011-09-21 01:08:35 UTC (rev 215) +++ trunk/R2OpenBUGS/man/as.bugs.array.Rd 2011-12-19 13:12:00 UTC (rev 216) @@ -50,7 +50,8 @@ \value{A \code{\link{bugs}} object is returned} \author{Jouni Kerman, \email{ke...@st...} with modification - by Andrew Gelman, \email{ge...@st...}, packaged by Uwe + by Andrew Gelman, \cr + \email{ge...@st...}, packaged by Uwe Ligges, \email{li...@st...}.} \seealso{\code{\link{bugs}}} Modified: trunk/R2OpenBUGS/man/bugs.Rd =================================================================== --- trunk/R2OpenBUGS/man/bugs.Rd 2011-09-21 01:08:35 UTC (rev 215) +++ trunk/R2OpenBUGS/man/bugs.Rd 2011-12-19 13:12:00 UTC (rev 216) @@ -1,17 +1,18 @@ \name{bugs} \alias{bugs} -\title{Run OpenBUGS from R or S-PLUS} +\title{Run OpenBUGS from R} \description{The \code{bugs} function takes data and starting values as input. It automatically writes a \pkg{OpenBUGS} script, calls the model, and - saves the simulations for easy access in \R or S-PLUS.} + saves the simulations for easy access in \R.} \usage{ bugs(data, inits, parameters.to.save, n.iter, model.file="model.txt", n.chains=3, n.burnin=floor(n.iter / 2), n.thin=1, saveExec=FALSE,restart=FALSE, debug=FALSE, DIC=TRUE, digits=5, codaPkg=FALSE, - OpenBUGS.pgm=NULL, working.directory=NULL, + OpenBUGS.pgm=NULL, + working.directory=NULL, clearWD=FALSE, useWINE=FALSE, WINE=NULL, newWINE=TRUE, WINEPATH=NULL, bugs.seed=1, summary.only=FALSE, save.history=(.Platform$OS.type == "windows" | useWINE==TRUE), @@ -55,7 +56,7 @@ performs, but does not change \code{n.iter} or \code{n.burnin}. Thinning implemented in this manner is not captured in summaries created by packages such as \pkg{coda}.} \item{saveExec}{If TRUE, a re-startable image of the OpenBUGS execution is - saved with \code{basename(model.file)} and extension .bug in the working + saved with \code{basename (model.file)} and extension .bug in the working directory, which must be specified. The .bug files can be large, so users should monitor them carefully and remove them when not needed. } @@ -86,13 +87,22 @@ A \code{bugs} object can be converted to an \code{mcmc.list} object as used by the \pkg{coda} package with the method \code{\link[coda]{as.mcmc.list}} (for which a method is provided by R2OpenBUGS).} - \item{OpenBUGS.pgm}{ For Windows or WINE execution, the full path to the OpenBUGS - executable. For linux execution, the full path to the OpenBUGS shell script (not - required if OpenBUGS is in the user's PATH variable). - If \code{NULL} (unset) and the environment variable \code{OpenBUGS_PATH} is set the latter will be used as the default. - If \code{NULL} (unset), the environment variable \code{OpenBUGS_PATH} is unset and the global option \code{R2OpenBUGS.pgm} is not \code{NULL} the latter will be used as the default. - If nothing of the former is set and OS is Windows, the most recent OpenBUGS version - registered in the Windows registry will be used as the default. + \item{OpenBUGS.pgm}{ For Windows or WINE execution, the full path + to the OpenBUGS + executable. For linux execution, the full path to the + OpenBUGS executable or shell script (the path to the shell + script is not + required if the OpenBUGS shell script is in the user's PATH variable). + If \code{NULL} (unset) and the environment variable + \code{OpenBUGS_PATH} is set the latter will be used as the default. + If \code{NULL} (unset), the environment variable + \code{OpenBUGS_PATH} is unset and the global option + \code{R2OpenBUGS.pgm} is not \code{NULL} the latter will be + used as the default. + If none of the former are set and OS is Windows, the + most recent OpenBUGS version + registered in the Windows registry will be used as the default. + For linux OS, the default location is /usr/local/bin/OpenBUGS. } \item{working.directory}{sets working directory during execution of this function; \pkg{OpenBUGS}' in- and output will be stored in this @@ -128,13 +138,13 @@ \enumerate{ \item Write a \pkg{BUGS} model in an ASCII file (hint: use \code{\link{write.model}}). - \item Go into \R / S-PLUS. + \item Go into \R. \item Prepare the inputs for the \code{bugs} function and run it (see Example section). - \item An \pkg{OpenBUGS} window will pop up and \R / S-PLUS will freeze + \item An \pkg{OpenBUGS} window will pop up and \R will freeze up. The model will now run in \pkg{OpenBUGS}. It might take awhile. You will see things happening in the Log window within \pkg{OpenBUGS}. When - \pkg{OpenBUGS} is done, its window will close and \R / S-PLUS will work + \pkg{OpenBUGS} is done, its window will close and \R will work again. \item If an error message appears, re-run with \code{debug=TRUE}. } @@ -156,7 +166,7 @@ \code{working.directory} and \code{model.file}, must be given in native (Unix) style, but \code{OpenBUGS.pgm} can be given in Windows path style (e.g. \dQuote{c:/Program Files/OpenBUGS/}) or - native (Unix) style + native (Unix) style \cr (e.g. \dQuote{/path/to/wine/folder/dosdevices/c:/Program Files/OpenBUGS/OpenBUGS321/OpenBUGS.exe}). Modified: trunk/R2OpenBUGS/man/bugs.sims.Rd =================================================================== --- trunk/R2OpenBUGS/man/bugs.sims.Rd 2011-09-21 01:08:35 UTC (rev 215) +++ trunk/R2OpenBUGS/man/bugs.sims.Rd 2011-12-19 13:12:00 UTC (rev 216) @@ -2,7 +2,7 @@ \alias{bugs.sims} \title{OpenBUGS output reader} -\description{Reads simulations from \pkg{OpenBUGS} into \R or S-PLUS, +\description{Reads simulations from \pkg{OpenBUGS} into \R, formats them, monitors convergence, performs convergence checks, and computes medians and quantiles - intended for internal use.} Modified: trunk/R2OpenBUGS/man/validateInstallOpenBUGS.Rd =================================================================== --- trunk/R2OpenBUGS/man/validateInstallOpenBUGS.Rd 2011-09-21 01:08:35 UTC (rev 215) +++ trunk/R2OpenBUGS/man/validateInstallOpenBUGS.Rd 2011-12-19 13:12:00 UTC (rev 216) @@ -17,8 +17,12 @@ \arguments{ \item{OpenBUGS.pgm}{See \code{\link{bugs}}.} - \item{OpenBUGS.examples}{A directory with the OpenBUGS examples (text versions of - model, data, and inits). If \code{NULL} we try to derive from \code{OpenBUGS.pgm}.} + \item{OpenBUGS.examples}{A directory with the OpenBUGS examples + (text versions of model, data, and inits). If \code{NULL}, for + Windows and WINE execution, 'Examples' directory is searched in the + \code{OpenBUGS.pgm} directory. For linux execution, the + directory is /usr/local/lib/OpenBUGS/doc/Examples, which is the default + location for the OpenBUGS linux installer.} \item{useWINE}{logical; attempt to use the Wine emulator to run \pkg{OpenBUGS}. Default is \code{FALSE}. If WINE is used, the arguments \code{OpenBUGS.pgm} and \code{working.directory} must be given in form of Linux paths rather than Windows paths (if not \code{NULL}).} @@ -44,7 +48,7 @@ \code{working.directory} and \code{model.file}, must be given in native (Unix) style, but \code{OpenBUGS.pgm} can be given in Windows path style (e.g. \dQuote{c:/Program Files/OpenBUGS/}) or - native (Unix) style + native (Unix) style \cr (e.g. \dQuote{/path/to/wine/folder/dosdevices/c:/Program Files/OpenBUGS/OpenBUGS321/OpenBUGS.exe}). Modified: trunk/R2OpenBUGS/man/write.model.Rd =================================================================== --- trunk/R2OpenBUGS/man/write.model.Rd 2011-09-21 01:08:35 UTC (rev 215) +++ trunk/R2OpenBUGS/man/write.model.Rd 2011-12-19 13:12:00 UTC (rev 216) @@ -1,13 +1,13 @@ \name{write.model} \alias{write.model} \title{Creating a OpenBUGS model file} -\description{Convert \R / S-PLUS function to a \pkg{OpenBUGS} model file} +\description{Convert \R function to a \pkg{OpenBUGS} model file} \usage{ write.model(model, con = "model.bug", digits = 5) } \arguments{ - \item{model}{\R / S-PLUS function containing the BUGS model in the BUGS + \item{model}{\R function containing the BUGS model in the BUGS model language, for minor differences see Section Details.} \item{con}{passed to \code{\link{writeLines}} which actually writes the model file} @@ -23,16 +23,11 @@ most BUGS models as \R functions. As a difference, BUGS syntax allows truncation specification like this: -\code{dnorm(...) I(...)} but this is illegal in \R and S-PLUS. To +\code{dnorm(...) I(...)} but this is illegal in \R. To overcome this incompatibility, use dummy operator \code{\%_\%} before \code{I(...)}: \code{dnorm(...) \%_\% I(...)}. The dummy operator \code{\%_\%} will be removed before the BUGS code is saved. -In S-PLUS, a warning is generated when the model function is defined if -the last statement in the model is an assignment. To avoid this -warning, add the line "invisible()" to the end of the model definition. -This line will be removed before the BUGS code is saved. - } \author{original idea by Jouni Kerman, modified by Uwe Ligges} @@ -52,9 +47,6 @@ if (is.R()){ # for R ## some temporary filename: filename <- file.path(tempdir(), "schoolsmodel.bug") -} else{ # for S-PLUS - ## put the file in the working directory: - filename <- "schoolsmodel.bug" } ## write model file: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <snt...@us...> - 2011-09-21 01:08:44
|
Revision: 215 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=215&view=rev Author: snthomas99 Date: 2011-09-21 01:08:35 +0000 (Wed, 21 Sep 2011) Log Message: ----------- Fixed bug in validateInstallOpenBUGS and changed version number Modified Paths: -------------- trunk/R2OpenBUGS/DESCRIPTION trunk/R2OpenBUGS/R/validateInstallOpenBUGS.R trunk/R2OpenBUGS/inst/NEWS trunk/R2OpenBUGS/inst/doc/R2OpenBUGS.pdf Modified: trunk/R2OpenBUGS/DESCRIPTION =================================================================== --- trunk/R2OpenBUGS/DESCRIPTION 2011-09-01 09:43:58 UTC (rev 214) +++ trunk/R2OpenBUGS/DESCRIPTION 2011-09-21 01:08:35 UTC (rev 215) @@ -1,7 +1,7 @@ Package: R2OpenBUGS Title: Running OpenBUGS from R / S-PLUS Date: 2011-08-25 -Version: 3.2-2 +Version: 3.2-1.2 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/R/validateInstallOpenBUGS.R =================================================================== --- trunk/R2OpenBUGS/R/validateInstallOpenBUGS.R 2011-09-01 09:43:58 UTC (rev 214) +++ trunk/R2OpenBUGS/R/validateInstallOpenBUGS.R 2011-09-21 01:08:35 UTC (rev 215) @@ -57,7 +57,9 @@ ok <- file.copy(exfiles, tempdir()) fit <- round(bugs(data=test.datafile[i], inits=test.inits[i], para=test.params[[test.models[i]]],model.file=test.modelfile[i], - n.burnin=5000, n.iter=20000, n.thin=1, n.chains=1, DIC=FALSE, working.directory=tempdir())$summary, 5) + n.burnin=5000, n.iter=20000, n.thin=1, n.chains=1, DIC=FALSE, + working.directory=tempdir(), + OpenBUGS.pgm=OpenBUGS.pgm)$summary, 5) if(isTRUE(all.equal(fit, res.true[[i]], tol=1e-2))){ message(paste('Results matched for example', test.models[[i]], '\n', sep=' ')) } else{ Modified: trunk/R2OpenBUGS/inst/NEWS =================================================================== --- trunk/R2OpenBUGS/inst/NEWS 2011-09-01 09:43:58 UTC (rev 214) +++ trunk/R2OpenBUGS/inst/NEWS 2011-09-21 01:08:35 UTC (rev 215) @@ -1,6 +1,11 @@ Changes to R2OpenBUGS: ====================== +Update 3.2-1.2 +-Changed handling of default OpenBUGS program location and other changes + required for cran compliance +- Fixed bug in validInstallOpenBUGS with user-supplied program location + Update 3.2-1 - Added saveExec and restart options to the bugs function that uses the OpenBUGS internalize/externalize feature to allow a user to Modified: trunk/R2OpenBUGS/inst/doc/R2OpenBUGS.pdf =================================================================== --- trunk/R2OpenBUGS/inst/doc/R2OpenBUGS.pdf 2011-09-01 09:43:58 UTC (rev 214) +++ trunk/R2OpenBUGS/inst/doc/R2OpenBUGS.pdf 2011-09-21 01:08:35 UTC (rev 215) @@ -235,7 +235,7 @@ /Type /XObject /Subtype /Form /FormType 1 -/PTEX.FileName (d:/temp/Rtmp0UCpFr/Rbuild5d10b9c/R2OpenBUGS/inst/doc/countssw.pdf) +/PTEX.FileName (C:/Documents\040and\040Settings/ThomasN/My\040Documents/BUGS/bugsdevel/bugs-r/R2OpenBUGS/inst/doc/countssw.pdf) /PTEX.PageNumber 1 /PTEX.InfoDict 58 0 R /BBox [0 0 432 216] @@ -1557,7 +1557,7 @@ /Type /XObject /Subtype /Form /FormType 1 -/PTEX.FileName (d:/temp/Rtmp0UCpFr/Rbuild5d10b9c/R2OpenBUGS/inst/doc/expectedsw.pdf) +/PTEX.FileName (C:/Documents\040and\040Settings/ThomasN/My\040Documents/BUGS/bugsdevel/bugs-r/R2OpenBUGS/inst/doc/expectedsw.pdf) /PTEX.PageNumber 1 /PTEX.InfoDict 66 0 R /BBox [0 0 432 216] @@ -2845,7 +2845,7 @@ /Type /XObject /Subtype /Form /FormType 1 -/PTEX.FileName (d:/temp/Rtmp0UCpFr/Rbuild5d10b9c/R2OpenBUGS/inst/doc/benzolsw.pdf) +/PTEX.FileName (C:/Documents\040and\040Settings/ThomasN/My\040Documents/BUGS/bugsdevel/bugs-r/R2OpenBUGS/inst/doc/benzolsw.pdf) /PTEX.PageNumber 1 /PTEX.InfoDict 85 0 R /BBox [0 0 432 216] @@ -3987,7 +3987,7 @@ /Type /XObject /Subtype /Form /FormType 1 -/PTEX.FileName (d:/temp/Rtmp0UCpFr/Rbuild5d10b9c/R2OpenBUGS/inst/doc/plot.pdf) +/PTEX.FileName (C:/Documents\040and\040Settings/ThomasN/My\040Documents/BUGS/bugsdevel/bugs-r/R2OpenBUGS/inst/doc/plot.pdf) /PTEX.PageNumber 1 /PTEX.InfoDict 132 0 R /BBox [0 0 470 469] @@ -5229,112 +5229,170 @@ 31 0 obj [2 0 R /Fit] endobj +184 0 obj << +/Length 99 +/Filter /FlateDecode +>> +stream +x\xDA3\xB6\xD432V0P04U02!s\x85C\xAEB.\xA0\xA0\x81P"\x93\x9C\xCB\xE5\xE4ɥ\xAE`\xC1\xA5\xEF\xE6\xD2\xF7\xF4U()*M\xE5\xD2w +pV0\xE4\xD2wQ\x886T0\x88\xE5\xF2tQ\x90\xA8\xAB\xFB\xFF\xBF +\xD8Hp\xB9zrr |
From: <chr...@us...> - 2011-09-01 09:44:07
|
Revision: 214 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=214&view=rev Author: chris-jackson Date: 2011-09-01 09:43:58 +0000 (Thu, 01 Sep 2011) Log Message: ----------- Quote the path to the helper program. Modified Paths: -------------- trunk/BRugs/R/internal.R trunk/BRugs/R/windows/zzz.x64.R.in Modified: trunk/BRugs/R/internal.R =================================================================== --- trunk/BRugs/R/internal.R 2011-09-01 08:37:10 UTC (rev 213) +++ trunk/BRugs/R/internal.R 2011-09-01 09:43:58 UTC (rev 214) @@ -52,7 +52,7 @@ cmdFile <- paste(tempDir, "cmds.txt", sep="/") pkgPath <- searchpaths()[search()=="package:BRugs"] bugsPath <- paste(pkgPath, "/exec/BugsHelper", sep="") - shcmd <- paste(bugsPath, dquote(tempDir), dquote(trashDir), dquote(extFile), dquote(cmdFile), dquote(ncmds)) + shcmd <- paste(dquote(bugsPath), dquote(tempDir), dquote(trashDir), dquote(extFile), dquote(cmdFile), dquote(ncmds)) for (i in 1:ncmds) { if (cmdtypes[i] %in% c("CharArray","RealArray")) cat(args[[i]], file=paste(tempDir, "/input",i,".txt", sep="")) @@ -92,15 +92,15 @@ .SamplesGlobalsCmd <- function(node){ options.old <- options() - options(scipen=20) # don't pass numbers in scientific notation to OpenBUGS + options(scipen=20) # don't pass numbers in scientific notation to OpenBUGS commands <- c(paste("SamplesEmbed.beg :=", getOption("BRugsSamplesBeg")), paste("SamplesEmbed.end :=", getOption("BRugsSamplesEnd")), paste("SamplesEmbed.firstChain :=", getOption("BRugsSamplesFirstChain")), paste("SamplesEmbed.lastChain :=", getOption("BRugsSamplesLastChain")), paste("SamplesEmbed.thin :=", getOption("BRugsSamplesThin")), paste("SamplesEmbed.SetVariable(", sQuote(node), ")", sep=""), - paste("BugsMappers.SetPrec(", getOption("BRugsPrec"), ")", sep="") + paste("BugsMappers.SetPrec(", getOption("BRugsPrec"), ")", sep="") ) options(options.old) - paste(commands, collapse="; ") + paste(commands, collapse="; ") } Modified: trunk/BRugs/R/windows/zzz.x64.R.in =================================================================== --- trunk/BRugs/R/windows/zzz.x64.R.in 2011-09-01 08:37:10 UTC (rev 213) +++ trunk/BRugs/R/windows/zzz.x64.R.in 2011-09-01 09:43:58 UTC (rev 214) @@ -14,8 +14,8 @@ ob <- findOpenBUGS() msg <- paste("Welcome to BRugs connected to OpenBUGS") if (!is.na(ob$version)) - msg <- paste(msg, " version ", ob$version) - else msg <- paste(msg, " in directory ", ob$dir) + msg <- paste(msg, "version", ob$version) + else msg <- paste(msg, "in directory", ob$dir) packageStartupMessage(msg) } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2011-09-01 08:37:21
|
Revision: 213 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=213&view=rev Author: chris-jackson Date: 2011-09-01 08:37:10 +0000 (Thu, 01 Sep 2011) Log Message: ----------- Use "view" argument to readRegistry Modified Paths: -------------- trunk/BRugs/R/windows/findOpenBUGS.R Modified: trunk/BRugs/R/windows/findOpenBUGS.R =================================================================== --- trunk/BRugs/R/windows/findOpenBUGS.R 2011-08-31 09:30:10 UTC (rev 212) +++ trunk/BRugs/R/windows/findOpenBUGS.R 2011-09-01 08:37:10 UTC (rev 213) @@ -5,9 +5,7 @@ deps <- utils:::packageDescription("BRugs", fields="SystemRequirements") version.req <- gsub(".*OpenBUGS ?\\(>= ?(.+)\\).*", "\\1", deps) - key <- if (.Platform$r_arch == "x64") "Software\\Wow6432Node\\OpenBUGS" else "Software\\OpenBUGS" - ob.reg <- try(utils:::readRegistry(key, "HLM"), silent = TRUE) - ## 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")) { 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() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Uwe L. <li...@st...> - 2011-08-31 12:37:32
|
And finally, I think samplesSample is broken, at least it does not do anything for me now. Uwe On 31.08.2011 14:25, Uwe Ligges wrote: > Chris, as a side note: > > I'd prefer not to copy the dlls into libs. In any case, it won't work > the way you did it. Please R CMD build before R CMD INSTALL the tar file. > > I can take a look how to clean this up diring the weekend. I prefer to > do things in Makevars.win rather than configure.win which makes it much > harder to produce bi-arch binaries for BRugs. > > Uwe > > > > > > > On 31.08.2011 14:01, Uwe Ligges wrote: >> Chris, >> >> >> thanks for your modifications and the 64-bit code. Great! I will test >> during the weekend (I am about to travel in an hour or so). >> >> >> >> On 31.08.2011 11:28, chr...@us... wrote: >>> Revision: 211 >>> http://bugs-r.svn.sourceforge.net/bugs-r/?rev=211&view=rev >>> Author: chris-jackson >>> Date: 2011-08-31 09:28:44 +0000 (Wed, 31 Aug 2011) >>> Log Message: >>> ----------- >>> Changes to allow running on x64 R in Windows. The same helper facility as on Linux is used to call the 32-bit DLL. >>> >>> + stop(errors[res], "\nPlease report this bug to ", maintainer) >> >> >> >> May I object against this line of code? >> If there are BUGS traps, I am certainly not the person who likes to get >> the bug report, since I cannot help in that case anyway. >> >> >> >>> Added: trunk/BRugs/R/windows/findOpenBUGS.R >>> =================================================================== >>> --- trunk/BRugs/R/windows/findOpenBUGS.R (rev 0) >>> +++ trunk/BRugs/R/windows/findOpenBUGS.R 2011-08-31 09:28:44 UTC (rev 211) >>> @@ -0,0 +1,43 @@ >>> +findOpenBUGS<- function() >>> +{ >>> + dir<- Sys.getenv("OpenBUGS_PATH") >>> + if(!nchar(dir)){ >>> + deps<- utils:::packageDescription("BRugs", fields="SystemRequirements") >>> + version.req<- gsub(".*OpenBUGS ?\\(>= ?(.+)\\).*", "\\1", deps) >>> + >>> + key<- if (.Platform$r_arch == "x64") "Software\\Wow6432Node\\OpenBUGS" else "Software\\OpenBUGS" >> >> >> The above is implemented by the view argument in readRegistry. Why not >> use it? It will be safe in case Microsoft changes the names of registry >> keys again in the next version of Windows. You have not changed it below. >> >> >> >>> + ob.reg<- try(utils:::readRegistry(key, "HLM"), silent = TRUE) >>> + ## ob.reg<- try(utils:::readRegistry("Software\\OpenBUGS", "HLM", view = "32-bit"), silent = TRUE) >> >> >> >>> + ## remove suffixes from development versions, converts e.g. 3.2.1alpha to 3.2.1 >> >> >> Question is if we actually want to remove that in case we really require >> a release rather than the alpha version. >> >> >> >>> + version.inst<- gsub("(.+[0-9]+)[a-zA-Z]+$","\\1", version.full) >>> + >>> + if(length(version.inst> 1)){ >>> + id<- which(apply(outer(version.inst, version.inst, Vectorize(compareVersion, c("a", "b"))), 1, function(x) all(x>= 0))) >>> + id<- max(id) # if more than one release with same number, arbitrarily choose last one in registry >>> + version.inst<- version.inst[id] >>> + version.full<- version.full[id] >>> + rnames<- rnames[id] >>> + } >>> + >>> + if (compareVersion(version.inst, version.req)< 0) { >>> + warning("Found OpenBUGS version ", version.inst, ".\n Requires ", version.req, " or greater.\nSetting the environment variable 'OpenBUGS_PATH' in advance of loading 'BRugs' overwrites the path.\nSee ?loadOpenBUGS in order to load OpenBUGS manually.") >>> + return() >>> + } >>> + >>> + ## OpenBUGS installation location >>> + dir<- utils:::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")) >>> + return() >>> + } >>> + version.inst<- NA >>> + } >>> + list(dir=dir, version=version.full) >>> +} >>> >> >> >> >> >>> Added: trunk/BRugs/R/windows/zzz.i386.R >>> =================================================================== >>> --- trunk/BRugs/R/windows/zzz.i386.R (rev 0) >>> +++ trunk/BRugs/R/windows/zzz.i386.R 2011-08-31 09:28:44 UTC (rev 211) >>> @@ -0,0 +1,40 @@ >>> +".onLoad.i386"<- function(lib, pkg){ >>> + ob<- findOpenBUGS() >>> + loadOpenBUGS(ob$dir) >>> + msg<- paste("Welcome to BRugs connected to OpenBUGS") >>> + if (!is.na(ob$version)) >>> + msg<- paste(msg, "version", ob$version) >>> + else msg<- paste(msg, "in directory", ob$dir) >>> + packageStartupMessage(msg) >>> +} >>> + >>> +".onUnload.i386"<- function(libpath){ >>> + if(is.loaded("CmdInterpreter")) { >>> + libname<- paste(options()$OpenBUGS, "libOpenBUGS.dll", sep="/") >>> + dyn.unload(libname) >>> + } >>> +} >>> + >>> +## Load OpenBUGS from specified location >>> +loadOpenBUGS<- function(dir) { >>> + libname<- paste(dir, "libOpenBUGS.dll", sep="/") >>> + if (!file.exists(libname)) { >>> + warning("Shared library \"libOpenBUGS.dll\" not found in ", dir) >>> + return(FALSE) >>> + } >>> + options(OpenBUGS = dir) >>> + dyn.load(libname) >>> + len<- nchar(dir) >>> + .C("SetWorkingDir", as.character(dir), len) >>> + ## Set temporary dir for "buffer.txt" output >>> + tempDir<- gsub("\\\\", "/", tempdir()) >>> + .C("SetTempDir", as.character(tempDir), nchar(tempDir)) >>> + command<- "BugsMappers.SetDest(2)" >>> + .CmdInterpreter(command) >>> + if(is.null(getOption("BRugsVerbose"))) >>> + options("BRugsVerbose" = TRUE) >>> + .initGlobals() >>> + options(OpenBUGSExamples = paste(dir, "Examples", sep="/")) >>> + invisible() >>> +} >>> + >>> >>> Added: trunk/BRugs/R/windows/zzz.x64.R >>> =================================================================== >>> --- trunk/BRugs/R/windows/zzz.x64.R (rev 0) >>> +++ trunk/BRugs/R/windows/zzz.x64.R 2011-08-31 09:28:44 UTC (rev 211) >>> @@ -0,0 +1,25 @@ >>> +if (is.R()){ >>> + >>> + ".onLoad.x64"<- function(lib, pkg){ >>> + ## TODO any need for these to be user specifiable? >>> + options("BRugsTmpdir" = gsub("\\\\", "/", tempdir())) >>> + options("BRugsExtFile" = paste(basename(tempfile()), ".bug", sep="")) >>> + options(OpenBUGS = "C:/Program Files (x86)/OpenBUGS/OpenBUGS321") >>> + options(OpenBUGSdoc = "C:/Program Files (x86)/OpenBUGS/OpenBUGS321") >>> + options(OpenBUGSExamples = paste(options()$OpenBUGSdoc, "Examples", sep="/")) >> >> >> >> Why not do it the same way as for 32-bit? The stuff is in the 32-bit >> view in the registry, hence findOpenBUGS results could be used here. >> >> The .in file is not helpful given we provide binaries for the package on >> CRAN and *my* installation will be inserted. >> >> >> >> Best wishes, >> uwe >> >> ------------------------------------------------------------------------------ >> Special Offer -- Download ArcSight Logger for FREE! >> Finally, a world-class log management solution at an even better >> price-free! And you'll get a free "Love Thy Logs" t-shirt when you >> download Logger. Secure your free ArcSight Logger TODAY! >> http://p.sf.net/sfu/arcsisghtdev2dev >> _______________________________________________ >> Bugs-r-devel mailing list >> Bug...@li... >> https://lists.sourceforge.net/lists/listinfo/bugs-r-devel > > ------------------------------------------------------------------------------ > Special Offer -- Download ArcSight Logger for FREE! > Finally, a world-class log management solution at an even better > price-free! And you'll get a free "Love Thy Logs" t-shirt when you > download Logger. Secure your free ArcSight Logger TODAY! > http://p.sf.net/sfu/arcsisghtdev2dev > _______________________________________________ > Bugs-r-devel mailing list > Bug...@li... > https://lists.sourceforge.net/lists/listinfo/bugs-r-devel |
From: Uwe L. <li...@st...> - 2011-08-31 12:25:28
|
Chris, as a side note: I'd prefer not to copy the dlls into libs. In any case, it won't work the way you did it. Please R CMD build before R CMD INSTALL the tar file. I can take a look how to clean this up diring the weekend. I prefer to do things in Makevars.win rather than configure.win which makes it much harder to produce bi-arch binaries for BRugs. Uwe On 31.08.2011 14:01, Uwe Ligges wrote: > Chris, > > > thanks for your modifications and the 64-bit code. Great! I will test > during the weekend (I am about to travel in an hour or so). > > > > On 31.08.2011 11:28, chr...@us... wrote: >> Revision: 211 >> http://bugs-r.svn.sourceforge.net/bugs-r/?rev=211&view=rev >> Author: chris-jackson >> Date: 2011-08-31 09:28:44 +0000 (Wed, 31 Aug 2011) >> Log Message: >> ----------- >> Changes to allow running on x64 R in Windows. The same helper facility as on Linux is used to call the 32-bit DLL. >> >> + stop(errors[res], "\nPlease report this bug to ", maintainer) > > > > May I object against this line of code? > If there are BUGS traps, I am certainly not the person who likes to get > the bug report, since I cannot help in that case anyway. > > > >> Added: trunk/BRugs/R/windows/findOpenBUGS.R >> =================================================================== >> --- trunk/BRugs/R/windows/findOpenBUGS.R (rev 0) >> +++ trunk/BRugs/R/windows/findOpenBUGS.R 2011-08-31 09:28:44 UTC (rev 211) >> @@ -0,0 +1,43 @@ >> +findOpenBUGS<- function() >> +{ >> + dir<- Sys.getenv("OpenBUGS_PATH") >> + if(!nchar(dir)){ >> + deps<- utils:::packageDescription("BRugs", fields="SystemRequirements") >> + version.req<- gsub(".*OpenBUGS ?\\(>= ?(.+)\\).*", "\\1", deps) >> + >> + key<- if (.Platform$r_arch == "x64") "Software\\Wow6432Node\\OpenBUGS" else "Software\\OpenBUGS" > > > The above is implemented by the view argument in readRegistry. Why not > use it? It will be safe in case Microsoft changes the names of registry > keys again in the next version of Windows. You have not changed it below. > > > >> + ob.reg<- try(utils:::readRegistry(key, "HLM"), silent = TRUE) >> + ## ob.reg<- try(utils:::readRegistry("Software\\OpenBUGS", "HLM", view = "32-bit"), silent = TRUE) > > > >> + ## remove suffixes from development versions, converts e.g. 3.2.1alpha to 3.2.1 > > > Question is if we actually want to remove that in case we really require > a release rather than the alpha version. > > > >> + version.inst<- gsub("(.+[0-9]+)[a-zA-Z]+$","\\1", version.full) >> + >> + if(length(version.inst> 1)){ >> + id<- which(apply(outer(version.inst, version.inst, Vectorize(compareVersion, c("a", "b"))), 1, function(x) all(x>= 0))) >> + id<- max(id) # if more than one release with same number, arbitrarily choose last one in registry >> + version.inst<- version.inst[id] >> + version.full<- version.full[id] >> + rnames<- rnames[id] >> + } >> + >> + if (compareVersion(version.inst, version.req)< 0) { >> + warning("Found OpenBUGS version ", version.inst, ".\n Requires ", version.req, " or greater.\nSetting the environment variable 'OpenBUGS_PATH' in advance of loading 'BRugs' overwrites the path.\nSee ?loadOpenBUGS in order to load OpenBUGS manually.") >> + return() >> + } >> + >> + ## OpenBUGS installation location >> + dir<- utils:::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")) >> + return() >> + } >> + version.inst<- NA >> + } >> + list(dir=dir, version=version.full) >> +} >> > > > > >> Added: trunk/BRugs/R/windows/zzz.i386.R >> =================================================================== >> --- trunk/BRugs/R/windows/zzz.i386.R (rev 0) >> +++ trunk/BRugs/R/windows/zzz.i386.R 2011-08-31 09:28:44 UTC (rev 211) >> @@ -0,0 +1,40 @@ >> +".onLoad.i386"<- function(lib, pkg){ >> + ob<- findOpenBUGS() >> + loadOpenBUGS(ob$dir) >> + msg<- paste("Welcome to BRugs connected to OpenBUGS") >> + if (!is.na(ob$version)) >> + msg<- paste(msg, "version", ob$version) >> + else msg<- paste(msg, "in directory", ob$dir) >> + packageStartupMessage(msg) >> +} >> + >> +".onUnload.i386"<- function(libpath){ >> + if(is.loaded("CmdInterpreter")) { >> + libname<- paste(options()$OpenBUGS, "libOpenBUGS.dll", sep="/") >> + dyn.unload(libname) >> + } >> +} >> + >> +## Load OpenBUGS from specified location >> +loadOpenBUGS<- function(dir) { >> + libname<- paste(dir, "libOpenBUGS.dll", sep="/") >> + if (!file.exists(libname)) { >> + warning("Shared library \"libOpenBUGS.dll\" not found in ", dir) >> + return(FALSE) >> + } >> + options(OpenBUGS = dir) >> + dyn.load(libname) >> + len<- nchar(dir) >> + .C("SetWorkingDir", as.character(dir), len) >> + ## Set temporary dir for "buffer.txt" output >> + tempDir<- gsub("\\\\", "/", tempdir()) >> + .C("SetTempDir", as.character(tempDir), nchar(tempDir)) >> + command<- "BugsMappers.SetDest(2)" >> + .CmdInterpreter(command) >> + if(is.null(getOption("BRugsVerbose"))) >> + options("BRugsVerbose" = TRUE) >> + .initGlobals() >> + options(OpenBUGSExamples = paste(dir, "Examples", sep="/")) >> + invisible() >> +} >> + >> >> Added: trunk/BRugs/R/windows/zzz.x64.R >> =================================================================== >> --- trunk/BRugs/R/windows/zzz.x64.R (rev 0) >> +++ trunk/BRugs/R/windows/zzz.x64.R 2011-08-31 09:28:44 UTC (rev 211) >> @@ -0,0 +1,25 @@ >> +if (is.R()){ >> + >> + ".onLoad.x64"<- function(lib, pkg){ >> + ## TODO any need for these to be user specifiable? >> + options("BRugsTmpdir" = gsub("\\\\", "/", tempdir())) >> + options("BRugsExtFile" = paste(basename(tempfile()), ".bug", sep="")) >> + options(OpenBUGS = "C:/Program Files (x86)/OpenBUGS/OpenBUGS321") >> + options(OpenBUGSdoc = "C:/Program Files (x86)/OpenBUGS/OpenBUGS321") >> + options(OpenBUGSExamples = paste(options()$OpenBUGSdoc, "Examples", sep="/")) > > > > Why not do it the same way as for 32-bit? The stuff is in the 32-bit > view in the registry, hence findOpenBUGS results could be used here. > > The .in file is not helpful given we provide binaries for the package on > CRAN and *my* installation will be inserted. > > > > Best wishes, > uwe > > ------------------------------------------------------------------------------ > Special Offer -- Download ArcSight Logger for FREE! > Finally, a world-class log management solution at an even better > price-free! And you'll get a free "Love Thy Logs" t-shirt when you > download Logger. Secure your free ArcSight Logger TODAY! > http://p.sf.net/sfu/arcsisghtdev2dev > _______________________________________________ > Bugs-r-devel mailing list > Bug...@li... > https://lists.sourceforge.net/lists/listinfo/bugs-r-devel |
From: Uwe L. <li...@st...> - 2011-08-31 12:22:53
|
Chris, thanks for your modifications and the 64-bit code. Great! I will test during the weekend (I am about to travel in an hour or so). On 31.08.2011 11:28, chr...@us... wrote: > Revision: 211 > http://bugs-r.svn.sourceforge.net/bugs-r/?rev=211&view=rev > Author: chris-jackson > Date: 2011-08-31 09:28:44 +0000 (Wed, 31 Aug 2011) > Log Message: > ----------- > Changes to allow running on x64 R in Windows. The same helper facility as on Linux is used to call the 32-bit DLL. > > + stop(errors[res], "\nPlease report this bug to ", maintainer) May I object against this line of code? If there are BUGS traps, I am certainly not the person who likes to get the bug report, since I cannot help in that case anyway. > Added: trunk/BRugs/R/windows/findOpenBUGS.R > =================================================================== > --- trunk/BRugs/R/windows/findOpenBUGS.R (rev 0) > +++ trunk/BRugs/R/windows/findOpenBUGS.R 2011-08-31 09:28:44 UTC (rev 211) > @@ -0,0 +1,43 @@ > +findOpenBUGS<- function() > +{ > + dir<- Sys.getenv("OpenBUGS_PATH") > + if(!nchar(dir)){ > + deps<- utils:::packageDescription("BRugs", fields="SystemRequirements") > + version.req<- gsub(".*OpenBUGS ?\\(>= ?(.+)\\).*", "\\1", deps) > + > + key<- if (.Platform$r_arch == "x64") "Software\\Wow6432Node\\OpenBUGS" else "Software\\OpenBUGS" The above is implemented by the view argument in readRegistry. Why not use it? It will be safe in case Microsoft changes the names of registry keys again in the next version of Windows. You have not changed it below. > + ob.reg<- try(utils:::readRegistry(key, "HLM"), silent = TRUE) > + ## ob.reg<- try(utils:::readRegistry("Software\\OpenBUGS", "HLM", view = "32-bit"), silent = TRUE) > + ## remove suffixes from development versions, converts e.g. 3.2.1alpha to 3.2.1 Question is if we actually want to remove that in case we really require a release rather than the alpha version. > + version.inst<- gsub("(.+[0-9]+)[a-zA-Z]+$","\\1", version.full) > + > + if(length(version.inst> 1)){ > + id<- which(apply(outer(version.inst, version.inst, Vectorize(compareVersion, c("a", "b"))), 1, function(x) all(x>= 0))) > + id<- max(id) # if more than one release with same number, arbitrarily choose last one in registry > + version.inst<- version.inst[id] > + version.full<- version.full[id] > + rnames<- rnames[id] > + } > + > + if (compareVersion(version.inst, version.req)< 0) { > + warning("Found OpenBUGS version ", version.inst, ".\n Requires ", version.req, " or greater.\nSetting the environment variable 'OpenBUGS_PATH' in advance of loading 'BRugs' overwrites the path.\nSee ?loadOpenBUGS in order to load OpenBUGS manually.") > + return() > + } > + > + ## OpenBUGS installation location > + dir<- utils:::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")) > + return() > + } > + version.inst<- NA > + } > + list(dir=dir, version=version.full) > +} > > Added: trunk/BRugs/R/windows/zzz.i386.R > =================================================================== > --- trunk/BRugs/R/windows/zzz.i386.R (rev 0) > +++ trunk/BRugs/R/windows/zzz.i386.R 2011-08-31 09:28:44 UTC (rev 211) > @@ -0,0 +1,40 @@ > +".onLoad.i386"<- function(lib, pkg){ > + ob<- findOpenBUGS() > + loadOpenBUGS(ob$dir) > + msg<- paste("Welcome to BRugs connected to OpenBUGS") > + if (!is.na(ob$version)) > + msg<- paste(msg, "version", ob$version) > + else msg<- paste(msg, "in directory", ob$dir) > + packageStartupMessage(msg) > +} > + > +".onUnload.i386"<- function(libpath){ > + if(is.loaded("CmdInterpreter")) { > + libname<- paste(options()$OpenBUGS, "libOpenBUGS.dll", sep="/") > + dyn.unload(libname) > + } > +} > + > +## Load OpenBUGS from specified location > +loadOpenBUGS<- function(dir) { > + libname<- paste(dir, "libOpenBUGS.dll", sep="/") > + if (!file.exists(libname)) { > + warning("Shared library \"libOpenBUGS.dll\" not found in ", dir) > + return(FALSE) > + } > + options(OpenBUGS = dir) > + dyn.load(libname) > + len<- nchar(dir) > + .C("SetWorkingDir", as.character(dir), len) > + ## Set temporary dir for "buffer.txt" output > + tempDir<- gsub("\\\\", "/", tempdir()) > + .C("SetTempDir", as.character(tempDir), nchar(tempDir)) > + command<- "BugsMappers.SetDest(2)" > + .CmdInterpreter(command) > + if(is.null(getOption("BRugsVerbose"))) > + options("BRugsVerbose" = TRUE) > + .initGlobals() > + options(OpenBUGSExamples = paste(dir, "Examples", sep="/")) > + invisible() > +} > + > > Added: trunk/BRugs/R/windows/zzz.x64.R > =================================================================== > --- trunk/BRugs/R/windows/zzz.x64.R (rev 0) > +++ trunk/BRugs/R/windows/zzz.x64.R 2011-08-31 09:28:44 UTC (rev 211) > @@ -0,0 +1,25 @@ > +if (is.R()){ > + > + ".onLoad.x64"<- function(lib, pkg){ > + ## TODO any need for these to be user specifiable? > + options("BRugsTmpdir" = gsub("\\\\", "/", tempdir())) > + options("BRugsExtFile" = paste(basename(tempfile()), ".bug", sep="")) > + options(OpenBUGS = "C:/Program Files (x86)/OpenBUGS/OpenBUGS321") > + options(OpenBUGSdoc = "C:/Program Files (x86)/OpenBUGS/OpenBUGS321") > + options(OpenBUGSExamples = paste(options()$OpenBUGSdoc, "Examples", sep="/")) Why not do it the same way as for 32-bit? The stuff is in the 32-bit view in the registry, hence findOpenBUGS results could be used here. The .in file is not helpful given we provide binaries for the package on CRAN and *my* installation will be inserted. Best wishes, uwe |
From: Uwe L. <li...@st...> - 2011-08-31 12:22:53
|
Chris, thanks for your modifications and the 64-bit code. Great! I will test during the weekend (I am about to travel in an hour or so). On 31.08.2011 11:28, chr...@us... wrote: > Revision: 211 > http://bugs-r.svn.sourceforge.net/bugs-r/?rev=211&view=rev > Author: chris-jackson > Date: 2011-08-31 09:28:44 +0000 (Wed, 31 Aug 2011) > Log Message: > ----------- > Changes to allow running on x64 R in Windows. The same helper facility as on Linux is used to call the 32-bit DLL. > > + stop(errors[res], "\nPlease report this bug to ", maintainer) May I object against this line of code? If there are BUGS traps, I am certainly not the person who likes to get the bug report, since I cannot help in that case anyway. > Added: trunk/BRugs/R/windows/findOpenBUGS.R > =================================================================== > --- trunk/BRugs/R/windows/findOpenBUGS.R (rev 0) > +++ trunk/BRugs/R/windows/findOpenBUGS.R 2011-08-31 09:28:44 UTC (rev 211) > @@ -0,0 +1,43 @@ > +findOpenBUGS<- function() > +{ > + dir<- Sys.getenv("OpenBUGS_PATH") > + if(!nchar(dir)){ > + deps<- utils:::packageDescription("BRugs", fields="SystemRequirements") > + version.req<- gsub(".*OpenBUGS ?\\(>= ?(.+)\\).*", "\\1", deps) > + > + key<- if (.Platform$r_arch == "x64") "Software\\Wow6432Node\\OpenBUGS" else "Software\\OpenBUGS" The above is implemented by the view argument in readRegistry. Why not use it? It will be safe in case Microsoft changes the names of registry keys again in the next version of Windows. You have not changed it below. > + ob.reg<- try(utils:::readRegistry(key, "HLM"), silent = TRUE) > + ## ob.reg<- try(utils:::readRegistry("Software\\OpenBUGS", "HLM", view = "32-bit"), silent = TRUE) > + ## remove suffixes from development versions, converts e.g. 3.2.1alpha to 3.2.1 Question is if we actually want to remove that in case we really require a release rather than the alpha version. > + version.inst<- gsub("(.+[0-9]+)[a-zA-Z]+$","\\1", version.full) > + > + if(length(version.inst> 1)){ > + id<- which(apply(outer(version.inst, version.inst, Vectorize(compareVersion, c("a", "b"))), 1, function(x) all(x>= 0))) > + id<- max(id) # if more than one release with same number, arbitrarily choose last one in registry > + version.inst<- version.inst[id] > + version.full<- version.full[id] > + rnames<- rnames[id] > + } > + > + if (compareVersion(version.inst, version.req)< 0) { > + warning("Found OpenBUGS version ", version.inst, ".\n Requires ", version.req, " or greater.\nSetting the environment variable 'OpenBUGS_PATH' in advance of loading 'BRugs' overwrites the path.\nSee ?loadOpenBUGS in order to load OpenBUGS manually.") > + return() > + } > + > + ## OpenBUGS installation location > + dir<- utils:::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")) > + return() > + } > + version.inst<- NA > + } > + list(dir=dir, version=version.full) > +} > > Added: trunk/BRugs/R/windows/zzz.i386.R > =================================================================== > --- trunk/BRugs/R/windows/zzz.i386.R (rev 0) > +++ trunk/BRugs/R/windows/zzz.i386.R 2011-08-31 09:28:44 UTC (rev 211) > @@ -0,0 +1,40 @@ > +".onLoad.i386"<- function(lib, pkg){ > + ob<- findOpenBUGS() > + loadOpenBUGS(ob$dir) > + msg<- paste("Welcome to BRugs connected to OpenBUGS") > + if (!is.na(ob$version)) > + msg<- paste(msg, "version", ob$version) > + else msg<- paste(msg, "in directory", ob$dir) > + packageStartupMessage(msg) > +} > + > +".onUnload.i386"<- function(libpath){ > + if(is.loaded("CmdInterpreter")) { > + libname<- paste(options()$OpenBUGS, "libOpenBUGS.dll", sep="/") > + dyn.unload(libname) > + } > +} > + > +## Load OpenBUGS from specified location > +loadOpenBUGS<- function(dir) { > + libname<- paste(dir, "libOpenBUGS.dll", sep="/") > + if (!file.exists(libname)) { > + warning("Shared library \"libOpenBUGS.dll\" not found in ", dir) > + return(FALSE) > + } > + options(OpenBUGS = dir) > + dyn.load(libname) > + len<- nchar(dir) > + .C("SetWorkingDir", as.character(dir), len) > + ## Set temporary dir for "buffer.txt" output > + tempDir<- gsub("\\\\", "/", tempdir()) > + .C("SetTempDir", as.character(tempDir), nchar(tempDir)) > + command<- "BugsMappers.SetDest(2)" > + .CmdInterpreter(command) > + if(is.null(getOption("BRugsVerbose"))) > + options("BRugsVerbose" = TRUE) > + .initGlobals() > + options(OpenBUGSExamples = paste(dir, "Examples", sep="/")) > + invisible() > +} > + > > Added: trunk/BRugs/R/windows/zzz.x64.R > =================================================================== > --- trunk/BRugs/R/windows/zzz.x64.R (rev 0) > +++ trunk/BRugs/R/windows/zzz.x64.R 2011-08-31 09:28:44 UTC (rev 211) > @@ -0,0 +1,25 @@ > +if (is.R()){ > + > + ".onLoad.x64"<- function(lib, pkg){ > + ## TODO any need for these to be user specifiable? > + options("BRugsTmpdir" = gsub("\\\\", "/", tempdir())) > + options("BRugsExtFile" = paste(basename(tempfile()), ".bug", sep="")) > + options(OpenBUGS = "C:/Program Files (x86)/OpenBUGS/OpenBUGS321") > + options(OpenBUGSdoc = "C:/Program Files (x86)/OpenBUGS/OpenBUGS321") > + options(OpenBUGSExamples = paste(options()$OpenBUGSdoc, "Examples", sep="/")) Why not do it the same way as for 32-bit? The stuff is in the 32-bit view in the registry, hence findOpenBUGS results could be used here. The .in file is not helpful given we provide binaries for the package on CRAN and *my* installation will be inserted. Best wishes, uwe |
From: <chr...@us...> - 2011-08-31 09:30:16
|
Revision: 212 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=212&view=rev Author: chris-jackson Date: 2011-08-31 09:30:10 +0000 (Wed, 31 Aug 2011) Log Message: ----------- Error instead of crash when sampler is adapting. Modified Paths: -------------- trunk/BRugs/R/plot.bgr.R trunk/BRugs/R/samples.bgr.R trunk/BRugs/R/samples.history.R trunk/BRugs/R/samples.size.R Modified: trunk/BRugs/R/plot.bgr.R =================================================================== --- trunk/BRugs/R/plot.bgr.R 2011-08-31 09:28:44 UTC (rev 211) +++ trunk/BRugs/R/plot.bgr.R 2011-08-31 09:30:10 UTC (rev 212) @@ -6,6 +6,7 @@ sM <- samplesMonitors(node) if(length(sM) > 1 || sM != node) stop("node must be a scalar variable from the model, for arrays use samplesBgr") + if (any(grep("^inference can not be made", sM))) { stop(sM) } grid <- bgrGrid(node, bins = bins) ## Use a single API call instead of looping API calls over Modified: trunk/BRugs/R/samples.bgr.R =================================================================== --- trunk/BRugs/R/samples.bgr.R 2011-08-31 09:28:44 UTC (rev 211) +++ trunk/BRugs/R/samples.bgr.R 2011-08-31 09:30:10 UTC (rev 212) @@ -5,6 +5,8 @@ ask = NULL, ann = TRUE, ...) # Plot bgr statistic { + mons <- samplesMonitors(node) + if (any(grep("^inference can not be made", mons))) { stop(mons) } if(plot && is.null(ask)) { if (is.R()) ask <- !((dev.cur() > 1) && !dev.interactive()) Modified: trunk/BRugs/R/samples.history.R =================================================================== --- trunk/BRugs/R/samples.history.R 2011-08-31 09:28:44 UTC (rev 211) +++ trunk/BRugs/R/samples.history.R 2011-08-31 09:30:10 UTC (rev 212) @@ -4,6 +4,7 @@ thin = samplesGetThin(), plot = TRUE, mfrow = c(3, 1), ask = NULL, ann = TRUE, ...) # Plot history { + if (samplesSize(node)==0) stop("No monitored samples available") if(plot && is.null(ask)) { if (is.R()) ask <- !((dev.cur() > 1) && !dev.interactive()) Modified: trunk/BRugs/R/samples.size.R =================================================================== --- trunk/BRugs/R/samples.size.R 2011-08-31 09:28:44 UTC (rev 211) +++ trunk/BRugs/R/samples.size.R 2011-08-31 09:30:10 UTC (rev 212) @@ -7,6 +7,7 @@ # so returns 0 for non-existent nodes if (any(grep("^no monitor set", sM))) return(0) if (any(grep("^model has probably not yet been updated", sM))) return(0) + if (any(grep("^inference can not be made", sM))) { warning(sM); return(0) } if(length(sM) > 1 || sM != node) stop("node must be a scalar variable from the model") size <- .OpenBUGS(c(.SamplesGlobalsCmd(node), "SamplesEmbed.SampleSize"), This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2011-08-31 09:28:51
|
Revision: 211 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=211&view=rev Author: chris-jackson Date: 2011-08-31 09:28:44 +0000 (Wed, 31 Aug 2011) Log Message: ----------- Changes to allow running on x64 R in Windows. The same helper facility as on Linux is used to call the 32-bit DLL. Modified Paths: -------------- trunk/BRugs/NEWS trunk/BRugs/R/internal.R trunk/BRugs/R/unix/internal.R trunk/BRugs/R/unix/zzz.R trunk/BRugs/R/unix/zzz.R.in trunk/BRugs/R/windows/internal.R trunk/BRugs/R/windows/zzz.R trunk/BRugs/configure trunk/BRugs/configure.ac trunk/BRugs/configure.win trunk/BRugs/man/BRugs.Rd trunk/BRugs/src/BugsHelper.c trunk/BRugs/src/Makefile.win trunk/BRugs/src/Makevars.in trunk/BRugs/tests/functions.R Added Paths: ----------- trunk/BRugs/R/windows/findOpenBUGS.R trunk/BRugs/R/windows/zzz.i386.R trunk/BRugs/R/windows/zzz.x64.R trunk/BRugs/R/windows/zzz.x64.R.in trunk/BRugs/configure.win.R trunk/BRugs/exec/ Property Changed: ---------------- trunk/BRugs/ trunk/BRugs/src/ Property changes on: trunk/BRugs ___________________________________________________________________ Added: svn:ignore + .Rbuildignore autom4te.cache config.log config.status Modified: trunk/BRugs/NEWS =================================================================== --- trunk/BRugs/NEWS 2011-08-30 21:57:45 UTC (rev 210) +++ trunk/BRugs/NEWS 2011-08-31 09:28:44 UTC (rev 211) @@ -1,10 +1,32 @@ Changes to BRugs: ===================== -Version 0.7.2 (24 August 2011) +Version 0.7.2 (?? September 2011) ------------- -Backport to the original BRugs package +BRugs now supports 64-bit R on Windows, using the same helper program +as Linux for calling the 32 bit OpenBUGS shared library. Thanks to +Brian Ripley for the reports. +On Linux, when the OpenBUGS library call terminates with a "trap" +error, the trap message is now shown. Thanks to Alexandre Villers. +Though on Windows, OpenBUGS "traps" still crash R. +modelSetWD() function added. This is simply an alias for setwd(), for +compatibility with the OpenBUGS script function of the same name. + +Just strip trailing spaces, not internal spaces, from updater names in +infoUpdatersbyName(). Thanks to Bob O'Hara. + +samplesSize() gives a warning, and samplesBgr() now gives an error, +instead of crashing, when trying to use them when the sampler is in an +adaptive phase. + +Warning in manual that enabling/disabling updaters is not supported on +Linux until the next version of OpenBUGS. + +BugsCmd API function is now supported by BugsHelper, but this is not +used. + + Version 0.7.1 (19 April 2011) ------------- Modified: trunk/BRugs/R/internal.R =================================================================== --- trunk/BRugs/R/internal.R 2011-08-30 21:57:45 UTC (rev 210) +++ trunk/BRugs/R/internal.R 2011-08-31 09:28:44 UTC (rev 211) @@ -1,5 +1,10 @@ ### Functions to run a single OpenBUGS API command string +.BugsCmd <- function(command) +{ + unlist(.OpenBUGS(command, "BugsCmd")) +} + .CmdInterpreter <- function(command) { unlist(.OpenBUGS(command, "CmdInterpreter")) @@ -21,7 +26,7 @@ } -.OpenBUGS.cmdtypes <- c("CmdInterpreter","Integer","CharArray","RealArray") +.OpenBUGS.cmdtypes <- c("CmdInterpreter","Integer","CharArray","RealArray","BugsCmd") .OpenBUGS <- function(cmds, cmdtypes=NULL, args=NULL) { ncmds <- length(cmds) @@ -32,14 +37,57 @@ .OpenBUGS.platform(cmds, cmdtypes, args) } +dquote <- function(x){ + paste("\"", x, "\"", sep="") +} + +.OpenBUGS.helper <- function(cmds, cmdtypes, args) { + ncmds <- length(cmds) + if (ncmds > 99999) stop("Maximum number of OpenBUGS API commands exceeded") + tempDir <- getOption("BRugsTmpdir") + ## Don't want internalize/externalize to overwrite the command + ## output buffer, so redirect its output to a separate trash can. + trashDir <- paste(tempDir, "_trash", sep="") + extFile <- getOption("BRugsExtFile") + cmdFile <- paste(tempDir, "cmds.txt", sep="/") + pkgPath <- searchpaths()[search()=="package:BRugs"] + bugsPath <- paste(pkgPath, "/exec/BugsHelper", sep="") + shcmd <- paste(bugsPath, dquote(tempDir), dquote(trashDir), dquote(extFile), dquote(cmdFile), dquote(ncmds)) + for (i in 1:ncmds) { + if (cmdtypes[i] %in% c("CharArray","RealArray")) + cat(args[[i]], file=paste(tempDir, "/input",i,".txt", sep="")) + } + cmd.id <- match(cmdtypes, .OpenBUGS.cmdtypes) - 1 + write(rbind(cmds, cmd.id), cmdFile) + res <- system(shcmd) + handleRes(res) + out <- vector(ncmds, mode="list") + for (i in 1:ncmds) { + if (cmdtypes[i] %in% c("Integer","CharArray","RealArray")) + out[[i]] <- scan(paste(tempDir,"/output",i,".txt",sep=""), + switch(cmdtypes[i], + "Integer" = integer(), + "CharArray" = character(), + "RealArray" = double()), + quiet=TRUE) + } + out +} + handleRes <- function(res) { maintainer <- utils:::packageDescription("BRugs", fields="Maintainer") - switch(res, - stop("An OpenBUGS module or procedure was called that did not exist. Please report this bug to ", maintainer), - stop("An OpenBUGS procedure was called with the wrong type of argument. Please report this bug to ", maintainer), - stop("An OpenBUGS procedure was called with the wrong signature. Please report this bug to ", maintainer) - ) + errors <- c("Internal \"trap\" error in OpenBUGS, or non-existent module or procedure called.", + "An OpenBUGS procedure was called with the wrong type of argument.", + "An OpenBUGS procedure was called with the wrong signature.") + ## If a library call ends in a trap, then error code 1 will be returned from BugsHelper on Linux + ## On Windows it shouldn't even get this far after a trap. TODO see if the trap message is shown. + if (res > 0) { + buf <- readLines(file.path(tempdir(), "buffer.txt")) + trap <- grep("Sorry something went wrong", buf, value=TRUE) + if(length(trap) > 0) message(trap[1]) + stop(errors[res], "\nPlease report this bug to ", maintainer) + } } .SamplesGlobalsCmd <- function(node){ @@ -50,7 +98,7 @@ paste("SamplesEmbed.firstChain :=", getOption("BRugsSamplesFirstChain")), paste("SamplesEmbed.lastChain :=", getOption("BRugsSamplesLastChain")), paste("SamplesEmbed.thin :=", getOption("BRugsSamplesThin")), - paste("SamplesEmbed.SetVariable(", shQuote(node), ")", sep=""), + paste("SamplesEmbed.SetVariable(", sQuote(node), ")", sep=""), paste("BugsMappers.SetPrec(", getOption("BRugsPrec"), ")", sep="") ) options(options.old) Modified: trunk/BRugs/R/unix/internal.R =================================================================== --- trunk/BRugs/R/unix/internal.R 2011-08-30 21:57:45 UTC (rev 210) +++ trunk/BRugs/R/unix/internal.R 2011-08-31 09:28:44 UTC (rev 211) @@ -1,36 +1,4 @@ -dquote <- function(x){ - paste("\"", x, "\"", sep="") -} - .OpenBUGS.platform <- function(cmds, cmdtypes, args) { - ncmds <- length(cmds) - if (ncmds > 99999) stop("Maximum number of OpenBUGS API commands exceeded") - tempDir <- getOption("BRugsTmpdir") - ## Don't want internalize/externalize to overwrite the command - ## output buffer, so redirect its output to a separate trash can. - trashDir <- paste(tempDir, "_trash", sep="") - extFile <- getOption("BRugsExtFile") - pkgPath <- searchpaths()[search()=="package:BRugs"] - bugsPath <- paste(pkgPath, "/exec/BugsHelper", sep="") - shcmd <- paste(bugsPath, dquote(tempDir), dquote(trashDir), dquote(extFile)) - for (i in 1:ncmds) { - if (cmdtypes[i] %in% c("CharArray","RealArray")) - cat(args[[i]], file=paste(tempDir, "/input",i,".txt", sep="")) - cmdtype <- match(cmdtypes[i], .OpenBUGS.cmdtypes) - 1 - shcmd <- paste(shcmd, dquote(cmds[i]), cmdtype) - } - res <- system(shcmd) - handleRes(res) - out <- vector(ncmds, mode="list") - for (i in 1:ncmds) { - if (cmdtypes[i] %in% c("Integer","CharArray","RealArray")) - out[[i]] <- scan(paste(tempDir,"/output",i,".txt",sep=""), - switch(cmdtypes[i], - "Integer" = integer(), - "CharArray" = character(), - "RealArray" = double()), - quiet=TRUE) - } - out + .OpenBUGS.helper(cmds, cmdtypes, args) } Modified: trunk/BRugs/R/unix/zzz.R =================================================================== --- trunk/BRugs/R/unix/zzz.R 2011-08-30 21:57:45 UTC (rev 210) +++ trunk/BRugs/R/unix/zzz.R 2011-08-31 09:28:44 UTC (rev 211) @@ -4,16 +4,16 @@ ## TODO any need for these to be user specifiable? options("BRugsTmpdir" = gsub("\\\\", "/", tempdir())) options("BRugsExtFile" = paste(basename(tempfile()), ".bug", sep="")) - options(OpenBUGS = "/usr/local/lib/OpenBUGS") + options(OpenBUGS = "/usr/local/lib/OpenBUGS/lib") options(OpenBUGSdoc = "/usr/local/lib/OpenBUGS/doc") options(OpenBUGSExamples = paste(options()$OpenBUGSdoc, "Examples", sep="/")) if(is.null(getOption("BRugsVerbose"))) options("BRugsVerbose" = TRUE) .initGlobals() - ver <- system("echo \"modelQuit()\" | /usr/local/lib/OpenBUGS/bin/OpenBUGS", intern=TRUE) + ver <- system("echo \"modelQuit()\" | /usr/local/lib/OpenBUGS/lib/../bin/OpenBUGS", intern=TRUE) ver <- sub("OpenBUGS version (([0-9]\\.)+[0-9]).+","\\1",ver[1]) - packageStartupMessage("Welcome to BRugs running on OpenBUGS version ", ver) + packageStartupMessage("Welcome to BRugs connected to OpenBUGS version ", ver) } ".onUnload" <- function(libpath){ Modified: trunk/BRugs/R/unix/zzz.R.in =================================================================== --- trunk/BRugs/R/unix/zzz.R.in 2011-08-30 21:57:45 UTC (rev 210) +++ trunk/BRugs/R/unix/zzz.R.in 2011-08-31 09:28:44 UTC (rev 211) @@ -11,9 +11,9 @@ if(is.null(getOption("BRugsVerbose"))) options("BRugsVerbose" = TRUE) .initGlobals() - ver <- system("echo \"modelQuit()\" | @OPENBUGS@/bin/OpenBUGS", intern=TRUE) + ver <- system("echo \"modelQuit()\" | @OPENBUGS@/../bin/OpenBUGS", intern=TRUE) ver <- sub("OpenBUGS version (([0-9]\\.)+[0-9]).+","\\1",ver[1]) - packageStartupMessage("Welcome to BRugs running on OpenBUGS version ", ver) + packageStartupMessage("Welcome to BRugs connected to OpenBUGS version ", ver) } ".onUnload" <- function(libpath){ Added: trunk/BRugs/R/windows/findOpenBUGS.R =================================================================== --- trunk/BRugs/R/windows/findOpenBUGS.R (rev 0) +++ trunk/BRugs/R/windows/findOpenBUGS.R 2011-08-31 09:28:44 UTC (rev 211) @@ -0,0 +1,43 @@ +findOpenBUGS <- function() +{ + dir <- Sys.getenv("OpenBUGS_PATH") + if(!nchar(dir)){ + deps <- utils:::packageDescription("BRugs", fields="SystemRequirements") + version.req <- gsub(".*OpenBUGS ?\\(>= ?(.+)\\).*", "\\1", deps) + + key <- if (.Platform$r_arch == "x64") "Software\\Wow6432Node\\OpenBUGS" else "Software\\OpenBUGS" + ob.reg <- try(utils:::readRegistry(key, "HLM"), silent = TRUE) + ## ob.reg <- try(utils:::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() + } + rnames <- names(ob.reg) + version.full <- gsub("OpenBUGS ", "", rnames) + ## remove suffixes from development versions, converts e.g. 3.2.1alpha to 3.2.1 + version.inst <- gsub("(.+[0-9]+)[a-zA-Z]+$","\\1", version.full) + + if(length(version.inst > 1)){ + id <- which(apply(outer(version.inst, version.inst, Vectorize(compareVersion, c("a", "b"))), 1, function(x) all(x >= 0))) + id <- max(id) # if more than one release with same number, arbitrarily choose last one in registry + version.inst <- version.inst[id] + version.full <- version.full[id] + rnames <- rnames[id] + } + + if (compareVersion(version.inst, version.req) < 0) { + warning("Found OpenBUGS version ", version.inst, ".\n Requires ", version.req, " or greater.\nSetting the environment variable 'OpenBUGS_PATH' in advance of loading 'BRugs' overwrites the path.\nSee ?loadOpenBUGS in order to load OpenBUGS manually.") + return() + } + + ## OpenBUGS installation location + dir <- utils:::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")) + return() + } + version.inst <- NA + } + list(dir=dir, version=version.full) +} Modified: trunk/BRugs/R/windows/internal.R =================================================================== --- trunk/BRugs/R/windows/internal.R 2011-08-30 21:57:45 UTC (rev 210) +++ trunk/BRugs/R/windows/internal.R 2011-08-31 09:28:44 UTC (rev 211) @@ -2,31 +2,39 @@ .OpenBUGS.platform <- function(cmds, cmdtypes, args) { - ncmds <- length(cmds) - out <- vector(ncmds, mode="list") - for (i in 1:ncmds) { - out[[i]] <- switch(cmdtypes[i], - "CmdInterpreter" = { - res <- .C("CmdInterpreter", cmds[i], nchar(cmds[i]), integer(1)) - handleRes(res[[3]]) - res - }, - "Integer" = { - values <- .C("Integer", cmds[i], nchar(cmds[i]), integer(1), integer(1)) - handleRes(values[[4]]) - as.integer(values[[3]]) - }, - "CharArray" = { - values <- .C("CharArray", cmds[i], nchar(cmds[i]), args[[i]], nchar(args[[i]]), integer(1)) - handleRes(values[[5]]) - values[[3]] - }, - "RealArray" = { - values <- .C("RealArray", cmds[i], nchar(cmds[i]), args[[i]], length(args[[i]]), integer(1)) - handleRes(values[[5]]) - values[[3]] - }) + if (.Platform$r_arch == "x64"){ + out <- .OpenBUGS.helper(cmds, cmdtypes, args) + } + else if (.Platform$r_arch == "i386") { + ncmds <- length(cmds) + out <- vector(ncmds, mode="list") + for (i in 1:ncmds) { + out[[i]] <- switch(cmdtypes[i], + "CmdInterpreter" = { + res <- .C("CmdInterpreter", cmds[i], nchar(cmds[i]), integer(1), PACKAGE="libOpenBUGS") + handleRes(res[[3]]) + res + }, + "Integer" = { + values <- .C("Integer", cmds[i], nchar(cmds[i]), integer(1), integer(1), PACKAGE="libOpenBUGS") + handleRes(values[[4]]) + as.integer(values[[3]]) + }, + "CharArray" = { + values <- .C("CharArray", cmds[i], nchar(cmds[i]), args[[i]], nchar(args[[i]]), integer(1), PACKAGE="libOpenBUGS") + handleRes(values[[5]]) + values[[3]] + }, + "RealArray" = { + values <- .C("RealArray", cmds[i], nchar(cmds[i]), args[[i]], length(args[[i]]), integer(1), PACKAGE="libOpenBUGS") + handleRes(values[[5]]) + values[[3]] + }) - } - out + } + } + else { + stop("Unknown architecture ", .Platform$r_arch, " , should be i386 or x64") + } + out } Modified: trunk/BRugs/R/windows/zzz.R =================================================================== --- trunk/BRugs/R/windows/zzz.R 2011-08-30 21:57:45 UTC (rev 210) +++ trunk/BRugs/R/windows/zzz.R 2011-08-31 09:28:44 UTC (rev 211) @@ -1,75 +1,27 @@ if (is.R()){ ".onLoad" <- function(lib, pkg){ - if(.Platform[["r_arch"]] != "i386"){ - stop("BRugs only works for 32-bit R") + if (.Platform$r_arch == "i386") { + .onLoad.i386(lib, pkg) } - dir <- Sys.getenv("OpenBUGS_PATH") - if(!nchar(dir)){ - deps <- utils:::packageDescription("BRugs", fields="SystemRequirements") - version.req <- gsub(".*OpenBUGS ?\\(>= ?(.+)\\).*", "\\1", deps) - - ob.reg <- try(utils:::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() - } - rnames <- names(ob.reg) - ver <- gsub("OpenBUGS ", "", rnames) - version.inst <- gsub("(.+)e$","\\1", ver) - - if(length(version.inst > 1)){ - id <- which(apply(outer(version.inst, version.inst, Vectorize(compareVersion, c("a", "b"))), 1, function(x) all(x >= 0))) - version.inst <- version.inst[id] - rnames <- rnames[id] - } - - if (compareVersion(version.inst, version.req) < 0) { - warning("Found OpenBUGS version ", version.inst, ".\n Requires ", version.req, " or greater.\nSetting the environment variable 'OpenBUGS_PATH' in advance of loading 'BRugs' overwrites the path.\nSee ?loadOpenBUGS in order to load OpenBUGS manually.") - return() - } - ## OpenBUGS installation location - dir <- utils:::readRegistry(paste("Software","OpenBUGS",rnames,sep="\\"), "HLM", view = "32-bit")[["InstallPath"]] - loadOpenBUGS(dir) - packageStartupMessage("Welcome to BRugs running on OpenBUGS version ", version.inst) - } else { - if(!file.exists(file.path(dir, "libOpenBUGS.dll"))){ - warning("Environment variable OpenBUGS_PATH found but cannot access ", file.path(dir, "libOpenBUGS.dll")) - return() - } - loadOpenBUGS(dir) - packageStartupMessage("Welcome to BRugs connected to OpenBUGS in\n", dir) + else if (.Platform$r_arch == "x64"){ + .onLoad.x64(lib, pkg) } - } - - ## Load OpenBUGS from specified location - loadOpenBUGS <- function(dir) { - libname <- paste(dir, "libOpenBUGS.dll", sep="/") - if (!file.exists(libname)) { - warning("Shared library \"libOpenBUGS.dll\" not found in ", dir) - return(FALSE) + else { + stop("Unknown architecture ", .Platform$r_arch, " , should be i386 or x64") } - options(OpenBUGS = dir) - dyn.load(libname) - len <- nchar(dir) - .C("SetWorkingDir", as.character(dir), len) - ## Set temporary dir for "buffer.txt" output - tempDir <- gsub("\\\\", "/", tempdir()) - .C("SetTempDir", as.character(tempDir), nchar(tempDir)) - command <- "BugsMappers.SetDest(2)" - .CmdInterpreter(command) - if(is.null(getOption("BRugsVerbose"))) - options("BRugsVerbose" = TRUE) - .initGlobals() - options(OpenBUGSExamples = paste(dir, "Examples", sep="/")) - invisible() } ".onUnload" <- function(libpath){ - if(is.loaded("CmdInterpreter")) { - libname <- paste(options()$OpenBUGS, "libOpenBUGS.dll", sep="/") - dyn.unload(libname) + if (.Platform$r_arch == "i386") { + .onUnload.i386(libpath) } - } + else if (.Platform$r_arch == "x64"){ + .onUnload.x64(libpath) + } + else { + stop("Unknown architecture ", .Platform$r_arch, " , should be i386 or x64") + } + } } Added: trunk/BRugs/R/windows/zzz.i386.R =================================================================== --- trunk/BRugs/R/windows/zzz.i386.R (rev 0) +++ trunk/BRugs/R/windows/zzz.i386.R 2011-08-31 09:28:44 UTC (rev 211) @@ -0,0 +1,40 @@ +".onLoad.i386" <- function(lib, pkg){ + ob <- findOpenBUGS() + loadOpenBUGS(ob$dir) + msg <- paste("Welcome to BRugs connected to OpenBUGS") + if (!is.na(ob$version)) + msg <- paste(msg, "version", ob$version) + else msg <- paste(msg, "in directory", ob$dir) + packageStartupMessage(msg) +} + +".onUnload.i386" <- function(libpath){ + if(is.loaded("CmdInterpreter")) { + libname <- paste(options()$OpenBUGS, "libOpenBUGS.dll", sep="/") + dyn.unload(libname) + } +} + +## Load OpenBUGS from specified location +loadOpenBUGS <- function(dir) { + libname <- paste(dir, "libOpenBUGS.dll", sep="/") + if (!file.exists(libname)) { + warning("Shared library \"libOpenBUGS.dll\" not found in ", dir) + return(FALSE) + } + options(OpenBUGS = dir) + dyn.load(libname) + len <- nchar(dir) + .C("SetWorkingDir", as.character(dir), len) + ## Set temporary dir for "buffer.txt" output + tempDir <- gsub("\\\\", "/", tempdir()) + .C("SetTempDir", as.character(tempDir), nchar(tempDir)) + command <- "BugsMappers.SetDest(2)" + .CmdInterpreter(command) + if(is.null(getOption("BRugsVerbose"))) + options("BRugsVerbose" = TRUE) + .initGlobals() + options(OpenBUGSExamples = paste(dir, "Examples", sep="/")) + invisible() +} + Added: trunk/BRugs/R/windows/zzz.x64.R =================================================================== --- trunk/BRugs/R/windows/zzz.x64.R (rev 0) +++ trunk/BRugs/R/windows/zzz.x64.R 2011-08-31 09:28:44 UTC (rev 211) @@ -0,0 +1,25 @@ +if (is.R()){ + + ".onLoad.x64" <- function(lib, pkg){ + ## TODO any need for these to be user specifiable? + options("BRugsTmpdir" = gsub("\\\\", "/", tempdir())) + options("BRugsExtFile" = paste(basename(tempfile()), ".bug", sep="")) + options(OpenBUGS = "C:/Program Files (x86)/OpenBUGS/OpenBUGS321") + options(OpenBUGSdoc = "C:/Program Files (x86)/OpenBUGS/OpenBUGS321") + options(OpenBUGSExamples = paste(options()$OpenBUGSdoc, "Examples", sep="/")) + + if(is.null(getOption("BRugsVerbose"))) + options("BRugsVerbose" = TRUE) + .initGlobals() + ob <- findOpenBUGS() + msg <- paste("Welcome to BRugs connected to OpenBUGS") + if (!is.na(ob$version)) + msg <- paste(msg, " version ", ob$version) + else msg <- paste(msg, " in directory ", ob$dir) + packageStartupMessage(msg) + } + + ".onUnload.x64" <- function(libpath){ + } + +} Added: trunk/BRugs/R/windows/zzz.x64.R.in =================================================================== --- trunk/BRugs/R/windows/zzz.x64.R.in (rev 0) +++ trunk/BRugs/R/windows/zzz.x64.R.in 2011-08-31 09:28:44 UTC (rev 211) @@ -0,0 +1,25 @@ +if (is.R()){ + + ".onLoad" <- function(lib, pkg){ + ## TODO any need for these to be user specifiable? + options("BRugsTmpdir" = gsub("\\\\", "/", tempdir())) + options("BRugsExtFile" = paste(basename(tempfile()), ".bug", sep="")) + options(OpenBUGS = "@OPENBUGS@") + options(OpenBUGSdoc = "@OPENBUGSDOC@") + options(OpenBUGSExamples = paste(options()$OpenBUGSdoc, "Examples", sep="/")) + + if(is.null(getOption("BRugsVerbose"))) + options("BRugsVerbose" = TRUE) + .initGlobals() + ob <- findOpenBUGS() + msg <- paste("Welcome to BRugs connected to OpenBUGS") + if (!is.na(ob$version)) + msg <- paste(msg, " version ", ob$version) + else msg <- paste(msg, " in directory ", ob$dir) + packageStartupMessage(msg) + } + + ".onUnload" <- function(libpath){ + } + +} Modified: trunk/BRugs/configure =================================================================== --- trunk/BRugs/configure 2011-08-30 21:57:45 UTC (rev 210) +++ trunk/BRugs/configure 2011-08-31 09:28:44 UTC (rev 211) @@ -556,6 +556,7 @@ ac_default_prefix=/usr/local ac_subst_vars='LTLIBOBJS LIBOBJS +DYNLIBEXT OPENBUGSDOC OPENBUGS OBJEXT @@ -2726,6 +2727,14 @@ 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;} @@ -2736,16 +2745,12 @@ OPENBUGSDOC=${OPENBUGS}/share/doc/openbugs-${VERSION} 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.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 +OPENBUGS=${OPENBUGS}/lib +DYNLIBEXT="so" + ac_config_files="$ac_config_files src/Makevars" cat >confcache <<\_ACEOF Modified: trunk/BRugs/configure.ac =================================================================== --- trunk/BRugs/configure.ac 2011-08-30 21:57:45 UTC (rev 210) +++ trunk/BRugs/configure.ac 2011-08-31 09:28:44 UTC (rev 211) @@ -59,7 +59,11 @@ OPENBUGSDOC=${OPENBUGS}/share/doc/openbugs-${VERSION} fi +OPENBUGS=${OPENBUGS}/lib +DYNLIBEXT="so" + AC_SUBST(OPENBUGS) AC_SUBST(OPENBUGSDOC) +AC_SUBST(DYNLIBEXT) AC_OUTPUT(src/Makevars) AC_OUTPUT(R/unix/zzz.R) Modified: trunk/BRugs/configure.win =================================================================== --- trunk/BRugs/configure.win 2011-08-30 21:57:45 UTC (rev 210) +++ trunk/BRugs/configure.win 2011-08-31 09:28:44 UTC (rev 211) @@ -0,0 +1,13 @@ +## Configure script only needed for 64 bit Windows, where BRugs calls +## the 32-bit OpenBUGS library via a helper application. First find +## the location of the OpenBUGS installation. + +OPENBUGS=`"${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" configure.win.R` + +## Install the OpenBUGS DLL into the package. There is no Windows +## equivalent of $rpath for adding to the dynamic link path, therefore +## the DLL is installed in the same directory as the helper +## executable. + +OPENBUGSLIB="$OPENBUGS/libOpenBUGS.dll" +cp "$OPENBUGSLIB" exec Added: trunk/BRugs/configure.win.R =================================================================== --- trunk/BRugs/configure.win.R (rev 0) +++ trunk/BRugs/configure.win.R 2011-08-31 09:28:44 UTC (rev 211) @@ -0,0 +1,20 @@ +## Find OpenBUGS installation location +source("R/windows/findOpenBUGS.R") +OPENBUGS <- findOpenBUGS()$dir +OPENBUGS <- gsub("\\\\","/",OPENBUGS) + +dummy <- file.copy("src/Makevars.in","src/Makefile.win", overwrite=TRUE) +x <- readLines("src/Makefile.win") +x <- gsub("@OPENBUGS@", dQuote(OPENBUGS), x, fixed=TRUE) +x <- gsub("@DYNLIBEXT@", "dll", x, fixed=TRUE) +writeLines(x, "src/Makefile.win") + +dummy <- file.copy("R/windows/zzz.x64.R.in","R/windows/zzz.x64.R", overwrite=TRUE) +x <- readLines("R/windows/zzz.x64.R") +x <- gsub("@OPENBUGS@", OPENBUGS, x, fixed=TRUE) +x <- gsub("@OPENBUGSDOC@", OPENBUGS, x, fixed=TRUE) +x <- gsub("\".onLoad\"[[:space:]]*<-[[:space:]]*function", "\".onLoad.x64\" <- function", x) +x <- gsub("\".onUnload\"[[:space:]]*<-[[:space:]]*function", "\".onUnload.x64\" <- function", x) +writeLines(x, "R/windows/zzz.x64.R") + +cat(OPENBUGS) Property changes on: trunk/BRugs/exec ___________________________________________________________________ Added: svn:ignore + BugsHelper Modified: trunk/BRugs/man/BRugs.Rd =================================================================== --- trunk/BRugs/man/BRugs.Rd 2011-08-30 21:57:45 UTC (rev 210) +++ trunk/BRugs/man/BRugs.Rd 2011-08-31 09:28:44 UTC (rev 211) @@ -35,6 +35,15 @@ with types of model that are currently not featured. If there is a problem, BRugs might just crash, which is not very good, but it might well carry on and produce answers that are wrong, which is even worse. Please let us know of any successes or failures. + + If BRugs does cause R to crash, it is advised to run the model from + 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} + + for suggestions for how to interpret these problematic error + messages. } %\references{} \seealso{\code{\link{help.WinBUGS}} (which currently is called from \code{help.BRugs}) and the meta function \code{\link{BRugsFit}}} Property changes on: trunk/BRugs/src ___________________________________________________________________ Added: svn:ignore + BRugs.dll Makevars Makevars.win Modified: trunk/BRugs/src/BugsHelper.c =================================================================== --- trunk/BRugs/src/BugsHelper.c 2011-08-30 21:57:45 UTC (rev 210) +++ trunk/BRugs/src/BugsHelper.c 2011-08-31 09:28:44 UTC (rev 211) @@ -1,68 +1,77 @@ /* BugsHelper - Perform one or more OpenBUGS API commands as specified in the command line arguments. -ARGUMENTS (not named) +ARGUMENTS (not named) argv[1]: Full path to temporary directory containing the buffer file for messages from the main API commands, and any input and output corresponding to the commands. - + argv[2]: Full path to temporary directory containing the buffer file for messages from the Internalize and Externalize commands. We do not - want these to overwrite the main buffer. - + want these to overwrite the main buffer. + argv[3]: Name of the file used to store the externalized model - state. This will be saved in the directory specified in argv[1]. - - The remaining arguments argv[4], argv[5], ... specify any number of - calls to OpenBUGS API functions. These are given in the order: - - cmd, cmdtype, cmd, cmdtype, ... - + state. This will be saved in the directory specified in argv[1]. + + argv[4]: Name of the command file, which contains a list of + calls to OpenBUGS API functions and the types of each call. + These are given on alternate lines of this file, in the order: + + cmd, cmdtype, cmd, cmdtype, ... + where "cmd" is an OpenBUGS API command, and "cmdtype" is an integer specifying the API function being called. Currently allowed values of "cmdtype" are - - 0 : if "cmd" is a call to the "CmdInterpreter" API function + + 0 : if "cmd" is a call to the "CmdInterpreter" API function 1 : if "cmd" is a call to the "Integer" API function 2 : if "cmd" is a call to the "CharArray" API function 3 : if "cmd" is a call to the "RealArray" API function - + 4 : if "cmd" is a call to "BugsCmd" (currently unused in BRugs, and not tested) -INPUT AND OUTPUT + argv[5]: Number of commands contained in the command file. +INPUT AND OUTPUT + Some OpenBUGS commands require input or produce output. The input and output for the Nth command given in the call to BugsHelper are stored in files called inputN.txt and outputN.txt, and are saved in the directory specified in argv[1]. - -EXAMPLE +EXAMPLE + The following command checks a BUGS model file stored in the file /path/to/Examples/Ratsmodel.txt and then loads a data file from /path/to/Examples/Ratsdata.txt. Temporary files are stored in subdirectories of /tmp. - + "BugsEmbed.SetFilePath('/scratch/chris/lib/R/BRugs/OpenBUGS/Examples/Ratsdata.txt');BugsEmbed.LoadDataGuard;BugsEmbed.LoadData" 0 - + /path/to/BugsHelper "/tmp/RtmpaRQois" "/tmp/RtmpaRQois_trash" "file327b23c6.bug" "BugsEmbed.SetFilePath('/path/to/Examples/Ratsmodel.txt');BugsEmbed.ParseGuard;BugsEmbed.Parse" 0 "BugsEmbed.SetFilePath('/path/to/Examples/Ratsdata.txt');BugsEmbed.LoadDataGuard;BugsEmbed.LoadData" 0 - + +TODO + How to handle an OpenBUGS "trap"? If the library call terminates with a crash, then BugsHelper terminates with an error code of 1. + But this error code is also used for "unknown module" internal errors which are handled. How to distinguish? + + AUTHOR - Chris Jackson <chr...@mr...> + Chris Jackson <chr...@mr...> - */ + */ #include <stdio.h> #include <string.h> #include <stdlib.h> #include <sys/stat.h> +#include <assert.h> -#define NODEBUG +#define NODEBUG -/* OpenBUGS API functions from libOpenBUGS.so */ +/* OpenBUGS API functions from libOpenBUGS.so */ int errno; extern void CLI (); extern void BugsCmd(char **command, int *len); @@ -82,7 +91,7 @@ char *fname; struct stat buf; FILE *ifp; - double tmp; + double tmp; fname = (char *) malloc(strlen(tmpdir) + 16); sprintf(fname, "%s/input%d.txt", tmpdir, cmdno); if (stat(fname, &buf) != -1) { @@ -178,7 +187,7 @@ } int do_Cmd(char *cmd) { - int length, res; + int length, res=0; length = strlen(cmd); #ifdef DEBUG printf("%s: %d\n", cmd, strlen(cmd)); @@ -188,7 +197,7 @@ } int do_Integer(char *cmd, char *tmpdir, int cmdno) { - int length, out, res; + int length, out, res=0; // doesn't need input -- assume only used for reading integers length = strlen(cmd); #ifdef DEBUG @@ -200,7 +209,7 @@ } int do_CharArray(char *cmd, char *tmpdir, int cmdno) { - int length, outlength, res; + int length, outlength, res=0; char *out; length = strlen(cmd); read_input_char(tmpdir, &out, &outlength, cmdno); @@ -214,7 +223,10 @@ } int do_RealArray(char *cmd, char *tmpdir, int cmdno) { - int length, outlength, res; + int length, outlength, res=0; +#ifdef DEBUG + int i; +#endif double *out; read_input_real(tmpdir, &out, &outlength, cmdno); length = strlen(cmd); @@ -229,6 +241,15 @@ return res; } +void do_BugsCmd(char *cmd) { + int length; + length = strlen(cmd); +#ifdef DEBUG + printf("%s: %d\n", cmd, strlen(cmd)); +#endif + BugsCmd(&cmd, &length); +} + int do_Internalize(char *tmpdir, char *extfile){ char *extpath, *int_cmd; struct stat buf; @@ -241,7 +262,7 @@ res = do_Cmd(int_cmd); free(int_cmd); } - else res = 10; /* TODO handle error */ + else res = 10; /* TODO handle error */ free(extpath); return res; } @@ -257,20 +278,39 @@ } int main(int argc, char **argv){ - int i, res, ncmds; +#ifdef DEBUG + printf("Entering BUGSHelper...\n"); +#endif + int i, res=0, ncmds, len; char *tmpdir = argv[1]; char *trashdir = argv[2]; char *extfile = argv[3]; - char *cmd, cmd_type; + char *cmdfile = argv[4]; + char *cmd, cmd_type; char *output_to_buffer_cmd = "BugsMappers.SetDest(2)"; + FILE *ifp; + struct stat buf; do_Cmd(output_to_buffer_cmd); do_TempDir(trashdir); do_Internalize(tmpdir, extfile); do_TempDir(tmpdir); - ncmds = (argc - 3) / 2; - for (i=0; i<ncmds; ++i) { - cmd = argv[4 + i*2]; - cmd_type = argv[5 + i*2][0]; + +// Commands and command type IDs are read from alternate lines of command file + ifp = fopen(cmdfile, "r"); + assert(stat(cmdfile, &buf) != -1); + len = buf.st_size; + cmd = (char *) malloc(len + 1); // command cannot be bigger than the command file + sscanf(argv[5], "%d", &ncmds); + + for (i=0; i<ncmds; ++i) { + len = 0; + while((cmd[len] = getc(ifp)) != '\n') { + ++len; + } + cmd[len] = '\0'; + cmd_type = getc(ifp); + assert(getc(ifp) == '\n'); + #ifdef DEBUG printf("%s, type %c of %d cmds\n", cmd, cmd_type, ncmds); #endif @@ -287,9 +327,13 @@ case '3': res = do_RealArray(cmd, tmpdir, i+1); break; + case '4': + do_BugsCmd(cmd); + break; } - if (res > 0) return res; + if (res > 0) return res; } + free(cmd); do_TempDir(trashdir); do_Externalize(tmpdir, extfile); return res; Modified: trunk/BRugs/src/Makefile.win =================================================================== --- trunk/BRugs/src/Makefile.win 2011-08-30 21:57:45 UTC (rev 210) +++ trunk/BRugs/src/Makefile.win 2011-08-31 09:28:44 UTC (rev 211) @@ -1,2 +1,6 @@ -all: - +BUGS_LIBS = "C:/Program Files (x86)/OpenBUGS/OpenBUGS321"/libOpenBUGS.dll +BUGS_LDFLAGS = -m32 -Wl,-rpath="C:/Program Files (x86)/OpenBUGS/OpenBUGS321" + +BugsHelper: + mkdir -p ../exec + $(CC) $(CFLAGS) $(LDFLAGS) $(BUGS_LDFLAGS) BugsHelper.c $(BUGS_LIBS) -o ../exec/BugsHelper Modified: trunk/BRugs/src/Makevars.in =================================================================== --- trunk/BRugs/src/Makevars.in 2011-08-30 21:57:45 UTC (rev 210) +++ trunk/BRugs/src/Makevars.in 2011-08-31 09:28:44 UTC (rev 211) @@ -1,5 +1,5 @@ -BUGS_LIBS = @OPENBUGS@/lib/libOpenBUGS.so -BUGS_LDFLAGS = -m32 -Wl,-rpath=@OPENBUGS@/lib +BUGS_LIBS = @OPENBUGS@/libOpenBUGS.@DYNLIBEXT@ +BUGS_LDFLAGS = -m32 -Wl,-rpath=@OPENBUGS@ BugsHelper: mkdir -p ../exec Modified: trunk/BRugs/tests/functions.R =================================================================== --- trunk/BRugs/tests/functions.R 2011-08-30 21:57:45 UTC (rev 210) +++ trunk/BRugs/tests/functions.R 2011-08-31 09:28:44 UTC (rev 211) @@ -123,8 +123,8 @@ ## Info functions stopifnot(infoNodeMethods("alpha")[,"Type"] == "UpdaterNormal.StdUpdater") stopifnot(infoNodeTypes("alpha")[1,"Type"]=="GraphNormal.Node") -stopifnot(infoUpdatersbyName()["alpha.c","Type"]=="conjugatenormalupdater") -stopifnot(infoUpdatersbyDepth()["alpha.c","Type"]=="conjugatenormalupdater") +stopifnot(infoUpdatersbyName()["alpha.c","Type"]=="conjugate normal updater") +stopifnot(infoUpdatersbyDepth()["alpha.c","Type"]=="conjugate normal updater") mem <- infoMemory() stopifnot(is.numeric(mem) && mem > 0) stopifnot(any(infoModules()[,"Module"] == "Kernel")) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |