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: <chr...@us...> - 2011-08-30 21:57:51
|
Revision: 210 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=210&view=rev Author: chris-jackson Date: 2011-08-30 21:57:45 +0000 (Tue, 30 Aug 2011) Log Message: ----------- Alias for R "setwd" with same name as OpenBUGS script command. Added Paths: ----------- trunk/BRugs/R/model.setWD.R trunk/BRugs/man/model.setWD.Rd Added: trunk/BRugs/R/model.setWD.R =================================================================== --- trunk/BRugs/R/model.setWD.R (rev 0) +++ trunk/BRugs/R/model.setWD.R 2011-08-30 21:57:45 UTC (rev 210) @@ -0,0 +1,3 @@ +## Simple alias to mimic the OpenBUGS script command + +"modelSetWD" <- setwd Added: trunk/BRugs/man/model.setWD.Rd =================================================================== --- trunk/BRugs/man/model.setWD.Rd (rev 0) +++ trunk/BRugs/man/model.setWD.Rd 2011-08-30 21:57:45 UTC (rev 210) @@ -0,0 +1,15 @@ +\name{modelSetWD} +\alias{modelSetWD} +\title{Set working directory} +\description{Change the working directory} +\usage{ +modelSetWD(dir) +} +\arguments{ + \item{dir}{Directory to change to. A character string} +} +\details{ + Simply an alias for \code{\link{setwd}} from base R, provided + to mimic the OpenBUGS script function \code{modelSetWD}. +} +\keyword{interface} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2011-08-30 21:56:06
|
Revision: 209 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=209&view=rev Author: chris-jackson Date: 2011-08-30 21:56:00 +0000 (Tue, 30 Aug 2011) Log Message: ----------- More detail and bugfixes for updater methods and other internal OpenBUGS technicalities. Modified Paths: -------------- trunk/BRugs/R/info.updaters.R trunk/BRugs/man/info.updaters.Rd trunk/BRugs/man/model.factory.Rd trunk/BRugs/man/model.setAP.Rd Added Paths: ----------- trunk/BRugs/R/model.getRN.R Modified: trunk/BRugs/R/info.updaters.R =================================================================== --- trunk/BRugs/R/info.updaters.R 2011-08-26 16:22:56 UTC (rev 208) +++ trunk/BRugs/R/info.updaters.R 2011-08-30 21:56:00 UTC (rev 209) @@ -1,28 +1,44 @@ -## display updaters sorted by node name +## display updaters sorted by node name infoUpdatersbyName <- function() { command <- "BugsEmbed.NotCompiledGuard; BugsEmbed.UpdatersByName" .CmdInterpreter(command) + buffer <- file.path(tempdir(), "buffer.txt") + if (readLines(buffer)[1]=="BugsCmds:NotCompiled") + stop("Model not compiled") buffer <- file.path(tempdir(), "Updater types.txt") result <- read.fwf(buffer, c(25, 50, 10, 10), skip = 1, as.is=TRUE, row.names=1, col.names=c("Node","Type", "Size","Depth")) - for (i in 1:2) - result[,i] <- gsub(" ", "", result[,i]) - rownames(result) <- gsub(" ", "", rownames(result)) + ## strip leading and trailing spaces + for (i in 1:2) { + result[,i] <- gsub("^ +", "\\1", result[,i]) + result[,i] <- gsub(" +$", "\\1", result[,i]) + } + rownames(result) <- gsub("^ +", "", rownames(result)) + rownames(result) <- gsub(" +$", "", rownames(result)) + unlink(buffer) result } -## display updaters sorted by node depth in graph +## display updaters sorted by node depth in graph infoUpdatersbyDepth <- function() { command <- "BugsEmbed.NotCompiledGuard; BugsEmbed.UpdatersByDepth" .CmdInterpreter(command) + buffer <- file.path(tempdir(), "buffer.txt") + if (readLines(buffer)[1]=="BugsCmds:NotCompiled") + stop("Model not compiled") buffer <- file.path(tempdir(), "Updater types.txt") result <- read.fwf(buffer, c(25, 50, 10, 10), skip = 1, as.is=TRUE, row.names=1, col.names=c("Node","Type", "Size","Depth")) - for (i in 1:2) - result[,i] <- gsub(" ", "", result[,i]) - rownames(result) <- gsub(" ", "", rownames(result)) + ## strip leading and trailing spaces + for (i in 1:2) { + result[,i] <- gsub("^ +", "\\1", result[,i]) + result[,i] <- gsub(" +$", "\\1", result[,i]) + } + rownames(result) <- gsub("^ +", "", rownames(result)) + rownames(result) <- gsub(" +$", "", rownames(result)) + unlink(buffer) result } Added: trunk/BRugs/R/model.getRN.R =================================================================== --- trunk/BRugs/R/model.getRN.R (rev 0) +++ trunk/BRugs/R/model.getRN.R 2011-08-30 21:56:00 UTC (rev 209) @@ -0,0 +1,7 @@ +"modelGetRN" <- +function() +# Get the seed of random number generator +{ + command <- "BugsEmbed.preSet" + .Integer(command) +} Modified: trunk/BRugs/man/info.updaters.Rd =================================================================== --- trunk/BRugs/man/info.updaters.Rd 2011-08-26 16:22:56 UTC (rev 208) +++ trunk/BRugs/man/info.updaters.Rd 2011-08-30 21:56:00 UTC (rev 209) @@ -8,8 +8,8 @@ infoUpdatersbyDepth() } \value{ - A data frame listing the MCMC updating algorithms used for each - stochastic node in the model. + A data frame listing the MCMC updating algorithms chosen for each + stochastic node in the model after the model has been compiled. For block updating algorithms, the first component in the block is shown followed by the other components of the block in angle brackets. Modified: trunk/BRugs/man/model.factory.Rd =================================================================== --- trunk/BRugs/man/model.factory.Rd 2011-08-26 16:22:56 UTC (rev 208) +++ trunk/BRugs/man/model.factory.Rd 2011-08-30 21:56:00 UTC (rev 209) @@ -2,15 +2,31 @@ \alias{modelEnable} \alias{modelDisable} \title{Enable and disable factories to create updaters} -\description{These functions enable and disable factories that create updaters.} +\description{These functions enable and disable factories that create + updaters. Currently only supported on Windows, not Linux. + Linux support should be available in the next OpenBUGS release after + version 3.2.1.} \usage{ modelEnable(factory) modelDisable(factory) } \arguments{ - \item{factory}{Character (length 1) name of the factory to be disabled/enabled.} + \item{factory}{Character (length 1) name of the factory to be + disabled/enabled, for example \code{"conjugate gamma"}. See + + \url{http://www.openbugs.info/Manuals/ModelMenu.html#Updateroptions} + + for more information. A list of the currently-used updaters + in a compiled model is given by \code{\link{infoUpdatersbyName}} or + \code{\link{infoUpdatersbyDepth}}. + + After enabling or disabling an updater, the model must be compiled + or re-compiled. + } } +\examples{\dontrun{ +modelDisable("conjugate gamma") +}} \seealso{\code{\link{BRugs}}, \code{\link{help.WinBUGS}}} \keyword{interface} \concept{factory} - Modified: trunk/BRugs/man/model.setAP.Rd =================================================================== --- trunk/BRugs/man/model.setAP.Rd 2011-08-26 16:22:56 UTC (rev 208) +++ trunk/BRugs/man/model.setAP.Rd 2011-08-30 21:56:00 UTC (rev 209) @@ -3,7 +3,8 @@ \alias{modelSetIts} \alias{modelSetOR} \title{Changing settings of updating algorithms} -\description{These functions change adaptivePhase, iterations, and overRelaxation settings.} +\description{These functions change adaptive phase, iterations, and + overRelaxation settings. Currently only supported on Windows, not Linux.} \usage{ modelSetAP(factoryName, adaptivePhase) modelSetIts(factoryName, iterations) @@ -12,7 +13,7 @@ \arguments{ \item{factoryName}{String defining which particular MCMC updating algorithm is to be tuned. Technically this string is the type name of the factory object used to create the updater, -for example \sQuote{UpdaterMetnormal.Factory} for the random walk metropolis sampler.} +for example \sQuote{UpdaterMetnormal.Factory} for the random walk Metropolis sampler.} \item{adaptivePhase}{length of the updater's adaptive phase} \item{iterations}{number of times an iterative algorithm is run before a failure is reported} \item{overRelaxation}{amount of over relaxation the updater uses} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2011-08-26 16:23:02
|
Revision: 208 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=208&view=rev Author: ligges Date: 2011-08-26 16:22:56 +0000 (Fri, 26 Aug 2011) Log Message: ----------- use validateInstallOpenBUGS as test cases and adapt/workaround for running on 64-bit Windows with OpenBUGS installed in a path containing "()" (where OpenBUGS cannot read files from) Modified Paths: -------------- trunk/R2OpenBUGS/R/validateInstallOpenBUGS.R trunk/R2OpenBUGS/man/validateInstallOpenBUGS.Rd Added Paths: ----------- trunk/R2OpenBUGS/tests/ trunk/R2OpenBUGS/tests/R2OpenBUGS.R trunk/R2OpenBUGS/tests/R2OpenBUGS.Rout.save Modified: trunk/R2OpenBUGS/R/validateInstallOpenBUGS.R =================================================================== --- trunk/R2OpenBUGS/R/validateInstallOpenBUGS.R 2011-08-26 16:21:28 UTC (rev 207) +++ trunk/R2OpenBUGS/R/validateInstallOpenBUGS.R 2011-08-26 16:22:56 UTC (rev 208) @@ -1,6 +1,6 @@ -validateInstallOpenBUGS<-function( +validateInstallOpenBUGS <- function( OpenBUGS.pgm=NULL, - OpenBUGS.examples=file.path(dirname(OpenBUGS.pgm),'Examples'), + OpenBUGS.examples=NULL, useWINE=FALSE, WINE=NULL, newWINE=TRUE, WINEPATH=NULL ) @@ -9,11 +9,15 @@ if(is.null(OpenBUGS.pgm)) - OpenBUGS.pgm <- file.path(findOpenBUGS(), "OpenBUGS.exe", fsep="\\") + OpenBUGS.pgm <- file.path(findOpenBUGS(), "OpenBUGS.exe") -if(!file.exists(OpenBUGS.Examples)) - stop("Cannot find Examples in ", OpenBUGS.Examples) +if(is.null(OpenBUGS.examples)) + OpenBUGS.examples <- file.path(dirname(OpenBUGS.pgm), 'Examples') +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", @@ -37,11 +41,9 @@ ) test.modelfile <- paste(test.models,"model.txt",sep="") -test.modelfile <- file.path(OpenBUGS.examples,test.modelfile) test.datafile <- paste(test.models,"data.txt",sep="") -test.datafile <- file.path(OpenBUGS.examples,test.datafile) test.inits <- paste(test.models,"inits.txt",sep="") -test.inits <- file.path(OpenBUGS.examples,test.inits) +test.pattern <- paste("^", test.models, ".*\\.txt$", sep="") ### Test for posterior means within 1 percent of previously saved values @@ -51,9 +53,11 @@ "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) + 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)$summary, 5) + n.burnin=5000, n.iter=20000, n.thin=1, n.chains=1, DIC=FALSE, working.directory=tempdir())$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/man/validateInstallOpenBUGS.Rd =================================================================== --- trunk/R2OpenBUGS/man/validateInstallOpenBUGS.Rd 2011-08-26 16:21:28 UTC (rev 207) +++ trunk/R2OpenBUGS/man/validateInstallOpenBUGS.Rd 2011-08-26 16:22:56 UTC (rev 208) @@ -9,7 +9,7 @@ \usage{ validateInstallOpenBUGS( OpenBUGS.pgm=NULL, - OpenBUGS.examples=file.path(dirname(OpenBUGS.pgm),'Examples'), + OpenBUGS.examples=NULL, useWINE=FALSE, WINE=NULL, newWINE=TRUE, WINEPATH=NULL ) @@ -18,7 +18,7 @@ \arguments{ \item{OpenBUGS.pgm}{See \code{\link{bugs}}.} \item{OpenBUGS.examples}{A directory with the OpenBUGS examples (text versions of - model, data, and inits). There is currently no default appropriate for linux.} + model, data, and inits). If \code{NULL} we try to derive from \code{OpenBUGS.pgm}.} \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}).} @@ -46,7 +46,7 @@ Windows path style (e.g. \dQuote{c:/Program Files/OpenBUGS/}) or native (Unix) style (e.g. \dQuote{/path/to/wine/folder/dosdevices/c:/Program - Files/OpenBUGS/OpenBUGS311/OpenBUGS.exe}). + Files/OpenBUGS/OpenBUGS321/OpenBUGS.exe}). } Property changes on: trunk/R2OpenBUGS/tests ___________________________________________________________________ Added: bugtraq:number + true Added: trunk/R2OpenBUGS/tests/R2OpenBUGS.R =================================================================== --- trunk/R2OpenBUGS/tests/R2OpenBUGS.R (rev 0) +++ trunk/R2OpenBUGS/tests/R2OpenBUGS.R 2011-08-26 16:22:56 UTC (rev 208) @@ -0,0 +1,2 @@ +library("R2OpenBUGS") +validateInstallOpenBUGS() Added: trunk/R2OpenBUGS/tests/R2OpenBUGS.Rout.save =================================================================== --- trunk/R2OpenBUGS/tests/R2OpenBUGS.Rout.save (rev 0) +++ trunk/R2OpenBUGS/tests/R2OpenBUGS.Rout.save 2011-08-26 16:22:56 UTC (rev 208) @@ -0,0 +1,56 @@ + +R Under development (unstable) (2011-08-25 r56795) +Copyright (C) 2011 The R Foundation for Statistical Computing +ISBN 3-900051-07-0 +Platform: i386-pc-mingw32/i386 (32-bit) + +R is free software and comes with ABSOLUTELY NO WARRANTY. +You are welcome to redistribute it under certain conditions. +Type 'license()' or 'licence()' for distribution details. + +R is a collaborative project with many contributors. +Type 'contributors()' for more information and +'citation()' on how to cite R or R packages in publications. + +Type 'demo()' for some demos, 'help()' for on-line help, or +'help.start()' for an HTML browser interface to help. +Type 'q()' to quit R. + +> library("R2OpenBUGS") +Loading required package: coda +Loading required package: lattice +> validateInstallOpenBUGS() +The version of OpenBUGS on your computer is being compared to validation +results created using OpenBUGS version 3.2.1 + +Results matched for example Air + +Results matched for example Asia + +Results matched for example Beetles + +Results matched for example BiRats + +Results matched for example Camel + +Results matched for example Dugongs + +Results matched for example Dyes + +Results matched for example Equiv + +Results matched for example Eyes + +Results matched for example Line + +Results matched for example OtreesMVN + +Results matched for example Rats + +Results matched for example Stacks + +Results matched for example Surgical + +Results matched for example Surgicalrand + +> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2011-08-26 16:21:34
|
Revision: 207 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=207&view=rev Author: ligges Date: 2011-08-26 16:21:28 +0000 (Fri, 26 Aug 2011) Log Message: ----------- make sure it works on Linux Modified Paths: -------------- trunk/R2OpenBUGS/R/bugs.R Modified: trunk/R2OpenBUGS/R/bugs.R =================================================================== --- trunk/R2OpenBUGS/R/bugs.R 2011-08-26 15:54:08 UTC (rev 206) +++ trunk/R2OpenBUGS/R/bugs.R 2011-08-26 16:21:28 UTC (rev 207) @@ -16,7 +16,7 @@ } if(is.null(OpenBUGS.pgm)) - OpenBUGS.pgm <- file.path(findOpenBUGS(), "OpenBUGS.exe", fsep="\\") + OpenBUGS.pgm <- file.path(findOpenBUGS(), "OpenBUGS.exe") if((.Platform$OS.type == "windows" | useWINE) & !file.exists(OpenBUGS.pgm)) stop("OpenBUGS executable was not found" ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2011-08-26 15:54:14
|
Revision: 206 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=206&view=rev Author: ligges Date: 2011-08-26 15:54:08 +0000 (Fri, 26 Aug 2011) Log Message: ----------- utils:::compareVersion was not imported Modified Paths: -------------- trunk/BRugs/NAMESPACE Modified: trunk/BRugs/NAMESPACE =================================================================== --- trunk/BRugs/NAMESPACE 2011-08-26 15:53:26 UTC (rev 205) +++ trunk/BRugs/NAMESPACE 2011-08-26 15:54:08 UTC (rev 206) @@ -1,4 +1,5 @@ importFrom(coda, mcmc, mcmc.list) +importFrom(utils, compareVersion) export(BRugsFit, bugsData, bugsInits, buildMCMC, dicClear, dicSet, dicStats, getNumChains, help.BRugs, help.WinBUGS, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2011-08-26 15:53:32
|
Revision: 205 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=205&view=rev Author: ligges Date: 2011-08-26 15:53:26 +0000 (Fri, 26 Aug 2011) Log Message: ----------- copy&paste error Modified Paths: -------------- trunk/R2OpenBUGS/R/findOpenBUGS.R Modified: trunk/R2OpenBUGS/R/findOpenBUGS.R =================================================================== --- trunk/R2OpenBUGS/R/findOpenBUGS.R 2011-08-26 15:52:13 UTC (rev 204) +++ trunk/R2OpenBUGS/R/findOpenBUGS.R 2011-08-26 15:53:26 UTC (rev 205) @@ -10,7 +10,7 @@ if(.Platform$OS.type != "windows") return(NA) - deps <- utils:::packageDescription("BRugs", fields="SystemRequirements") + deps <- utils:::packageDescription("R2OpenBUGS", fields="SystemRequirements") version.req <- gsub(".*OpenBUGS ?\\(>= ?(.+)\\).*", "\\1", deps) ob.reg <- try(utils:::readRegistry("Software\\OpenBUGS", "HLM", view = "32-bit"), silent = TRUE) if (inherits(ob.reg, "try-error")) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2011-08-26 15:24:58
|
Revision: 203 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=203&view=rev Author: ligges Date: 2011-08-26 15:24:52 +0000 (Fri, 26 Aug 2011) Log Message: ----------- improved auto-detect OpenBUGS routines (outsourced into non exported function findOpenBUGS.R()) Modified Paths: -------------- trunk/R2OpenBUGS/R/bugs.R trunk/R2OpenBUGS/R/validateInstallOpenBUGS.R trunk/R2OpenBUGS/man/bugs.Rd trunk/R2OpenBUGS/man/validateInstallOpenBUGS.Rd Added Paths: ----------- trunk/R2OpenBUGS/R/findOpenBUGS.R Modified: trunk/R2OpenBUGS/R/bugs.R =================================================================== --- trunk/R2OpenBUGS/R/bugs.R 2011-08-26 15:23:52 UTC (rev 202) +++ trunk/R2OpenBUGS/R/bugs.R 2011-08-26 15:24:52 UTC (rev 203) @@ -3,40 +3,33 @@ 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=ifelse(.Platform$OS.type == "windows" | useWINE==TRUE, - paste("C:/Program Files/OpenBUGS/OpenBUGS", - version,"/OpenBUGS.exe",sep=""),"OpenBUGS"), - version='321', - 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 (missing(OpenBUGS.pgm) && - !is.null(bugs.pgm <- getOption("R2OpenBUGS.pgm"))) { # requested by Jouni Kerman - OpenBUGS.pgm<- bugs.pgm - } + if(is.null(OpenBUGS.pgm)) + OpenBUGS.pgm <- file.path(findOpenBUGS(), "OpenBUGS.exe", fsep="\\") - if((.Platform$OS.type == "windows" | useWINE) & !file.exists(OpenBUGS.pgm)) - stop("OpenBUGS executable was not found" ) + if((.Platform$OS.type == "windows" | useWINE) & !file.exists(OpenBUGS.pgm)) + stop("OpenBUGS executable was not found" ) ## 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) + OpenBUGS.pgm <- win2native(OpenBUGS.pgm, newWINE=newWINE, WINEPATH=WINEPATH) } + if(! bugs.seed %in% 1:14) + stop("OpenBUGS seed must be integer in 1:14") - if(! bugs.seed %in% c(1:14))stop("OpenBUGS seed must be integer in 1-14") - if(!is.function(model.file) && length(grep("\\.bug", tolower(model.file))))stop("model.file must be renamed with .txt rather than .bug") @@ -172,6 +165,3 @@ class(sims) <- "bugs" sims } - - - Added: trunk/R2OpenBUGS/R/findOpenBUGS.R =================================================================== --- trunk/R2OpenBUGS/R/findOpenBUGS.R (rev 0) +++ trunk/R2OpenBUGS/R/findOpenBUGS.R 2011-08-26 15:24:52 UTC (rev 203) @@ -0,0 +1,33 @@ +findOpenBUGS <- function(){ + dir <- Sys.getenv("OpenBUGS_PATH") + if(nchar(dir)) + return(dir) + + dir <- getOption("R2OpenBUGS.pgm") + if(!is.null(dir)) + return(dir) + + if(.Platform$OS.type != "windows") + return(NA) + + 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")) + return(NA) + + 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(max(version.inst), version.req) < 0) + warning("Found OpenBUGS version ", version.inst, ".\n Requires ", version.req, " or greater.") + + utils:::readRegistry(paste("Software", "OpenBUGS", rnames, sep="\\"), "HLM", view = "32-bit")[["InstallPath"]] +} Modified: trunk/R2OpenBUGS/R/validateInstallOpenBUGS.R =================================================================== --- trunk/R2OpenBUGS/R/validateInstallOpenBUGS.R 2011-08-26 15:23:52 UTC (rev 202) +++ trunk/R2OpenBUGS/R/validateInstallOpenBUGS.R 2011-08-26 15:24:52 UTC (rev 203) @@ -1,8 +1,5 @@ validateInstallOpenBUGS<-function( - OpenBUGS.pgm=ifelse(.Platform$OS.type == "windows" | useWINE==TRUE, - paste("C:/Program Files/OpenBUGS/OpenBUGS", - version,"/OpenBUGS.exe",sep=""),"OpenBUGS"), - version='321', + OpenBUGS.pgm=NULL, OpenBUGS.examples=file.path(dirname(OpenBUGS.pgm),'Examples'), useWINE=FALSE, WINE=NULL, newWINE=TRUE, WINEPATH=NULL @@ -10,6 +7,13 @@ { ## Selected examples which take a few seconds in total to run + +if(is.null(OpenBUGS.pgm)) + OpenBUGS.pgm <- file.path(findOpenBUGS(), "OpenBUGS.exe", fsep="\\") + +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", @@ -32,32 +36,31 @@ Surgicalrand = c("p","pop.mean", "sigma") ) -test.modelfile = paste(test.models,"model.txt",sep="") -test.modelfile<-file.path(OpenBUGS.examples,test.modelfile) -test.datafile = paste(test.models,"data.txt",sep="") -test.datafile<-file.path(OpenBUGS.examples,test.datafile) -test.inits = paste(test.models,"inits.txt",sep="") -test.inits<-file.path(OpenBUGS.examples,test.inits) +test.modelfile <- paste(test.models,"model.txt",sep="") +test.modelfile <- file.path(OpenBUGS.examples,test.modelfile) +test.datafile <- paste(test.models,"data.txt",sep="") +test.datafile <- file.path(OpenBUGS.examples,test.datafile) +test.inits <- paste(test.models,"inits.txt",sep="") +test.inits <- file.path(OpenBUGS.examples,test.inits) ### Test for posterior means within 1 percent of previously saved values -res.true<-dget(file=system.file("validateInstallOpenBUGS/validOpenBUGSResults.R",package="R2OpenBUGS") ) +res.true <- dget(file = system.file("validateInstallOpenBUGS/validOpenBUGSResults.R", package="R2OpenBUGS") ) -cat("The version of OpenBUGS on your computer is being compared to validation\n", +message("The version of OpenBUGS on your computer is being compared to validation\n", "results created using OpenBUGS version 3.2.1\n") for (i in seq(along=test.models)) { - fit<-round(bugs(data=test.datafile[i], inits=test.inits[i], + 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)$summary,5) - if(isTRUE(all.equal(fit,res.true[[i]],tol=1e-2))){ - cat(paste('Results matched for example',test.models[[i]],'\n',sep=' ')) + n.burnin=5000, n.iter=20000, n.thin=1, n.chains=1, DIC=FALSE)$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{ - cat(paste('Results did not match for example',test.models[[i]],'\n',sep=' ')) + message(paste('Results did not match for example',test.models[[i]], '\n', sep=' ')) } flush.console() } - return(invisible()) + invisible() } - Modified: trunk/R2OpenBUGS/man/bugs.Rd =================================================================== --- trunk/R2OpenBUGS/man/bugs.Rd 2011-08-26 15:23:52 UTC (rev 202) +++ trunk/R2OpenBUGS/man/bugs.Rd 2011-08-26 15:24:52 UTC (rev 203) @@ -11,11 +11,7 @@ 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=ifelse(.Platform$OS.type == "windows" | useWINE==TRUE, - paste("C:/Program Files/OpenBUGS/OpenBUGS", - version,"/OpenBUGS.exe",sep=""),"OpenBUGS"), - version='321', - 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), @@ -93,10 +89,11 @@ \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 the global option \code{R2OpenBUGS.bugs.directory} is not \code{NULL}, - it will be used as the default.} - \item{version}{The version of OpenBUGS to use. \code{version} is ignored - with linux execution or if \code{OpenBUGS.pgm} is specified.} + 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{working.directory}{sets working directory during execution of this function; \pkg{OpenBUGS}' in- and output will be stored in this directory; if \code{NULL}, a temporary working directory via @@ -108,7 +105,7 @@ \code{codaPkg=FALSE}.} \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}).} + rather than Windows paths (if not \code{NULL}).} \item{WINE}{Character, path to \file{wine} binary file, it is tried hard (by a guess and the utilities \code{which} and \code{locate}) to get the information automatically if not given.} @@ -259,7 +256,7 @@ parameters <- c("theta", "mu.theta", "sigma.theta") \dontrun{ -## You may need to edit "bugs.directory", +## You may need to specify "OpenBUGS.pgm" ## also you need write access in the working directory: schools.sim <- bugs(data, inits, parameters, model.file, n.chains=3, n.iter=5000) Modified: trunk/R2OpenBUGS/man/validateInstallOpenBUGS.Rd =================================================================== --- trunk/R2OpenBUGS/man/validateInstallOpenBUGS.Rd 2011-08-26 15:23:52 UTC (rev 202) +++ trunk/R2OpenBUGS/man/validateInstallOpenBUGS.Rd 2011-08-26 15:24:52 UTC (rev 203) @@ -8,10 +8,7 @@ \usage{ validateInstallOpenBUGS( - OpenBUGS.pgm=ifelse(.Platform$OS.type == "windows" | useWINE==TRUE, - paste("C:/Program Files/OpenBUGS/OpenBUGS", - version,"/OpenBUGS.exe",sep=""),"OpenBUGS"), - version='321', + OpenBUGS.pgm=NULL, OpenBUGS.examples=file.path(dirname(OpenBUGS.pgm),'Examples'), useWINE=FALSE, WINE=NULL, newWINE=TRUE, WINEPATH=NULL @@ -19,14 +16,7 @@ } \arguments{ - \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 the global option \code{R2OpenBUGS.bugs.directory} is not \code{NULL}, - it will be used as the default.} - \item{version}{The version of OpenBUGS to validate. \code{version} is ignored - with linux execution or if \code{OpenBUGS.pgm} is specified. The current - comparison results were created with OpenBUGS 3.2.1} + \item{OpenBUGS.pgm}{See \code{\link{bugs}}.} \item{OpenBUGS.examples}{A directory with the OpenBUGS examples (text versions of model, data, and inits). There is currently no default appropriate for linux.} \item{useWINE}{logical; attempt to use the Wine emulator to run This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2011-08-26 15:23:58
|
Revision: 202 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=202&view=rev Author: ligges Date: 2011-08-26 15:23:52 +0000 (Fri, 26 Aug 2011) Log Message: ----------- doc tweak Modified Paths: -------------- trunk/R2OpenBUGS/man/attach.all.Rd Modified: trunk/R2OpenBUGS/man/attach.all.Rd =================================================================== --- trunk/R2OpenBUGS/man/attach.all.Rd 2011-08-26 15:04:21 UTC (rev 201) +++ trunk/R2OpenBUGS/man/attach.all.Rd 2011-08-26 15:23:52 UTC (rev 202) @@ -77,8 +77,7 @@ } parameters <- c("theta", "mu.theta", "sigma.theta") \dontrun{ -## You may need to edit "bugs.directory", -## also you need write access in the working directory: +## See ?bugs if the following fails: schools.sim <- bugs(data, inits, parameters, model.file, n.chains = 3, n.iter = 1000, working.directory = NULL) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2011-08-26 15:04:27
|
Revision: 201 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=201&view=rev Author: ligges Date: 2011-08-26 15:04:21 +0000 (Fri, 26 Aug 2011) Log Message: ----------- new maintainer, R version dependency >= 2.11.0! Modified Paths: -------------- trunk/R2OpenBUGS/DESCRIPTION Modified: trunk/R2OpenBUGS/DESCRIPTION =================================================================== --- trunk/R2OpenBUGS/DESCRIPTION 2011-08-26 15:02:35 UTC (rev 200) +++ trunk/R2OpenBUGS/DESCRIPTION 2011-08-26 15:04:21 UTC (rev 201) @@ -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 / S-PLUS. -Depends: R (>= 2.10.1), coda (>= 0.11-0) -SystemRequirements: OpenBUGS >=3.2.1 -Maintainer: Uwe Ligges <li...@st...> +Depends: R (>= 2.11.0), coda (>= 0.11-0) +SystemRequirements: OpenBUGS (>= 3.2.1) +Maintainer: Neal Thomas <nea...@pf...> License: GPL-2 Dialect: R, S-PLUS This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2011-08-26 15:02:41
|
Revision: 200 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=200&view=rev Author: ligges Date: 2011-08-26 15:02:35 +0000 (Fri, 26 Aug 2011) Log Message: ----------- simplified and refined methods to compare and select versions Modified Paths: -------------- trunk/BRugs/R/windows/zzz.R Modified: trunk/BRugs/R/windows/zzz.R =================================================================== --- trunk/BRugs/R/windows/zzz.R 2011-08-26 14:17:59 UTC (rev 199) +++ trunk/BRugs/R/windows/zzz.R 2011-08-26 15:02:35 UTC (rev 200) @@ -7,8 +7,7 @@ dir <- Sys.getenv("OpenBUGS_PATH") if(!nchar(dir)){ deps <- utils:::packageDescription("BRugs", fields="SystemRequirements") - ver <- gsub(".*OpenBUGS ?\\(>= ?(.+)\\).*", "\\1", deps) - version.req <- as.numeric(paste(substr(ver, 1, 2), gsub("\\.","",substr(ver, 3, nchar(ver))), sep="")) + 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")) { @@ -17,17 +16,22 @@ } rnames <- names(ob.reg) ver <- gsub("OpenBUGS ", "", rnames) - veri <- gsub("(.+)e$","\\1", ver) - version.inst <- as.numeric(paste(substr(veri, 1, 2), gsub("\\.","",substr(veri, 3, nchar(veri))), sep="")) + version.inst <- gsub("(.+)e$","\\1", ver) - if (max(version.inst) < version.req) { + 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[which.max(version.inst)],sep="\\"), "HLM", view = "32-bit")$InstallPath + dir <- utils:::readRegistry(paste("Software","OpenBUGS",rnames,sep="\\"), "HLM", view = "32-bit")[["InstallPath"]] loadOpenBUGS(dir) - packageStartupMessage("Welcome to BRugs running on OpenBUGS version ", veri[which.max(version.inst)]) + 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")) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2011-08-26 14:18:05
|
Revision: 199 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=199&view=rev Author: ligges Date: 2011-08-26 14:17:59 +0000 (Fri, 26 Aug 2011) Log Message: ----------- stupid me: OpenBUGS_PATH seems to be more straightforward than than BRugs_PATH Modified Paths: -------------- trunk/BRugs/R/windows/zzz.R Modified: trunk/BRugs/R/windows/zzz.R =================================================================== --- trunk/BRugs/R/windows/zzz.R 2011-08-26 14:14:39 UTC (rev 198) +++ trunk/BRugs/R/windows/zzz.R 2011-08-26 14:17:59 UTC (rev 199) @@ -4,7 +4,7 @@ if(.Platform[["r_arch"]] != "i386"){ stop("BRugs only works for 32-bit R") } - dir <- Sys.getenv("BRUGS_PATH") + dir <- Sys.getenv("OpenBUGS_PATH") if(!nchar(dir)){ deps <- utils:::packageDescription("BRugs", fields="SystemRequirements") ver <- gsub(".*OpenBUGS ?\\(>= ?(.+)\\).*", "\\1", deps) @@ -12,7 +12,7 @@ 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 'BRUGS_PATH' in advance of loading 'BRugs' overwrites the path.\nSee ?loadOpenBUGS in order to load OpenBUGS manually.") + 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) @@ -21,7 +21,7 @@ version.inst <- as.numeric(paste(substr(veri, 1, 2), gsub("\\.","",substr(veri, 3, nchar(veri))), sep="")) if (max(version.inst) < version.req) { - warning("Found OpenBUGS version ", version.inst, ".\n Requires ", version.req, " or greater.\nSetting the environment variable 'BRUGS_PATH' in advance of loading 'BRugs' overwrites the path.\nSee ?loadOpenBUGS in order to load OpenBUGS manually.") + 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 @@ -30,7 +30,7 @@ packageStartupMessage("Welcome to BRugs running on OpenBUGS version ", veri[which.max(version.inst)]) } else { if(!file.exists(file.path(dir, "libOpenBUGS.dll"))){ - warning("Environment variable BRUGS_PATH found but cannot access ", file.path(dir, "libOpenBUGS.dll")) + warning("Environment variable OpenBUGS_PATH found but cannot access ", file.path(dir, "libOpenBUGS.dll")) return() } loadOpenBUGS(dir) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2011-08-26 14:14:45
|
Revision: 198 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=198&view=rev Author: ligges Date: 2011-08-26 14:14:39 +0000 (Fri, 26 Aug 2011) Log Message: ----------- get rid of hardcoded version number Modified Paths: -------------- trunk/BRugs/R/windows/zzz.R Modified: trunk/BRugs/R/windows/zzz.R =================================================================== --- trunk/BRugs/R/windows/zzz.R 2011-08-26 09:29:37 UTC (rev 197) +++ trunk/BRugs/R/windows/zzz.R 2011-08-26 14:14:39 UTC (rev 198) @@ -6,20 +6,22 @@ } dir <- Sys.getenv("BRUGS_PATH") if(!nchar(dir)){ + deps <- utils:::packageDescription("BRugs", fields="SystemRequirements") + ver <- gsub(".*OpenBUGS ?\\(>= ?(.+)\\).*", "\\1", deps) + version.req <- as.numeric(paste(substr(ver, 1, 2), gsub("\\.","",substr(ver, 3, nchar(ver))), sep="")) + ob.reg <- try(utils:::readRegistry("Software\\OpenBUGS", "HLM", view = "32-bit"), silent = TRUE) if (inherits(ob.reg, "try-error")) { - warning("OpenBUGS 3.2.1 or greater must be installed\n(if so, this indicates missing registry keys of OpenBUGS).\nSetting the environment variable 'BRUGS_PATH' in advance of loading 'BRugs' overwrites the path.\nSee ?loadOpenBUGS in order to load OpenBUGS manually.") + warning("OpenBUGS ", version.req, " or greater must be installed\n(if so, this indicates missing registry keys of OpenBUGS).\nSetting the environment variable 'BRUGS_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) veri <- gsub("(.+)e$","\\1", ver) version.inst <- as.numeric(paste(substr(veri, 1, 2), gsub("\\.","",substr(veri, 3, nchar(veri))), sep="")) - deps <- utils:::packageDescription("BRugs", fields="SystemRequirements") - ver <- gsub(".*OpenBUGS ?\\(>= ?(.+)\\).*", "\\1", deps) - version.req <- as.numeric(paste(substr(ver, 1, 2), gsub("\\.","",substr(ver, 3, nchar(ver))), sep="")) + if (max(version.inst) < version.req) { - warning("Found OpenBUGS version ", version.inst, ".\n Requires ", version.req, " or greater.") + warning("Found OpenBUGS version ", version.inst, ".\n Requires ", version.req, " or greater.\nSetting the environment variable 'BRUGS_PATH' in advance of loading 'BRugs' overwrites the path.\nSee ?loadOpenBUGS in order to load OpenBUGS manually.") return() } ## OpenBUGS installation location This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2011-08-26 09:29:46
|
Revision: 197 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=197&view=rev Author: ligges Date: 2011-08-26 09:29:37 +0000 (Fri, 26 Aug 2011) Log Message: ----------- 32- vs 64 bit Windows distinctions did not work prior to R-2.11.0 Modified Paths: -------------- trunk/BRugs/DESCRIPTION Modified: trunk/BRugs/DESCRIPTION =================================================================== --- trunk/BRugs/DESCRIPTION 2011-08-26 09:28:07 UTC (rev 196) +++ trunk/BRugs/DESCRIPTION 2011-08-26 09:29:37 UTC (rev 197) @@ -5,7 +5,7 @@ Author: OpenBUGS was developed by Andrew Thomas, Dave Lunn, David Spiegelhalter and Nicky Best. R interface developed by Uwe Ligges, Sibylle Sturtz, Andrew Gelman, Gregor Gorjanc and Chris Jackson. Linux port and most recent developments by Chris Jackson. Description: Fully-interactive R interface to the OpenBUGS software for Bayesian analysis using MCMC sampling Maintainer: Uwe Ligges <li...@st...> -Depends: R (>= 2.5.0), utils, coda +Depends: R (>= 2.11.0), utils, coda SystemRequirements: OpenBUGS (>= 3.2.1), hence ix86 Windows or Linux License: GPL-2 URL: http://www.openbugs.info/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2011-08-26 09:28:14
|
Revision: 196 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=196&view=rev Author: ligges Date: 2011-08-26 09:28:07 +0000 (Fri, 26 Aug 2011) Log Message: ----------- Archs in DESCRIPTION is to be added by the install processes, not in advance Modified Paths: -------------- trunk/BRugs/DESCRIPTION Modified: trunk/BRugs/DESCRIPTION =================================================================== --- trunk/BRugs/DESCRIPTION 2011-08-25 16:14:43 UTC (rev 195) +++ trunk/BRugs/DESCRIPTION 2011-08-26 09:28:07 UTC (rev 196) @@ -6,7 +6,6 @@ Description: Fully-interactive R interface to the OpenBUGS software for Bayesian analysis using MCMC sampling Maintainer: Uwe Ligges <li...@st...> Depends: R (>= 2.5.0), utils, coda -SystemRequirements: OpenBUGS (>= 3.2.1) -Archs: i386 +SystemRequirements: OpenBUGS (>= 3.2.1), hence ix86 Windows or Linux License: GPL-2 URL: http://www.openbugs.info/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2011-08-25 16:04:45
|
Revision: 194 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=194&view=rev Author: ligges Date: 2011-08-25 16:04:39 +0000 (Thu, 25 Aug 2011) Log Message: ----------- increase version number for further modifications Modified Paths: -------------- trunk/R2OpenBUGS/DESCRIPTION Modified: trunk/R2OpenBUGS/DESCRIPTION =================================================================== --- trunk/R2OpenBUGS/DESCRIPTION 2011-08-25 15:21:48 UTC (rev 193) +++ trunk/R2OpenBUGS/DESCRIPTION 2011-08-25 16:04:39 UTC (rev 194) @@ -1,7 +1,7 @@ Package: R2OpenBUGS Title: Running OpenBUGS from R / S-PLUS -Date: 2011-03-01 -Version: 3.2-1 +Date: 2011-08-25 +Version: 3.2-2 Author: originally written as R2WinBUGS by Andrew Gelman <ge...@st...>; changes and packaged by Sibylle Sturtz <st...@st...> and Uwe Ligges <li...@st...>. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2011-08-25 15:21:55
|
Revision: 193 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=193&view=rev Author: ligges Date: 2011-08-25 15:21:48 +0000 (Thu, 25 Aug 2011) Log Message: ----------- workaround for OpenBUGS-3.2.1 not being able to deal with "()" in dirnames/filenames while this is a default location under 64-bit Windows for the Examples files Modified Paths: -------------- trunk/BRugs/man/BRugs.Rd trunk/BRugs/man/BRugsFit.Rd trunk/BRugs/tests/BRugs.R trunk/BRugs/tests/BRugs.Rout.save trunk/BRugs/tests/examples.R trunk/BRugs/tests/examples.Rout.save trunk/BRugs/tests/functions.R trunk/BRugs/tests/functions.Rout.save Modified: trunk/BRugs/man/BRugs.Rd =================================================================== --- trunk/BRugs/man/BRugs.Rd 2011-08-25 15:20:34 UTC (rev 192) +++ trunk/BRugs/man/BRugs.Rd 2011-08-25 15:21:48 UTC (rev 193) @@ -43,9 +43,13 @@ ### Step by step example: ### library("BRugs") # loading BRugs -## Now setting the working directory to the examples' one: -oldwd <- setwd(options()$OpenBUGSExamples) +## Prepare the example files in a temporary directory +exfiles <- dir(options()$OpenBUGSExamples, pattern="^Rats.*txt$", full.names=TRUE) +ok <- file.copy(exfiles, tempdir()) +## Now setting the working directory to the temporary one: +oldwd <- setwd(tempdir()) + ## some usual steps (like clicking in WinBUGS): modelCheck("Ratsmodel.txt") # check model file modelData("Ratsdata.txt") # read data file Modified: trunk/BRugs/man/BRugsFit.Rd =================================================================== --- trunk/BRugs/man/BRugsFit.Rd 2011-08-25 15:20:34 UTC (rev 192) +++ trunk/BRugs/man/BRugsFit.Rd 2011-08-25 15:21:48 UTC (rev 193) @@ -53,10 +53,13 @@ \code{openbugs} (and \code{bugs}) and \code{as.bugs.array} functions in the CRAN package \pkg{R2WinBUGS}.} \examples{ \donttest{ +## Prepare the example files in a temporary directory +exfiles <- dir(options()$OpenBUGSExamples, pattern="^Rats.*txt$", full.names=TRUE) +ok <- file.copy(exfiles, tempdir()) BRugsFit(data = "Ratsdata.txt", inits = "Ratsinits.txt", para = c("alpha", "beta"), modelFile = "Ratsmodel.txt", numChains = 1, - working.directory = options()$OpenBUGSExamples) + working.directory = tempdir()) } } \keyword{interface} Modified: trunk/BRugs/tests/BRugs.R =================================================================== --- trunk/BRugs/tests/BRugs.R 2011-08-25 15:20:34 UTC (rev 192) +++ trunk/BRugs/tests/BRugs.R 2011-08-25 15:21:48 UTC (rev 193) @@ -2,14 +2,21 @@ if (test) { -library(BRugs) +library("BRugs") +## Prepare the example files in a temporary directory +exfiles <- dir(options()$OpenBUGSExamples, pattern="^Rats.*txt$", full.names=TRUE) +ok <- file.copy(exfiles, tempdir()) +exfiles <- dir(options()$OpenBUGSExamples, pattern="^Beetles.*txt$", full.names=TRUE) +ok <- file.copy(exfiles, tempdir()) + + BRugsFit(data = "Ratsdata.txt", inits = "Ratsinits.txt", para = c("alpha", "beta"), modelFile = "Ratsmodel.txt", numChains = 1, - working.directory = options()$OpenBUGSExamples) + working.directory = tempdir()) -setwd(options()$OpenBUGSExamples) +setwd(tempdir()) modelCheck("Ratsmodel.txt") modelData("Ratsdata.txt") modelCompile(numChains=2) @@ -28,23 +35,23 @@ BRugsFit(data = "Beetlesdata.txt", inits = "Beetlesinits.txt", para = c("alpha", "beta", "rhat"), modelFile = "Beetlesmodel.txt", numChains = 1, - working.directory = options()$OpenBUGSExamples) + working.directory = tempdir()) BRugsFit(data = beetles, inits = "Beetlesinits.txt", para = c("alpha", "beta", "rhat"), modelFile = "Beetlesmodel.txt", numChains = 1, - working.directory = options()$OpenBUGSExamples) + working.directory = tempdir()) with(beetles, BRugsFit(data = list("x", "n", "r", "N"), inits = "Beetlesinits.txt", para=c("alpha", "beta", "rhat"), modelFile = "Beetlesmodel.txt", - numChains = 1, working.directory = options()$OpenBUGSExamples) + numChains = 1, working.directory = tempdir()) ) with(beetles, BRugsFit(data = c("x", "n", "r", "N"), inits = "Beetlesinits.txt", para=c("alpha", "beta", "rhat"), modelFile = "Beetlesmodel.txt", - numChains = 1, working.directory = options()$OpenBUGSExamples) + numChains = 1, working.directory = tempdir()) ) } Modified: trunk/BRugs/tests/BRugs.Rout.save =================================================================== --- trunk/BRugs/tests/BRugs.Rout.save 2011-08-25 15:20:34 UTC (rev 192) +++ trunk/BRugs/tests/BRugs.Rout.save 2011-08-25 15:21:48 UTC (rev 193) @@ -1,5 +1,5 @@ -R version 2.13.1 (2011-07-08) +R version 2.13.1 Patched (2011-07-20 r56455) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i386-pc-mingw32/i386 (32-bit) @@ -20,14 +20,21 @@ > > if (test) { + -+ library(BRugs) ++ library("BRugs") + ++ ## Prepare the example files in a temporary directory ++ exfiles <- dir(options()$OpenBUGSExamples, pattern="^Rats.*txt$", full.names=TRUE) ++ ok <- file.copy(exfiles, tempdir()) ++ exfiles <- dir(options()$OpenBUGSExamples, pattern="^Beetles.*txt$", full.names=TRUE) ++ ok <- file.copy(exfiles, tempdir()) ++ ++ + BRugsFit(data = "Ratsdata.txt", inits = "Ratsinits.txt", + para = c("alpha", "beta"), modelFile = "Ratsmodel.txt", + numChains = 1, -+ working.directory = options()$OpenBUGSExamples) ++ working.directory = tempdir()) + -+ setwd(options()$OpenBUGSExamples) ++ setwd(tempdir()) + modelCheck("Ratsmodel.txt") + modelData("Ratsdata.txt") + modelCompile(numChains=2) @@ -46,23 +53,23 @@ + BRugsFit(data = "Beetlesdata.txt", inits = "Beetlesinits.txt", + para = c("alpha", "beta", "rhat"), modelFile = "Beetlesmodel.txt", + numChains = 1, -+ working.directory = options()$OpenBUGSExamples) ++ working.directory = tempdir()) + + BRugsFit(data = beetles, inits = "Beetlesinits.txt", + para = c("alpha", "beta", "rhat"), modelFile = "Beetlesmodel.txt", + numChains = 1, -+ working.directory = options()$OpenBUGSExamples) ++ working.directory = tempdir()) + + with(beetles, + BRugsFit(data = list("x", "n", "r", "N"), inits = "Beetlesinits.txt", + para=c("alpha", "beta", "rhat"), modelFile = "Beetlesmodel.txt", -+ numChains = 1, working.directory = options()$OpenBUGSExamples) ++ numChains = 1, working.directory = tempdir()) + ) + + with(beetles, + BRugsFit(data = c("x", "n", "r", "N"), inits = "Beetlesinits.txt", + para=c("alpha", "beta", "rhat"), modelFile = "Beetlesmodel.txt", -+ numChains = 1, working.directory = options()$OpenBUGSExamples) ++ numChains = 1, working.directory = tempdir()) + ) + + } Modified: trunk/BRugs/tests/examples.R =================================================================== --- trunk/BRugs/tests/examples.R 2011-08-25 15:20:34 UTC (rev 192) +++ trunk/BRugs/tests/examples.R 2011-08-25 15:21:48 UTC (rev 193) @@ -2,7 +2,7 @@ if (test) { -library(BRugs) +library("BRugs") ## Selected examples which take a few seconds in total to run @@ -28,19 +28,20 @@ Surgicalrand = c("p","pop.mean", "sigma") ) -test.modelfile = paste(test.models,"model.txt",sep="") -test.datafile = paste(test.models,"data.txt",sep="") -test.inits = paste(test.models,"inits.txt",sep="") - +test.modelfile <- paste(test.models,"model.txt",sep="") +test.datafile <- paste(test.models,"data.txt",sep="") +test.inits <- paste(test.models,"inits.txt",sep="") +test.pattern <- paste("^", test.models, ".*\\.txt$", sep="") ### Test for posterior means within 10 percent of previously saved values res.true <- dget(file="examples.stats.R") for (i in seq(along=test.models)) { - fit <- BRugsFit(data=test.datafile[i], inits=test.inits[i], modelFile=test.modelfile[i], para=test.params[[test.models[i]]], - nBurnin=5000, nIter=20000, nThin=1, numChains=1, seed=1 - , - working.directory=options()$OpenBUGSExamples - ) + exfiles <- dir(options()$OpenBUGSExamples, pattern=test.pattern[i], full.names=TRUE) + ok <- file.copy(exfiles, tempdir()) + fit <- BRugsFit(data=test.datafile[i], inits=test.inits[i], + modelFile=test.modelfile[i], para=test.params[[test.models[i]]], + nBurnin=5000, nIter=20000, nThin=1, numChains=1, seed=1, + working.directory=tempdir()) stopifnot(isTRUE(all.equal(fit$Stats$mean, res.true[[i]]$Stats$mean, tol=1e-01))) } Modified: trunk/BRugs/tests/examples.Rout.save =================================================================== --- trunk/BRugs/tests/examples.Rout.save 2011-08-25 15:20:34 UTC (rev 192) +++ trunk/BRugs/tests/examples.Rout.save 2011-08-25 15:21:48 UTC (rev 193) @@ -1,5 +1,5 @@ -R version 2.13.1 (2011-07-08) +R version 2.13.1 Patched (2011-07-20 r56455) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i386-pc-mingw32/i386 (32-bit) @@ -20,7 +20,7 @@ > > if (test) { + -+ library(BRugs) ++ library("BRugs") + + ## Selected examples which take a few seconds in total to run + @@ -46,19 +46,20 @@ + Surgicalrand = c("p","pop.mean", "sigma") + ) + -+ test.modelfile = paste(test.models,"model.txt",sep="") -+ test.datafile = paste(test.models,"data.txt",sep="") -+ test.inits = paste(test.models,"inits.txt",sep="") -+ ++ test.modelfile <- paste(test.models,"model.txt",sep="") ++ test.datafile <- paste(test.models,"data.txt",sep="") ++ test.inits <- paste(test.models,"inits.txt",sep="") ++ test.pattern <- paste("^", test.models, ".*\\.txt$", sep="") + ### Test for posterior means within 10 percent of previously saved values + + res.true <- dget(file="examples.stats.R") + for (i in seq(along=test.models)) { -+ fit <- BRugsFit(data=test.datafile[i], inits=test.inits[i], modelFile=test.modelfile[i], para=test.params[[test.models[i]]], -+ nBurnin=5000, nIter=20000, nThin=1, numChains=1, seed=1 -+ , -+ working.directory=options()$OpenBUGSExamples -+ ) ++ exfiles <- dir(options()$OpenBUGSExamples, pattern=test.pattern[i], full.names=TRUE) ++ ok <- file.copy(exfiles, tempdir()) ++ fit <- BRugsFit(data=test.datafile[i], inits=test.inits[i], ++ modelFile=test.modelfile[i], para=test.params[[test.models[i]]], ++ nBurnin=5000, nIter=20000, nThin=1, numChains=1, seed=1, ++ working.directory=tempdir()) + stopifnot(isTRUE(all.equal(fit$Stats$mean, res.true[[i]]$Stats$mean, tol=1e-01))) + } + @@ -268,5 +269,5 @@ monitor set for variable 'p' monitor set for variable 'pop.mean' monitor set for variable 'sigma' -20000 updates took 1 s +20000 updates took 2 s > Modified: trunk/BRugs/tests/functions.R =================================================================== --- trunk/BRugs/tests/functions.R 2011-08-25 15:20:34 UTC (rev 192) +++ trunk/BRugs/tests/functions.R 2011-08-25 15:21:48 UTC (rev 193) @@ -3,7 +3,9 @@ if (test) { library("BRugs") -setwd(options()$OpenBUGSExamples) +exfiles <- dir(options()$OpenBUGSExamples, pattern="^Rats.*txt$", full.names=TRUE) +ok <- file.copy(exfiles, tempdir()) +setwd(tempdir()) ## .onLoad(lib=.libPaths()[1], pkg="BRugs") # if developing without using namespace ### TEST ALL USER-LEVEL FUNCTIONS USING RATS EXAMPLE Modified: trunk/BRugs/tests/functions.Rout.save =================================================================== --- trunk/BRugs/tests/functions.Rout.save 2011-08-25 15:20:34 UTC (rev 192) +++ trunk/BRugs/tests/functions.Rout.save 2011-08-25 15:21:48 UTC (rev 193) @@ -1,5 +1,5 @@ -R version 2.13.1 (2011-07-08) +R version 2.13.1 Patched (2011-07-20 r56455) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i386-pc-mingw32/i386 (32-bit) @@ -21,7 +21,9 @@ > if (test) { + + library("BRugs") -+ setwd(options()$OpenBUGSExamples) ++ exfiles <- dir(options()$OpenBUGSExamples, pattern="^Rats.*txt$", full.names=TRUE) ++ ok <- file.copy(exfiles, tempdir()) ++ setwd(tempdir()) + ## .onLoad(lib=.libPaths()[1], pkg="BRugs") # if developing without using namespace + + ### TEST ALL USER-LEVEL FUNCTIONS USING RATS EXAMPLE This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2011-08-25 15:20:42
|
Revision: 192 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=192&view=rev Author: ligges Date: 2011-08-25 15:20:34 +0000 (Thu, 25 Aug 2011) Log Message: ----------- tweaks Modified Paths: -------------- trunk/BRugs/R/windows/zzz.R Modified: trunk/BRugs/R/windows/zzz.R =================================================================== --- trunk/BRugs/R/windows/zzz.R 2011-08-24 18:53:11 UTC (rev 191) +++ trunk/BRugs/R/windows/zzz.R 2011-08-25 15:20:34 UTC (rev 192) @@ -1,8 +1,9 @@ if (is.R()){ ".onLoad" <- function(lib, pkg){ - if(.Platform[["r_arch"]] != "i386") + if(.Platform[["r_arch"]] != "i386"){ stop("BRugs only works for 32-bit R") + } dir <- Sys.getenv("BRUGS_PATH") if(!nchar(dir)){ ob.reg <- try(utils:::readRegistry("Software\\OpenBUGS", "HLM", view = "32-bit"), silent = TRUE) @@ -18,11 +19,11 @@ ver <- gsub(".*OpenBUGS ?\\(>= ?(.+)\\).*", "\\1", deps) version.req <- as.numeric(paste(substr(ver, 1, 2), gsub("\\.","",substr(ver, 3, nchar(ver))), sep="")) if (max(version.inst) < version.req) { - warning("Found OpenBUGS version ", version.inst, ". Requires ", version.req, " or greater") + warning("Found OpenBUGS version ", version.inst, ".\n Requires ", version.req, " or greater.") return() } ## OpenBUGS installation location - dir <- utils:::readRegistry(paste("Software","OpenBUGS",rnames[which.max(version.inst)],sep="\\"),"HLM")$InstallPath + dir <- utils:::readRegistry(paste("Software","OpenBUGS",rnames[which.max(version.inst)],sep="\\"), "HLM", view = "32-bit")$InstallPath loadOpenBUGS(dir) packageStartupMessage("Welcome to BRugs running on OpenBUGS version ", veri[which.max(version.inst)]) } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2011-08-24 18:53:20
|
Revision: 191 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=191&view=rev Author: ligges Date: 2011-08-24 18:53:11 +0000 (Wed, 24 Aug 2011) Log Message: ----------- back-porting BRugs from www.openbugs.info Modified Paths: -------------- trunk/BRugs/DESCRIPTION trunk/BRugs/NAMESPACE trunk/BRugs/NEWS trunk/BRugs/R/bgr.point.R trunk/BRugs/R/bugs.data.R trunk/BRugs/R/bugs.inits.R trunk/BRugs/R/dimensions.R trunk/BRugs/R/formatdata.R trunk/BRugs/R/get.chain.R trunk/BRugs/R/info.node.R trunk/BRugs/R/internal.R trunk/BRugs/R/model.check.R trunk/BRugs/R/model.compile.R trunk/BRugs/R/model.inits.R trunk/BRugs/R/model.names.R trunk/BRugs/R/model.precision.R trunk/BRugs/R/model.setRN.R trunk/BRugs/R/plot.bgr.R trunk/BRugs/R/samples.coda.R trunk/BRugs/R/samples.correl.R trunk/BRugs/R/samples.density.R trunk/BRugs/R/samples.get.beg.R trunk/BRugs/R/samples.get.end.R trunk/BRugs/R/samples.get.firstChain.R trunk/BRugs/R/samples.get.lastChain.R trunk/BRugs/R/samples.get.thin.R trunk/BRugs/R/samples.monitors.R trunk/BRugs/R/samples.sample.R trunk/BRugs/R/samples.set.beg.R trunk/BRugs/R/samples.set.end.R trunk/BRugs/R/samples.set.firstChain.R trunk/BRugs/R/samples.set.lastChain.R trunk/BRugs/R/samples.set.thin.R trunk/BRugs/R/samples.size.R trunk/BRugs/R/samples.stats.R trunk/BRugs/R/set.values.R trunk/BRugs/R/unix/help.R trunk/BRugs/R/windows/help.R trunk/BRugs/R/zzz.R trunk/BRugs/configure trunk/BRugs/man/BRugs.Rd trunk/BRugs/man/BRugsFit.Rd trunk/BRugs/man/bgr.point.Rd trunk/BRugs/man/bugs.data.Rd trunk/BRugs/man/bugs.inits.Rd trunk/BRugs/man/model.RN.Rd trunk/BRugs/man/set.values.Rd trunk/BRugs/tests/BRugs.R trunk/BRugs/tests/BRugs.Rout.save trunk/BRugs/tests/examples.R trunk/BRugs/tests/functions.R Added Paths: ----------- 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.ac trunk/BRugs/man/unix/ trunk/BRugs/man/unix/loadOpenBUGS.Rd trunk/BRugs/man/windows/ trunk/BRugs/man/windows/loadOpenBUGS.Rd trunk/BRugs/src/BugsHelper.c trunk/BRugs/src/Makefile.win trunk/BRugs/src/Makevars.in trunk/BRugs/tests/examples.Rout.save trunk/BRugs/tests/functions.Rout.save trunk/BRugs/tests/local.R trunk/BRugs/tests/test.sh Removed Paths: ------------- trunk/BRugs/.Rbuildignore trunk/BRugs/R/model.getRN.R trunk/BRugs/inst/OpenBUGS/ trunk/BRugs/inst/README-inst_OpenBUGS trunk/BRugs/src/Makevars trunk/BRugs/src/Makevars.win Deleted: trunk/BRugs/.Rbuildignore =================================================================== --- trunk/BRugs/.Rbuildignore 2011-07-02 13:49:30 UTC (rev 190) +++ trunk/BRugs/.Rbuildignore 2011-08-24 18:53:11 UTC (rev 191) @@ -1 +0,0 @@ -inst/README-inst_OpenBUGS Modified: trunk/BRugs/DESCRIPTION =================================================================== --- trunk/BRugs/DESCRIPTION 2011-07-02 13:49:30 UTC (rev 190) +++ trunk/BRugs/DESCRIPTION 2011-08-24 18:53:11 UTC (rev 191) @@ -1,12 +1,12 @@ Package: BRugs -Title: OpenBUGS and its R / S-PLUS interface BRugs -Version: 0.6-0 -Date: 2010-04-30 -Author: The Chief Software Bug is Andrew Thomas, with web assistance from Real Bug Bob O'Hara. Other members of the BUGS team are statisticians David Spiegelhalter, Nicky Best, Dave Lunn and Ken Rice. Dave Lunn has also made major contributions to the software development. R Code modified, extended and packaged for R by Uwe Ligges and Sibylle Sturtz. Some ideas taken from the R2WinBUGS package based on code by Andrew Gelman. With considerable contributions by Gregor Gorjanc <gre...@bf...>. -Description: An R / S-PLUS package containing OpenBUGS and its R / S-PLUS interface BRugs. +Title: R interface to the OpenBUGS MCMC software +Version: 0.7-2 +Date: 2011-08-24 +Author: OpenBUGS was developed by Andrew Thomas, Dave Lunn, David Spiegelhalter and Nicky Best. R interface developed by Uwe Ligges, Sibylle Sturtz, Andrew Gelman, Gregor Gorjanc and Chris Jackson. Linux port and most recent developments by Chris Jackson. +Description: Fully-interactive R interface to the OpenBUGS software for Bayesian analysis using MCMC sampling Maintainer: Uwe Ligges <li...@st...> -Depends: R (>= 2.5.0), coda +Depends: R (>= 2.5.0), utils, coda +SystemRequirements: OpenBUGS (>= 3.2.1) Archs: i386 -OS_type: windows License: GPL-2 URL: http://www.openbugs.info/ Modified: trunk/BRugs/NAMESPACE =================================================================== --- trunk/BRugs/NAMESPACE 2011-07-02 13:49:30 UTC (rev 190) +++ trunk/BRugs/NAMESPACE 2011-08-24 18:53:11 UTC (rev 191) @@ -1,12 +1,12 @@ -useDynLib(BRugs) importFrom(coda, mcmc, mcmc.list) export(BRugsFit, bugsData, bugsInits, buildMCMC, dicClear, dicSet, dicStats, getNumChains, help.BRugs, help.WinBUGS, infoMemory,infoModules,infoNodeValues,infoNodeMethods,infoNodeTypes, infoUpdatersbyName,infoUpdatersbyDepth, +loadOpenBUGS, modelAdaptivePhase, modelCheck, modelCompile, modelData, -modelGenInits, modelGetRN, modelInits, modelIteration, +modelGenInits, modelInits, modelIteration, modelNames, modelPrecision, modelSaveState, modelSetAP, modelSetIts, modelSetOR, modelSetRN, modelUpdate, modelEnable, modelDisable, Modified: trunk/BRugs/NEWS =================================================================== --- trunk/BRugs/NEWS 2011-07-02 13:49:30 UTC (rev 190) +++ trunk/BRugs/NEWS 2011-08-24 18:53:11 UTC (rev 191) @@ -1,10 +1,140 @@ Changes to BRugs: ===================== +Version 0.7.2 (24 August 2011) +------------- +Backport to the original BRugs package -Update 0.6-0 -- Switch to new OpenBUGS (currently 3.1.0) -- 32-bit versions only +Version 0.7.1 (19 April 2011) +------------- + +The configure script on Linux now automatically detects OpenBUGS +installed by the RPM and DEB packages (to standards-compliant +locations) as well as OpenBUGS installed by the source package. + +Bug fix - bugsData should accept data as a list of variable names. +Thanks to Brian Ripley for these reports. + +handleRes() now explicitly labels internal OpenBUGS traps as bugs and +asks the user to send a bug report to the package maintainer. + +On Windows, if OpenBUGS installation is not detected in the registry, +package loading continues with a warning instead of stopping with an +error. If OpenBUGS was actually installed, the user can then load it +from a specified directory with loadOpenBUGS(dir). + + +Version 0.7 (March 2011) +----------- + +BRugs now works with an existing installation of OpenBUGS (3.2.1 or +later) instead of being distributed with the OpenBUGS library. + +On Windows, the OpenBUGS location is determined by a registry key +which is installed by the OpenBUGS for Windows installation program. + +On Linux, the OpenBUGS shared library and documentation are assumed to +be installed together in a library directory. Using the new OpenBUGS +for Linux source package OpenBUGS-3.2.1.tar.gz or later, this library +directory is by default + +/usr/local/lib/OpenBUGS + +In most cases it should be detected automatically when installing, but +it can be changed by running, for instance + +R CMD INSTALL --configure-args='--with-openbugs=/usr/lib/OpenBUGS' + + + +Version 0.61 +------------ +Fix for crash in bugsData + + +Version 0.6 +----------- + +Forked from the version of BRugs (0.5.3) available on CRAN Extras. +This new version supports Linux for the first time, as detailed below. + + +CHANGES MADE FOR LINUX PORT OF BRugs + +* A C program called BugsHelper is used to call the OpenBUGS shared + library on Linux via a system() call. With one call of BugsHelper, + any number of different OpenBUGS API commands can be run. The state + of the model is "internalized" on entry from a file in the temporary + directory, and "externalized" on exit. The source is in src/ and + the binary is installed into exec/. + +* New function .OpenBUGS() to execute a sequence of OpenBUGS API + commands of possibly differing types (e.g. CmdInterpreter, + RealArray, Integer) with given arguments. On Windows, this is a + wrapper for the old method of calling C functions from the + dyn.load()-ed library. On Linux, this calls BugsHelper once. The + old .CmdInterpreter and related functions still have the same + interfaces, but work by calling .OpenBUGS(). + +* Input and output from the OpenBUGS API on Linux is performed through + files input1.txt, output1.txt, input2.txt, output2.txt, ... in the + same /tmp/R*** directory as the buffer.txt file. The buffer.txt + file is used as before for messages from OpenBUGS. + +* A set of global variables is stored in the options() list containing + the begin and end iterations, first and last chains, thin interval + and precision to calculate sample statistics. This is required + because the OpenBUGS Internalize / Externalize facility used by + BugsHelper does not save these variables, which are normally stored + in the OpenBUGS internal module SamplesEmbed. They are not saved + because OpenBUGS considers them to be part of the GUI state + (equivalent to the values typed in Inference->Samples...) rather + than the model state. These variables are reset when a new model is + checked and compiled. + +* As a result, all functions which compute sample statistics must + first call an API command which is returned by + .SamplesGlobalsCmd(node). This command updates the values stored in + SamplesEmbed using the values stored in options(). This ensures + that OpenBUGS knows about them before calculating sample statistics. + (Note this is still done on Windows where it is not necessary, but + there should be negligible overhead). The directly affected + functions are samplesCoda(), samplesSize(), samplesSample(), + samplesStats(), samplesCorrel(), plotBgr(). + +* .onLoad() in zzz.R initialises these global variables on Linux and + Windows. + +* The corresponding set/get functions are changed to read and write + these global variables instead of updating the values in + SamplesEmbed. + +* plotBGR() modified to use a single .OpenBUGS() call to return a list + of samples for each required iteration on the grid. bgrPoint() + takes a sample instead of a node and iteration. Using one + .OpenBUGS() call for each sample would be an order of magnitude + slower using the Linux helper program. Assume the extra memory + overhead, compared to the old method, is not a problem on Windows. + +* infoNodeValues() and SetValues() now read and write the values from + multiple chains, and work on scalars as well as vectors. + +* modelNames() modified to use a single .OpenBUGS call instead of + looping API commands over names in the model. + +* useDynLib(BRugs) removed from NAMESPACE. This is done in .OnLoad() + instead, to ensure that it is only used on Windows. + +* modelGetRN() removed, as the initial random number preset is not + saved by the Externalize facility. The random number state however + is saved and restored properly during the model run. There is no + need for the initial preset to be read by the user, as it does not + change as the model runs. + +* samplesCorrel() wasn't setting begin/end/thin etc. properly, since + the CorrelEmbed module doesn't use the values in SamplesEmbed. + These are now read from the variables in options(). + Update 0.5-3 - fix writeModel() again by going through parse tree now - fix buildMCMC() to report right thinning parameters and keep all samples Modified: trunk/BRugs/R/bgr.point.R =================================================================== --- trunk/BRugs/R/bgr.point.R 2011-07-02 13:49:30 UTC (rev 190) +++ trunk/BRugs/R/bgr.point.R 2011-08-24 18:53:11 UTC (rev 191) @@ -1,14 +1,9 @@ "bgrPoint" <- -function(node, iteration) -# Calculate the bgr statistic at iteration +function(sample) +# Calculate the bgr statistic given a sample concatenated over chains { - oldEnd <- samplesGetEnd() - on.exit(samplesSetEnd(oldEnd)) - samplesSetEnd(as.integer(iteration)) numChains <- getNumChains() - sampleSize <- samplesSize(node) - command <- "SamplesEmbed.SampleValues" - sample <- samplesSample(node) + sampleSize <- length(sample) lenChain <- sampleSize %/% numChains if (is.R()) dq <- quantile(sample, c(0.1, 0.9), names = FALSE) @@ -25,5 +20,5 @@ } n.delta <- n.delta / numChains bgr.stat <- d.delta / n.delta - return(c(iteration, n.delta, d.delta, bgr.stat)) + return(c(n.delta, d.delta, bgr.stat)) } Modified: trunk/BRugs/R/bugs.data.R =================================================================== --- trunk/BRugs/R/bugs.data.R 2011-07-02 13:49:30 UTC (rev 190) +++ trunk/BRugs/R/bugs.data.R 2011-08-24 18:53:11 UTC (rev 191) @@ -1,26 +1,29 @@ "bugsData" <- -function(data, fileName = file.path(tempdir(), "data.txt"), digits = 5){ - if(is.numeric(unlist(data))) - if(is.R()) { - write.datafile(lapply(data, formatC, digits = digits, format = "E"), fileName) + function(data, fileName = file.path(tempdir(), "data.txt"), format="E", digits = 5){ + if (is.character(unlist(data))) { + 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 = format), fileName) + } + else { + data.list <- lapply(as.list(data), get, where = parent.frame(2)) + names(data.list) <- unlist(data) + writeDatafileS4(data.list, towhere = "data.txt") + } } - else { - writeDatafileS4(data, towhere = "data.txt") + else if(is.list(data)) { + data <- lapply(data, function(x){x <- if(is.character(x)||is.factor(x)) match(x, unique(x)) else x}) + if(is.R()) { + write.datafile(lapply(data, formatC, digits = digits, format = format), fileName) + } + else { + writeDatafileS4(data, towhere = "data.txt") + } } - 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"), fileName) - } - else { - data.list <- lapply(as.list(data), get, where = parent.frame(2)) - names(data.list) <- unlist(data) - writeDatafileS4(data.list, towhere = "data.txt") - } + else stop("Expected a list of data, a list or vector of variable names") + invisible(fileName) } - invisible(fileName) -} if(is.R()){ Modified: trunk/BRugs/R/bugs.inits.R =================================================================== --- trunk/BRugs/R/bugs.inits.R 2011-07-02 13:49:30 UTC (rev 190) +++ trunk/BRugs/R/bugs.inits.R 2011-08-24 18:53:11 UTC (rev 191) @@ -1,5 +1,5 @@ "bugsInits" <- -function (inits, numChains = 1, fileName, digits = 5){ +function (inits, numChains = 1, fileName, format="E", digits = 5){ if(missing(fileName)) fileName <- file.path(tempdir(), paste("inits", 1:numChains, ".txt", sep = "")) if(length(fileName) != numChains) @@ -8,12 +8,12 @@ for (i in 1:numChains){ if (is.function(inits)) if (is.R()) - write.datafile(lapply(inits(), formatC, digits = digits, format = "E"), fileName[i]) + write.datafile(lapply(inits(), formatC, digits = digits, format = format), fileName[i]) else writeDatafileS4(inits(), towhere = fileName[i]) else if (is.R()) - write.datafile(lapply(inits[[i]], formatC, digits = digits, format = "E"), fileName[i]) + write.datafile(lapply(inits[[i]], formatC, digits = digits, format = format), fileName[i]) else writeDatafileS4(inits[[i]], towhere = fileName[i]) } Modified: trunk/BRugs/R/dimensions.R =================================================================== --- trunk/BRugs/R/dimensions.R 2011-07-02 13:49:30 UTC (rev 190) +++ trunk/BRugs/R/dimensions.R 2011-08-24 18:53:11 UTC (rev 191) @@ -5,9 +5,8 @@ nodeLabel <- as.character(node) if(!(nodeLabel %in% modelNames())) stop("node must be a variable name from the model") - command <- "BugsRobjects.SetVariable" - .C("CharArray", command, nchar(command), nodeLabel, nchar(nodeLabel), integer(1), PACKAGE="BRugs") - command <- "BugsRobjects.GetNumDimensions" - dimensions <- .Integer(command) - return(dimensions) + dimensions <- .OpenBUGS(c("BugsRobjects.SetVariable", "BugsRobjects.GetNumDimensions"), + c("CharArray", "Integer"), + list(nodeLabel, NA))[[2]] + dimensions } Modified: trunk/BRugs/R/formatdata.R =================================================================== --- trunk/BRugs/R/formatdata.R 2011-07-02 13:49:30 UTC (rev 190) +++ trunk/BRugs/R/formatdata.R 2011-08-24 18:53:11 UTC (rev 191) @@ -1,28 +1,31 @@ "formatdata" <- function (datalist){ - if (!is.list(datalist) || is.data.frame(datalist)) + if (!is.list(datalist) || is.data.frame(datalist)) stop("argument to formatdata() ", "must be a list") n <- length(datalist) datalist.string <- vector(n, mode = "list") datanames <- names(datalist) for (i in 1:n) { - datalist.string[[i]] <- - switch(as.character(dimensions(datanames[i])), - "0" = paste(names(datalist)[i], - "=", as.character(datalist[[i]]), sep = ""), - "1" = paste(names(datalist)[i], - "=c(", paste(as.character(datalist[[i]]), collapse = ", "), - ")", sep = ""), - paste(names(datalist)[i], - "= structure(.Data= c(", - paste(as.character(as.vector(aperm(datalist[[i]]))), collapse = ", "), - "), .Dim=c(", - paste(as.character(dim(datalist[[i]])), collapse = ", "), - "))", sep = "") - ) + if (is.factor(datalist[[i]])) + datalist[[i]] <- as.integer(datalist[[i]]) + datalist.string[[i]] <- + if (length(datalist[[i]]) == 1) + paste(names(datalist)[i], + "=", as.character(datalist[[i]]), sep = "") + else if (is.vector(datalist[[i]]) && length(datalist[[i]]) > 1) + paste(names(datalist)[i], + "=c(", paste(as.character(datalist[[i]]), collapse = ", "), + ")", sep = "") + else + paste(names(datalist)[i], + "= structure(.Data= c(", + paste(as.character(as.vector(aperm(datalist[[i]]))), collapse = ", "), + "), .Dim=c(", + paste(as.character(dim(datalist[[i]])), collapse = ", "), + "))", sep = "") } - datalist.tofile <- paste("list(", - paste(unlist(datalist.string), collapse = ", "), + datalist.tofile <- paste("list(", + paste(unlist(datalist.string), collapse = ", "), ")", sep = "") return(datalist.tofile) } Modified: trunk/BRugs/R/get.chain.R =================================================================== --- trunk/BRugs/R/get.chain.R 2011-07-02 13:49:30 UTC (rev 190) +++ trunk/BRugs/R/get.chain.R 2011-08-24 18:53:11 UTC (rev 191) @@ -2,6 +2,5 @@ function() # Get chain field { - command<- "BugsEmbed.chain" - .Integer(command) + getOption("BRugsNextChain") } Modified: trunk/BRugs/R/info.node.R =================================================================== --- trunk/BRugs/R/info.node.R 2011-07-02 13:49:30 UTC (rev 190) +++ trunk/BRugs/R/info.node.R 2011-08-24 18:53:11 UTC (rev 191) @@ -3,16 +3,18 @@ # Get current value of node { nodeLabel <- as.character(nodeLabel) - command <- "BugsRobjects.SetVariable" - len <- nchar(command) - .C("CharArray", command, as.integer(len), nodeLabel, nchar(nodeLabel), integer(1), PACKAGE="BRugs") - command <- "BugsRobjects.GetSize" - nodeSize <- .Integer(command) + out <- .OpenBUGS(c("BugsRobjects.SetVariable", "BugsRobjects.GetSize"), + c("CharArray","Integer"), + list(nodeLabel, NA)) + nodeSize <- out[[2]] if(nodeSize == -1) stop(nodeLabel, " is not a node in BUGS model") - command <- "BugsRobjects.GetValues" - .C("RealArray", command, nchar(command), as.double(rep(NA, nodeSize)), - as.integer(nodeSize), integer(1), NAOK = TRUE, PACKAGE="BRugs")[[3]] + numChains <- getNumChains() + out <- .OpenBUGS(c("BugsRobjects.SetVariable", "BugsRobjects.GetValues"), + c("CharArray","RealArray"), + list(nodeLabel, double(nodeSize*numChains))) + values <- matrix(out[[2]], nrow=nodeSize, ncol=numChains) + values } infoNodeMethods <- function(nodeLabel) Modified: trunk/BRugs/R/internal.R =================================================================== --- trunk/BRugs/R/internal.R 2011-07-02 13:49:30 UTC (rev 190) +++ trunk/BRugs/R/internal.R 2011-08-24 18:53:11 UTC (rev 191) @@ -1,22 +1,58 @@ +### Functions to run a single OpenBUGS API command string + .CmdInterpreter <- function(command) -{ - command <- as.character(command) - res <- .C("CmdInterpreter", command, nchar(command), integer(1), PACKAGE = "BRugs") - handleRes(res[[3]]) - return(res) +{ + unlist(.OpenBUGS(command, "CmdInterpreter")) } .Integer <- function(command) { - values <- .C("Integer", command, nchar(command), integer(1), integer(1), PACKAGE = "BRugs") - handleRes(values[[4]]) - as.integer(values[[3]]) + unlist(.OpenBUGS(command, "Integer")) } +.CharArray <- function(command, arg) +{ + unlist(.OpenBUGS(command, "CharArray", arg)) +} + +.RealArray <- function(command, arg) +{ + unlist(.OpenBUGS(command, "RealArray", arg)) +} + + +.OpenBUGS.cmdtypes <- c("CmdInterpreter","Integer","CharArray","RealArray") + +.OpenBUGS <- function(cmds, cmdtypes=NULL, args=NULL) { + ncmds <- length(cmds) + if (is.null(cmdtypes)) cmdtypes <- rep("CmdInterpreter", ncmds) + if (is.null(args)) args <- as.list(rep(NA, ncmds)) + stopifnot(ncmds==length(cmdtypes)) + stopifnot(ncmds==length(args)) + .OpenBUGS.platform(cmds, cmdtypes, args) +} + handleRes <- function(res) { - switch(res, - stop("An OpenBUGS module or procedure was called that did not exist."), - stop("An OpenBUGS procedure was called with the wrong type of argument."), - stop("An OpenBUGS procedure was called with the wrong signature.")) + 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) + ) } + +.SamplesGlobalsCmd <- function(node){ + options.old <- options() + 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(", shQuote(node), ")", sep=""), + paste("BugsMappers.SetPrec(", getOption("BRugsPrec"), ")", sep="") + ) + options(options.old) + paste(commands, collapse="; ") +} Modified: trunk/BRugs/R/model.check.R =================================================================== --- trunk/BRugs/R/model.check.R 2011-07-02 13:49:30 UTC (rev 190) +++ trunk/BRugs/R/model.check.R 2011-08-24 18:53:11 UTC (rev 191) @@ -16,6 +16,7 @@ command <- gsub ("//", "/", command) } .CmdInterpreter(command) + .initGlobals() if(getOption("BRugsVerbose")) buffer() } Modified: trunk/BRugs/R/model.compile.R =================================================================== --- trunk/BRugs/R/model.compile.R 2011-07-02 13:49:30 UTC (rev 190) +++ trunk/BRugs/R/model.compile.R 2011-08-24 18:53:11 UTC (rev 191) @@ -10,6 +10,7 @@ .CmdInterpreter(command) samplesSetFirstChain(1) samplesSetLastChain(numChains) + options("BRugsNextChain" = 1) if(getOption("BRugsVerbose")) buffer() } Deleted: trunk/BRugs/R/model.getRN.R =================================================================== --- trunk/BRugs/R/model.getRN.R 2011-07-02 13:49:30 UTC (rev 190) +++ trunk/BRugs/R/model.getRN.R 2011-08-24 18:53:11 UTC (rev 191) @@ -1,7 +0,0 @@ -"modelGetRN" <- -function() -# Get the seed of random number generator -{ - command <- "BugsEmbed.preSet" - .Integer(command) -} Modified: trunk/BRugs/R/model.inits.R =================================================================== --- trunk/BRugs/R/model.inits.R 2011-07-02 13:49:30 UTC (rev 190) +++ trunk/BRugs/R/model.inits.R 2011-08-24 18:53:11 UTC (rev 191) @@ -28,9 +28,10 @@ } .CmdInterpreter(command) if(getOption("BRugsVerbose")){ - cat("Initializing chain ", chainNum[i], ": ", sep="") + message("Initializing chain ", chainNum[i], ": ", sep="") buffer() } + options("BRugsNextChain" = chainNum[i] + 1) } invisible() } Modified: trunk/BRugs/R/model.names.R =================================================================== --- trunk/BRugs/R/model.names.R 2011-07-02 13:49:30 UTC (rev 190) +++ trunk/BRugs/R/model.names.R 2011-08-24 18:53:11 UTC (rev 191) @@ -6,15 +6,29 @@ number <- .Integer(command) name <- character(number) if(length(number)){ - for(i in 1:number){ - command <- paste("BugsRobjects.SetIndex(", i-1, ")", sep="") - .CmdInterpreter(command) - command <- "BugsRobjects.GetStringLength" - numchar <- .Integer(command) - command <- "BugsRobjects.GetVariable" - char <- paste(rep(" ", numchar), collapse="") - name[i] <- .C("CharArray", command, nchar(command), char, numchar, integer(1), PACKAGE="BRugs")[[3]] - } + cmds <- character(0) + cmdtype <- character() + for(i in 1:number){ + cmds <- c(cmds, paste("BugsRobjects.SetIndex(", i-1, ")", sep=""), + "BugsRobjects.GetStringLength") + cmdtype <- c(cmdtype, c("CmdInterpreter","Integer")) + } + res <- .OpenBUGS(cmds, cmdtype) + numchar <- unlist(res[seq(2, 2*number, by=2)]) + + cmds <- character(0) + cmdtype <- character() + args <- list() + for(i in 1:number){ + char <- paste(rep(" ", numchar[i]), collapse="") + cmds <- c(cmds, + paste("BugsRobjects.SetIndex(", i-1, ")", sep=""), + "BugsRobjects.GetVariable") + cmdtype <- c(cmdtype, c("CmdInterpreter","CharArray")) + args <- c(args, list(NA, char)) + } + res <- .OpenBUGS(cmds, cmdtype, args) + name <- unlist(res[seq(2, 2*number, by=2)]) } return(name) -} + } Modified: trunk/BRugs/R/model.precision.R =================================================================== --- trunk/BRugs/R/model.precision.R 2011-07-02 13:49:30 UTC (rev 190) +++ trunk/BRugs/R/model.precision.R 2011-08-24 18:53:11 UTC (rev 191) @@ -5,6 +5,7 @@ if(!is.numeric(prec)) stop("prec ", "must be numeric") prec <- as.integer(prec) - command <- paste("BugsMappers.SetPrec(", prec, ")") - invisible(.CmdInterpreter(command)) + options(BRugsPrec=prec) +# command <- paste("BugsMappers.SetPrec(", prec, ")") +# invisible(.CmdInterpreter(command)) } Modified: trunk/BRugs/R/model.setRN.R =================================================================== --- trunk/BRugs/R/model.setRN.R 2011-07-02 13:49:30 UTC (rev 190) +++ trunk/BRugs/R/model.setRN.R 2011-08-24 18:53:11 UTC (rev 191) @@ -6,9 +6,5 @@ stop("state must be an integer from 1 to 14") state <- as.integer(state) command <- paste("BugsEmbed.SetRNGuard; BugsEmbed.SetRNState(", state, ")" ) - res <- .CmdInterpreter(command)[[3]] - if(!res){ - if(getOption("BRugsVerbose")) - message("Random number generator state successfully set") - }else stop("Setting random number generator state returned with an error.") + invisible(.CmdInterpreter(command)) } Modified: trunk/BRugs/R/plot.bgr.R =================================================================== --- trunk/BRugs/R/plot.bgr.R 2011-07-02 13:49:30 UTC (rev 190) +++ trunk/BRugs/R/plot.bgr.R 2011-08-24 18:53:11 UTC (rev 191) @@ -1,13 +1,42 @@ +### Plot bgr diagnostic for single component of OpenBUGS name "plotBgr" <- -function(node, plot = TRUE, main = NULL, xlab = "iteration", ylab = "bgr", - col = c("red", "blue", "green"), bins = 50, ...) -# Plot bgr diagnostic for single component of OpenBUGS name + function(node, plot = TRUE, main = NULL, xlab = "iteration", ylab = "bgr", + col = c("red", "blue", "green"), bins = 50, ...) { sM <- samplesMonitors(node) if(length(sM) > 1 || sM != node) stop("node must be a scalar variable from the model, for arrays use samplesBgr") grid <- bgrGrid(node, bins = bins) - bgr <- sapply(grid, bgrPoint, node = node) + + ## Use a single API call instead of looping API calls over + ## iterations - more efficient with the Linux helper. + + ## find size of available sample at each grid point + res <- .OpenBUGS(cmds = c(.SamplesGlobalsCmd(node), + as.vector(rbind(paste("SamplesEmbed.end := ", grid, ";"), "SamplesEmbed.SampleSize;"))), + cmdtypes = c("CmdInterpreter", rep(c("CmdInterpreter","Integer"), bins)), + args=as.list(c(NA, rep(c(NA, NA), bins))) + ) + + args <- list(NA) + for (i in seq(length=bins)){ + args[[2*i]] <- NA + args[[2*i + 1]] <- double(res[[2*i + 1]]) + } + + ## get available sample at each grid point + res <- .OpenBUGS(cmds = + c(.SamplesGlobalsCmd(node), + as.vector(rbind(paste("SamplesEmbed.end := ", grid, ";"), "SamplesEmbed.SampleValues;"))), + cmdtypes = c("CmdInterpreter", rep(c("CmdInterpreter","RealArray"), bins)), + args=args) + + ## remove junk elements of list, leaving a list of samples for each grid point + res[c(1, 2*seq(length=bins))] <- NULL + + ## calculate between, within and ratio statistics for each grid point + bgr <- rbind(grid, sapply(res, bgrPoint)) + yRange <- range(bgr[4,]) yRange <- c(0, max(c(1.2, yRange[2]))) nRange <- range(bgr[2,]) @@ -21,7 +50,7 @@ bgr[3,] <- bgr[3,] / max if(plot){ plot(grid, bgr[4,], ylim = yRange, type = "l", - main = if(is.null(main)) node else main, xlab = xlab, ylab = ylab, col = col[1], ...) + main = if(is.null(main)) node else main, xlab = xlab, ylab = ylab, col = col[1], ...) lines(grid, bgr[2,], col = col[2], ...) lines(grid, bgr[3,], col = col[3], ...) } @@ -30,4 +59,5 @@ bgr$Iteration <- as.integer(bgr$Iteration) if(plot) invisible(bgr) else return(bgr) + } Modified: trunk/BRugs/R/samples.coda.R =================================================================== --- trunk/BRugs/R/samples.coda.R 2011-07-02 13:49:30 UTC (rev 190) +++ trunk/BRugs/R/samples.coda.R 2011-08-24 18:53:11 UTC (rev 191) @@ -29,9 +29,8 @@ samplesSetLastChain(lastChain) thin <- max(c(thin, 1)) samplesSetThin(thin) - command <- paste("SamplesEmbed.SetVariable(", sQuote(node), - ");SamplesEmbed.StatsGuard;", "SamplesEmbed.CODA(", - sQuote(stem), ")") + command <- paste(.SamplesGlobalsCmd(node), ";SamplesEmbed.StatsGuard;", + "SamplesEmbed.CODA(", sQuote(stem), ")") .CmdInterpreter(command) buffer() } Modified: trunk/BRugs/R/samples.correl.R =================================================================== --- trunk/BRugs/R/samples.correl.R 2011-07-02 13:49:30 UTC (rev 190) +++ trunk/BRugs/R/samples.correl.R 2011-08-24 18:53:11 UTC (rev 191) @@ -22,10 +22,16 @@ samplesSetLastChain(lastChain) thin <- max(c(thin, 1)) samplesSetThin(thin) - - command <- paste("CorrelEmbed.SetVariable0(", sQuote(node0), - ");CorrelEmbed.SetVariable1(", sQuote(node1), - ");CorrelEmbed.Guard", ";CorrelEmbed.PrintMatrix") + + command <- paste("CorrelEmbed.beg :=", getOption("BRugsSamplesBeg"), + "; CorrelEmbed.end :=", getOption("BRugsSamplesEnd"), + "; CorrelEmbed.firstChain :=", getOption("BRugsSamplesFirstChain"), + "; CorrelEmbed.lastChain :=", getOption("BRugsSamplesLastChain"), + "; CorrelEmbed.thin :=", getOption("BRugsSamplesThin"), + "; CorrelEmbed.SetVariable0(", sQuote(node0), + ");CorrelEmbed.SetVariable1(", sQuote(node1), + ");CorrelEmbed.Guard", ";CorrelEmbed.PrintMatrix" + ) .CmdInterpreter(command) buffer <- file.path(tempdir(), "buffer.txt") rlb <- readLines(buffer) Modified: trunk/BRugs/R/samples.density.R =================================================================== --- trunk/BRugs/R/samples.density.R 2011-07-02 13:49:30 UTC (rev 190) +++ trunk/BRugs/R/samples.density.R 2011-08-24 18:53:11 UTC (rev 191) @@ -31,10 +31,12 @@ thin <- max(c(thin, 1)) samplesSetThin(thin) mons <- samplesMonitors(node) - if (is.R()) - par(mfrow = mfrow, ask = ask, ann = ann) - else - par(mfrow = mfrow, ask = ask) + if (plot) { + if (is.R()) + par(mfrow = mfrow, ask = ask, ann = ann) + else + par(mfrow = mfrow, ask = ask) + } result <- sapply(mons, plotDensity, plot=plot, ...) if (!is.R()) invisible() Modified: trunk/BRugs/R/samples.get.beg.R =================================================================== --- trunk/BRugs/R/samples.get.beg.R 2011-07-02 13:49:30 UTC (rev 190) +++ trunk/BRugs/R/samples.get.beg.R 2011-08-24 18:53:11 UTC (rev 191) @@ -1,7 +1,6 @@ "samplesGetBeg" <- function() -# Get the beg field +# Beginning iteration from which to compute sample statistics { - command <- "SamplesEmbed.beg" - .Integer(command) + getOption("BRugsSamplesBeg") } Modified: trunk/BRugs/R/samples.get.end.R =================================================================== --- trunk/BRugs/R/samples.get.end.R 2011-07-02 13:49:30 UTC (rev 190) +++ trunk/BRugs/R/samples.get.end.R 2011-08-24 18:53:11 UTC (rev 191) @@ -1,7 +1,6 @@ "samplesGetEnd" <- function() -# Get the end field +# End iteration from which to compute sample statistics { - command <- "SamplesEmbed.end" - .Integer(command) + getOption("BRugsSamplesEnd") } Modified: trunk/BRugs/R/samples.get.firstChain.R =================================================================== --- trunk/BRugs/R/samples.get.firstChain.R 2011-07-02 13:49:30 UTC (rev 190) +++ trunk/BRugs/R/samples.get.firstChain.R 2011-08-24 18:53:11 UTC (rev 191) @@ -1,7 +1,6 @@ "samplesGetFirstChain" <- function() -# Get the firstChain field +# First chain from which to compute sample statistics { - command <- "SamplesEmbed.firstChain" - .Integer(command) + getOption("BRugsSamplesFirstChain") } Modified: trunk/BRugs/R/samples.get.lastChain.R =================================================================== --- trunk/BRugs/R/samples.get.lastChain.R 2011-07-02 13:49:30 UTC (rev 190) +++ trunk/BRugs/R/samples.get.lastChain.R 2011-08-24 18:53:11 UTC (rev 191) @@ -1,7 +1,6 @@ "samplesGetLastChain" <- function() -# Get the lastChain field +# Last chain from which to compute sample statistics { - command <- "SamplesEmbed.lastChain" - .Integer(command) + getOption("BRugsSamplesLastChain") } Modified: trunk/BRugs/R/samples.get.thin.R =================================================================== --- trunk/BRugs/R/samples.get.thin.R 2011-07-02 13:49:30 UTC (rev 190) +++ trunk/BRugs/R/samples.get.thin.R 2011-08-24 18:53:11 UTC (rev 191) @@ -1,7 +1,6 @@ "samplesGetThin" <- function() -# Get the thin field +# Thinning interval to apply to sample statistics { - command <- "SamplesEmbed.thin" - .Integer(command) + getOption("BRugsSamplesThin") } Modified: trunk/BRugs/R/samples.monitors.R =================================================================== --- trunk/BRugs/R/samples.monitors.R 2011-07-02 13:49:30 UTC (rev 190) +++ trunk/BRugs/R/samples.monitors.R 2011-08-24 18:53:11 UTC (rev 191) @@ -4,7 +4,7 @@ { if (is.R()){ command <- paste("SamplesEmbed.SetVariable(", sQuote(node), - ");SamplesEmbed.StatsGuard;SamplesEmbed.Labels") + ");SamplesEmbed.StatsGuard;SamplesEmbed.Labels",sep="") .CmdInterpreter(command) buffer <- file.path(tempdir(), "buffer.txt") rlb <- readLines(buffer) @@ -23,7 +23,7 @@ } else { sampsMonsSingle <- function(node){ command <- paste("SamplesEmbed.SetVariable(", sQuote(node), - ");SamplesEmbed.StatsGuard;SamplesEmbed.Labels") + ");SamplesEmbed.StatsGuard;SamplesEmbed.Labels",sep="") .CmdInterpreter(command) buffer <- file.path(tempdir(), "buffer.txt") rlb <- readLines(buffer) Modified: trunk/BRugs/R/samples.sample.R =================================================================== --- trunk/BRugs/R/samples.sample.R 2011-07-02 13:49:30 UTC (rev 190) +++ trunk/BRugs/R/samples.sample.R 2011-08-24 18:53:11 UTC (rev 191) @@ -9,16 +9,14 @@ sM <- samplesMonitors(node)[1] if(sM == "model must be initialized before monitors used") stop("model must be initialized / updated / monitored before samplesSample is used") - - command <- "BugsRobjects.SetVariable" - .C("CharArray", command, nchar(command), node, nchar(node), integer(1), PACKAGE="BRugs") - command <- "BugsRobjects.GetSize" - nodeSize <- .Integer(command) - if(nodeSize > 1) + nodeSize <- .OpenBUGS(c("BugsRobjects.SetVariable", "BugsRobjects.GetSize"), + c("CharArray","Integer"), + list(node,NA))[[2]] + if(nodeSize > 1) stop("Only scalar nodes such as ", node, "[1] are allowed.") - sampleSize <- samplesSize(node) - command <- "SamplesEmbed.SampleValues" - .C("RealArray", command, nchar(command), - double(sampleSize), sampleSize, integer(1), PACKAGE="BRugs")[[3]] + sample <- .OpenBUGS(c(.SamplesGlobalsCmd(node), "SamplesEmbed.SampleValues"), + c("CmdInterpreter","RealArray"), + list(node,double(sampleSize)))[[2]] + sample } Modified: trunk/BRugs/R/samples.set.beg.R =================================================================== --- trunk/BRugs/R/samples.set.beg.R 2011-07-02 13:49:30 UTC (rev 190) +++ trunk/BRugs/R/samples.set.beg.R 2011-08-24 18:53:11 UTC (rev 191) @@ -5,6 +5,5 @@ if(!is.numeric(begIt)) stop("begIt ", "must be numeric") begIt <- as.integer(begIt) - command <- paste("SamplesEmbed.beg :=", begIt) - invisible(.CmdInterpreter(command)) + options("BRugsSamplesBeg" = begIt) } Modified: trunk/BRugs/R/samples.set.end.R =================================================================== --- trunk/BRugs/R/samples.set.end.R 2011-07-02 13:49:30 UTC (rev 190) +++ trunk/BRugs/R/samples.set.end.R 2011-08-24 18:53:11 UTC (rev 191) @@ -5,6 +5,5 @@ if(!is.numeric(endIt)) stop("endIt ", "must be numeric") endIt <- as.integer(endIt) - command <- paste("SamplesEmbed.end :=", endIt) - invisible(.CmdInterpreter(command)) + options("BRugsSamplesEnd" = endIt) } Modified: trunk/BRugs/R/samples.set.firstChain.R =================================================================== --- trunk/BRugs/R/samples.set.firstChain.R 2011-07-02 13:49:30 UTC (rev 190) +++ trunk/BRugs/R/samples.set.firstChain.R 2011-08-24 18:53:11 UTC (rev 191) @@ -7,6 +7,5 @@ first <- as.integer(first) if(!(first %in% 1:getNumChains())) stop("it is required to have 1 <= first <= nchains") - command <- paste("SamplesEmbed.firstChain :=", as.integer(first)) - invisible(.CmdInterpreter(command)) + options("BRugsSamplesFirstChain" = first) } Modified: trunk/BRugs/R/samples.set.lastChain.R =================================================================== --- trunk/BRugs/R/samples.set.lastChain.R 2011-07-02 13:49:30 UTC (rev 190) +++ trunk/BRugs/R/samples.set.lastChain.R 2011-08-24 18:53:11 UTC (rev 191) @@ -7,6 +7,5 @@ last <- as.integer(last) if(!(last %in% 1:getNumChains())) stop("it is required to have 1 <= last <= nchains") - command <- paste("SamplesEmbed.lastChain :=", last) - invisible(.CmdInterpreter(command)) + options("BRugsSamplesLastChain" = last) } Modified: trunk/BRugs/R/samples.set.thin.R =================================================================== --- trunk/BRugs/R/samples.set.thin.R 2011-07-02 13:49:30 UTC (rev 190) +++ trunk/BRugs/R/samples.set.thin.R 2011-08-24 18:53:11 UTC (rev 191) @@ -4,6 +4,5 @@ { if(!is.numeric(thin)) stop("thin ", "must be numeric") - command <- paste("SamplesEmbed.thin :=", as.integer(thin)) - invisible(.CmdInterpreter(command)) + options("BRugsSamplesThin" = thin) } Modified: trunk/BRugs/R/samples.size.R =================================================================== --- trunk/BRugs/R/samples.size.R 2011-07-02 13:49:30 UTC (rev 190) +++ trunk/BRugs/R/samples.size.R 2011-08-24 18:53:11 UTC (rev 191) @@ -9,8 +9,7 @@ if (any(grep("^model has probably not yet been updated", sM))) return(0) if(length(sM) > 1 || sM != node) stop("node must be a scalar variable from the model") - command <- paste("SamplesEmbed.SetVariable(", shQuote(node), ")") - .CmdInterpreter(command) - command <- "SamplesEmbed.SampleSize" - .Integer(command) + size <- .OpenBUGS(c(.SamplesGlobalsCmd(node), "SamplesEmbed.SampleSize"), + c("CmdInterpreter","Integer"))[[2]] + size } Modified: trunk/BRugs/R/samples.stats.R =================================================================== --- trunk/BRugs/R/samples.stats.R 2011-07-02 13:49:30 UTC (rev 190) +++ trunk/BRugs/R/samples.stats.R 2011-08-24 18:53:11 UTC (rev 191) @@ -22,7 +22,6 @@ samplesSetLastChain(lastChain) thin <- max(c(thin, 1)) samplesSetThin(thin) - nodeName <- sQuote(node) if (is.R()){ result <- data.frame(mean=NULL, sd=NULL, MC_error = NULL, val2.5pc=NULL, @@ -33,9 +32,8 @@ start = numeric(), sample=numeric()) } - for(i in seq(along=nodeName)){ - command <- paste("SamplesEmbed.SetVariable(", nodeName[i], - ");SamplesEmbed.StatsGuard;SamplesEmbed.Stats") + for(i in seq(along=node)){ + command <- paste(.SamplesGlobalsCmd(node), "SamplesEmbed.StatsGuard;SamplesEmbed.Stats") .CmdInterpreter(command) buffer <- file.path(tempdir(), "buffer.txt") rlb <- readLines(buffer) @@ -44,9 +42,9 @@ result <- rbind(result, read.table(buffer)) else{ if(length(grep("val97.5pc", rlb))) - message("Variable ", nodeName[i], " has probably not been updated") + message("Variable ", node[i], " has probably not been updated") else - message("Variable ", nodeName[i], ": ", rlb) + message("Variable ", node[i], ": ", rlb) } } return(result) Modified: trunk/BRugs/R/set.values.R =================================================================== --- trunk/BRugs/R/set.values.R 2011-07-02 13:49:30 UTC (rev 190) +++ trunk/BRugs/R/set.values.R 2011-08-24 18:53:11 UTC (rev 191) @@ -8,19 +8,16 @@ # if(any(DoNotSetNA)) # warning("Some NA values formerly had a non-NA value -- left unchanged") # values[DoNotSetNA] <- cv[DoNotSetNA] - if (dimensions(nodeLabel) == 0) - stop("Only allowed for vector, not scalar nodes") - command <- "BugsRobjects.SetVariable" - .C("CharArray", command, nchar(command), nodeLabel, nchar(nodeLabel), integer(1), PACKAGE="BRugs") - command <- "BugsRobjects.GetSize" - nodeSize <- .Integer(command) + nodeSize <- .OpenBUGS(c("BugsRobjects.SetVariable", "BugsRobjects.GetSize"), + c("CharArray","Integer"), + c(nodeLabel,NA))[[2]] if(nodeSize == -1) stop(nodeLabel, " is not a node in BUGS model") - if(length(values) != nodeSize) - stop("length(values) does not correspond to the node size") - command <- "BugsRobjects.SetValues" - res <- .C("RealArray", command, nchar(command), as.double(values), as.integer(nodeSize), - integer(1), NAOK = TRUE, PACKAGE="BRugs") - handleRes(res[[5]]) + numChains <- getNumChains() + if(length(values) != nodeSize*numChains) + stop("length(values) does not correspond to the node size and number of chains") + .OpenBUGS(c("BugsRobjects.SetVariable", "BugsRobjects.SetValues"), + c("CharArray","RealArray"), + list(nodeLabel,as.double(values)))[[2]] invisible() } Modified: trunk/BRugs/R/unix/help.R =================================================================== --- trunk/BRugs/R/unix/help.R 2011-07-02 13:49:30 UTC (rev 190) +++ trunk/BRugs/R/unix/help.R 2011-08-24 18:53:11 UTC (rev 191) @@ -24,6 +24,6 @@ "switch to its window."), exdent = 4)) writeLines("Otherwise, be patient ...") - browseURL(system.file("OpenBUGS", "Manuals", "Contents.html", package="BRugs")) + browseURL(file.path(options()$OpenBUGSdoc, "Manuals", "Contents.html")) invisible("") } Added: trunk/BRugs/R/unix/internal.R =================================================================== --- trunk/BRugs/R/unix/internal.R (rev 0) +++ trunk/BRugs/R/unix/internal.R 2011-08-24 18:53:11 UTC (rev 191) @@ -0,0 +1,36 @@ +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 +} Added: trunk/BRugs/R/unix/zzz.R =================================================================== --- trunk/BRugs/R/unix/zzz.R (rev 0) +++ trunk/BRugs/R/unix/zzz.R 2011-08-24 18:53:11 UTC (rev 191) @@ -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 = "/usr/local/lib/OpenBUGS") + 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 <- sub("OpenBUGS version (([0-9]\\.)+[0-9]).+","\\1",ver[1]) + packageStartupMessage("Welcome to BRugs running on OpenBUGS version ", ver) + } + + ".onUnload" <- function(libpath){ + } + + ## Windows-only + loadOpenBUGS <- function(dir) { + } +} Added: trunk/BRugs/R/unix/zzz.R.in =================================================================== --- trunk/BRugs/R/unix/zzz.R.in (rev 0) +++ trunk/BRugs/R/unix/zzz.R.in 2011-08-24 18:53:11 UTC (rev 191) @@ -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() + 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) + } + + ".onUnload" <- function(libpath){ + } + + ## Windows-only + loadOpenBUGS <- function(dir) { + } +} Modified: trunk/BRugs/R/windows/help.R =================================================================== --- trunk/BRugs/R/windows/help.R 2011-07-02 13:49:30 UTC (rev 190) +++ trunk/BRugs/R/windows/help.R 2011-08-24 18:53:11 UTC (rev 191) @@ -2,7 +2,7 @@ { ## stolen from help.start() # a <- system.file("OpenBUGS", "Manuals", "WinBUGS Manual.html", package="BRugs") - # if (!file.exists(a)) + # if (!file.exists(a)) # stop("I can't find the html help") # a <- chartr("/", "\\", a) # message("If nothing happens, you should open `", a, "' yourself") @@ -15,9 +15,9 @@ help.WinBUGS <- function(browser = getOption("browser")) { # stolen from help.start() - a <- system.file("OpenBUGS", "Manuals", "Contents.html", package="BRugs") - if (!file.exists(a)) - stop("I can't find the html help") + a <- file.path(options()$OpenBUGS, "Manuals", "Contents.html") + if (!file.exists(a)) + stop("HTML help not found in file ", a) if (is.R()) a <- chartr("/", "\\", a) else Added: trunk/BRugs/R/windows/internal.R =================================================================== --- trunk/BRugs/R/windows/internal.R (rev 0) +++ trunk/BRugs/R/windows/internal.R 2011-08-24 18:53:11 UTC (rev 191) @@ -0,0 +1,32 @@ +### Run a list of OpenBUGS API command strings + +.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]] + }) + + } + out +} Added: trunk/BRugs/R/windows/zzz.R =================================================================== --- trunk/BRugs/R/windows/zzz.R (rev 0) +++ trunk/BRugs/R/windows/zzz.R 2011-08-24 18:53:11 UTC (rev 191) @@ -0,0 +1,68 @@ +if (is.R()){ + + ".onLoad" <- function(lib, pkg){ + if(.Platform[["r_arch"]] != "i386") + stop("BRugs only works for 32-bit R") + dir <- Sys.getenv("BRUGS_PATH") + if(!nchar(dir)){ + ob.reg <- try(utils:::readRegistry("Software\\OpenBUGS", "HLM", view = "32-bit"), silent = TRUE) + if (inherits(ob.reg, "try-error")) { + warning("OpenBUGS 3.2.1 or greater must be installed\n(if so, this indicates missing registry keys of OpenBUGS).\nSetting the environment variable 'BRUGS_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) + veri <- gsub("(.+)e$","\\1", ver) + version.inst <- as.numeric(paste(substr(veri, 1, 2), gsub("\\.","",substr(veri, 3, nchar(veri))), sep="")) + deps <- utils:::packageDescription("BRugs", fields="SystemRequirements") + ver <- gsub(".*OpenBUGS ?\\(>= ?(.+)\\).*", "\\1", deps) + version.req <- as.numeric(paste(substr(ver, 1, 2), gsub("\\.","",substr(ver, 3, nchar(ver))), sep="")) + if (max(version.inst) < version.req) { + warning("Found OpenBUGS version ", version.inst, ". Requires ", version.req, " or greater") + return() + } + ## OpenBUGS installation location + dir <- utils:::readRegistry(paste("Software","OpenBUGS",rnames[which.max(version.inst)],sep="\\"),"HLM")$InstallPath + loadOpenBUGS(dir) + packageStartupMessage("Welcome to BRugs running on OpenBUGS version ", veri[which.max(version.inst)]) + } else { + if(!file.exists(file.path(dir, "libOpenBUGS.dll"))){ + warning("Environment variable BRUGS_PATH found but cannot access ", file.path(dir, "libOpenBUGS.dll")) + return() + } + loadOpenBUGS(dir) + packageStartupMessage("Welcome to BRugs connected to OpenBUGS in\n", dir) + } + } + + ## 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() + } + + ".onUnload" <- function(libpath){ + if(is.loaded("CmdInterpreter")) { + libname <- paste(options()$OpenBUGS, "libOpenBUGS.dll", sep="/") + dyn.unload(libname) + } + } + +} Modified: trunk/BRugs/R/zzz.R =================================================================== --- trunk/BRugs/R/zzz.R 2011-07-02 13:49:30 UTC (rev 190) +++ trunk/BRugs/R/zzz.R 2011-08-24 18:53:11 UTC (rev 191) @@ -1,32 +1,23 @@ +## See unix/zzz.R, windows/zzz.R for platform specific .onLoad functions + if (is.R()){ - ".onLoad" <- function(lib, pkg){ - ## sets path / file variables and initializes subsystems - root <- file.path(system.file("OpenBUGS", package=pkg)) - ## we do have a NAMESPACE now: library.dynam("BRugs", pkg, lib) - len <- nchar(root) - tempDir <- gsub("\\\\", "/", tempdir()) - .C("SetWorkingDir", as.character(root), len, PACKAGE="BRugs") - .C("SetTempDir", as.character(tempDir), nchar(tempDir), PACKAGE="BRugs") - command <- "BugsMappers.SetDest(2)" - .CmdInterpreter(command) - if(is.null(getOption("BRugsVerbose"))) - options("BRugsVerbose" = TRUE) + .initGlobals <- function(){ + options("BRugsSamplesBeg" = 1) + options("BRugsSamplesEnd" = 10000000) + options("BRugsSamplesFirstChain" = 1) + options("BRugsSamplesLastChain" = 1) + options("BRugsSamplesThin" = 1) + options("BRugsSamplesVariable" = "*") + options("BRugsNextChain" = 1) # index of chain which needs to be initialized next + options("BRugsPrec" = 4) } - - ".onAttach" <- function(lib, pkg){ - message("Welcome to BRugs running on OpenBUGS version 3.1.0") - } - - ".onUnload" <- function(libpath){ - library.dynam.unload("BRugs", libpath) - } ## Overwriting new (from R-2.6.0) sQuote (for typing human readable text) in R within the BRugs Namespace! ## we cannot use sQuote that uses fancy quotes! sQuote <- function(x) paste("'", x, "'", sep="") - + } else { # ends if (is.R()) ".First.lib" <- function(lib.loc, section) @@ -41,12 +32,12 @@ command <- "BugsMappers.SetDest(2)" .C("CmdInterpreter", as.character(command), nchar(command), integer(1)) if(is.null(getOption("BRugsVerbose"))) - options("BRugsVerbose" = TRUE) + options("BRugsVerbose" = TRUE) invisible() } - + .tempDir <- getwd() - + tempdir <- function(){ .tempDir } } # ends else Modified: trunk/BRugs/configure =================================================================== --- trunk/BRugs/configure 2011-07-02 13:49:30 UTC (rev 190) +++ trunk/BRugs/configure 2011-08-24 18:53:11 UTC (rev 191) @@ -1,3 +1,5027 @@ -echo "Package 'BRugs' currently only works under Windows.\nIt is supposed to work under Linux in future releases." -exit 1 - +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.65 for BRugs 0.7. +# +# +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o)... [truncated message content] |
From: <li...@us...> - 2011-07-02 13:49:36
|
Revision: 190 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=190&view=rev Author: ligges Date: 2011-07-02 13:49:30 +0000 (Sat, 02 Jul 2011) Log Message: ----------- forgot to initialize object Modified Paths: -------------- trunk/R2WinBUGS/R/openbugs.R Modified: trunk/R2WinBUGS/R/openbugs.R =================================================================== --- trunk/R2WinBUGS/R/openbugs.R 2011-05-25 18:31:52 UTC (rev 189) +++ trunk/R2WinBUGS/R/openbugs.R 2011-07-02 13:49:30 UTC (rev 190) @@ -19,6 +19,7 @@ parametersToSave <- parameters.to.save ## Move to working drirectory or temporary directory when NULL + inTempDir <- FALSE if(is.null(working.directory)) { working.directory <- tempdir() inTempDir <- TRUE This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <snt...@us...> - 2011-05-25 18:31:58
|
Revision: 189 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=189&view=rev Author: snthomas99 Date: 2011-05-25 18:31:52 +0000 (Wed, 25 May 2011) Log Message: ----------- add = to version number in bugs documenation Modified Paths: -------------- trunk/R2OpenBUGS/man/bugs.Rd Modified: trunk/R2OpenBUGS/man/bugs.Rd =================================================================== --- trunk/R2OpenBUGS/man/bugs.Rd 2011-05-25 17:48:35 UTC (rev 188) +++ trunk/R2OpenBUGS/man/bugs.Rd 2011-05-25 18:31:52 UTC (rev 189) @@ -144,7 +144,7 @@ BUGS version support: \itemize{ - \item{\pkg{OpenBUGS} }{>3.2.1} + \item{\pkg{OpenBUGS} }{>=3.2.1} } Operation system support: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <snt...@us...> - 2011-05-25 17:48:41
|
Revision: 188 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=188&view=rev Author: snthomas99 Date: 2011-05-25 17:48:35 +0000 (Wed, 25 May 2011) Log Message: ----------- Updated documenation for the bugs function Modified Paths: -------------- trunk/R2OpenBUGS/man/bugs.Rd Modified: trunk/R2OpenBUGS/man/bugs.Rd =================================================================== --- trunk/R2OpenBUGS/man/bugs.Rd 2011-04-21 16:51:36 UTC (rev 187) +++ trunk/R2OpenBUGS/man/bugs.Rd 2011-05-25 17:48:35 UTC (rev 188) @@ -144,7 +144,7 @@ BUGS version support: \itemize{ - \item{\pkg{OpenBUGS} }{>3.1} + \item{\pkg{OpenBUGS} }{>3.2.1} } Operation system support: @@ -161,7 +161,7 @@ Windows path style (e.g. \dQuote{c:/Program Files/OpenBUGS/}) or native (Unix) style (e.g. \dQuote{/path/to/wine/folder/dosdevices/c:/Program - Files/OpenBUGS/OpenBUGS311/OpenBUGS.exe}). + Files/OpenBUGS/OpenBUGS321/OpenBUGS.exe}). } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2011-04-21 16:51:43
|
Revision: 187 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=187&view=rev Author: chris-jackson Date: 2011-04-21 16:51:36 +0000 (Thu, 21 Apr 2011) Log Message: ----------- Changes for version 0.7 1 (see NEWS) Modified Paths: -------------- branches/linux/BRugs/DESCRIPTION branches/linux/BRugs/NAMESPACE branches/linux/BRugs/NEWS branches/linux/BRugs/R/bugs.data.R branches/linux/BRugs/R/internal.R branches/linux/BRugs/R/unix/help.R branches/linux/BRugs/R/unix/zzz.R branches/linux/BRugs/R/unix/zzz.R.in branches/linux/BRugs/R/windows/zzz.R branches/linux/BRugs/configure branches/linux/BRugs/configure.ac branches/linux/BRugs/src/Makevars branches/linux/BRugs/tests/BRugs.R branches/linux/BRugs/tests/examples.R branches/linux/BRugs/tests/functions.R Added Paths: ----------- branches/linux/BRugs/man/windows/ branches/linux/BRugs/man/windows/loadOpenBUGS.Rd Modified: branches/linux/BRugs/DESCRIPTION =================================================================== --- branches/linux/BRugs/DESCRIPTION 2011-04-21 15:52:16 UTC (rev 186) +++ branches/linux/BRugs/DESCRIPTION 2011-04-21 16:51:36 UTC (rev 187) @@ -1,8 +1,8 @@ Package: BRugs Title: R interface to the OpenBUGS MCMC software -Version: 0.7 -Date: 2011-03-07 -Author: OpenBUGS was developed by Andrew Thomas, Dave Lunn, David Spiegelhalter and Nicky Best. R interface developed by Uwe Ligges, Sibylle Sturtz, Andrew Gelman, Gregor Gorjanc and Chris Jackson. Linux port and most recent developments by Chris Jackson. +Version: 0.7.1 +Date: 2011-04-19 +Author: OpenBUGS was developed by Andrew Thomas, Dave Lunn, David Spiegelhalter and Nicky Best. R interface developed by Uwe Ligges, Sibylle Sturtz, Andrew Gelman, Gregor Gorjanc and Chris Jackson. Linux port and most recent developments by Chris Jackson. Description: Fully-interactive R interface to the OpenBUGS software for Bayesian analysis using MCMC sampling Maintainer: Chris Jackson <chr...@mr...> Depends: R (>= 2.5.0), utils, coda Modified: branches/linux/BRugs/NAMESPACE =================================================================== --- branches/linux/BRugs/NAMESPACE 2011-04-21 15:52:16 UTC (rev 186) +++ branches/linux/BRugs/NAMESPACE 2011-04-21 16:51:36 UTC (rev 187) @@ -4,6 +4,7 @@ getNumChains, help.BRugs, help.WinBUGS, infoMemory,infoModules,infoNodeValues,infoNodeMethods,infoNodeTypes, infoUpdatersbyName,infoUpdatersbyDepth, +loadOpenBUGS, modelAdaptivePhase, modelCheck, modelCompile, modelData, modelGenInits, modelInits, modelIteration, modelNames, modelPrecision, modelSaveState, Modified: branches/linux/BRugs/NEWS =================================================================== --- branches/linux/BRugs/NEWS 2011-04-21 15:52:16 UTC (rev 186) +++ branches/linux/BRugs/NEWS 2011-04-21 16:51:36 UTC (rev 187) @@ -1,8 +1,27 @@ -Version 0.7 +Version 0.7.1 (19 April 2011) +------------- + +The configure script on Linux now automatically detects OpenBUGS +installed by the RPM and DEB packages (to standards-compliant +locations) as well as OpenBUGS installed by the source package. + +Bug fix - bugsData should accept data as a list of variable names. +Thanks to Brian Ripley for these reports. + +handleRes() now explicitly labels internal OpenBUGS traps as bugs and +asks the user to send a bug report to the package maintainer. + +On Windows, if OpenBUGS installation is not detected in the registry, +package loading continues with a warning instead of stopping with an +error. If OpenBUGS was actually installed, the user can then load it +from a specified directory with loadOpenBUGS(dir). + + +Version 0.7 (March 2011) ----------- BRugs now works with an existing installation of OpenBUGS (3.2.1 or -later) instead of being distributed with the OpenBUGS library. +later) instead of being distributed with the OpenBUGS library. On Windows, the OpenBUGS location is determined by a registry key which is installed by the OpenBUGS for Windows installation program. @@ -12,25 +31,25 @@ for Linux source package OpenBUGS-3.2.1.tar.gz or later, this library directory is by default -/usr/local/lib/OpenBUGS +/usr/local/lib/OpenBUGS In most cases it should be detected automatically when installing, but it can be changed by running, for instance -R CMD INSTALL --configure-args='--with-openbugs=/usr/lib/OpenBUGS' +R CMD INSTALL --configure-args='--with-openbugs=/usr/lib/OpenBUGS' Version 0.61 ------------ -Fix for crash in bugsData +Fix for crash in bugsData -Version 0.6 +Version 0.6 ----------- Forked from the version of BRugs (0.5.3) available on CRAN Extras. -This new version supports Linux for the first time, as detailed below. +This new version supports Linux for the first time, as detailed below. CHANGES MADE FOR LINUX PORT OF BRugs @@ -40,7 +59,7 @@ any number of different OpenBUGS API commands can be run. The state of the model is "internalized" on entry from a file in the temporary directory, and "externalized" on exit. The source is in src/ and - the binary is installed into exec/. + the binary is installed into exec/. * New function .OpenBUGS() to execute a sequence of OpenBUGS API commands of possibly differing types (e.g. CmdInterpreter, Modified: branches/linux/BRugs/R/bugs.data.R =================================================================== --- branches/linux/BRugs/R/bugs.data.R 2011-04-21 15:52:16 UTC (rev 186) +++ branches/linux/BRugs/R/bugs.data.R 2011-04-21 16:51:36 UTC (rev 187) @@ -1,28 +1,29 @@ "bugsData" <- -function(data, fileName = file.path(tempdir(), "data.txt"), format="E", digits = 5){ - if(is.list(data)) { - data <- lapply(data, function(x){x <- if(is.character(x)||is.factor(x)) match(x, unique(x)) else x}) - if(is.R()) { - write.datafile(lapply(data, formatC, digits = digits, format = format), fileName) + function(data, fileName = file.path(tempdir(), "data.txt"), format="E", digits = 5){ + if (is.character(unlist(data))) { + 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 = format), fileName) + } + else { + data.list <- lapply(as.list(data), get, where = parent.frame(2)) + names(data.list) <- unlist(data) + writeDatafileS4(data.list, towhere = "data.txt") + } } - else { - writeDatafileS4(data, towhere = "data.txt") + else if(is.list(data)) { + data <- lapply(data, function(x){x <- if(is.character(x)||is.factor(x)) match(x, unique(x)) else x}) + if(is.R()) { + write.datafile(lapply(data, formatC, digits = digits, format = format), fileName) + } + else { + writeDatafileS4(data, towhere = "data.txt") + } } - } - 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 = format), fileName) - } - else { - data.list <- lapply(as.list(data), get, where = parent.frame(2)) - names(data.list) <- unlist(data) - writeDatafileS4(data.list, towhere = "data.txt") - } + else stop("Expected a list of data, a list or vector of variable names") + invisible(fileName) } - invisible(fileName) -} if(is.R()){ Modified: branches/linux/BRugs/R/internal.R =================================================================== --- branches/linux/BRugs/R/internal.R 2011-04-21 15:52:16 UTC (rev 186) +++ branches/linux/BRugs/R/internal.R 2011-04-21 16:51:36 UTC (rev 187) @@ -34,10 +34,12 @@ handleRes <- function(res) { - switch(res, - stop("An OpenBUGS module or procedure was called that did not exist."), - stop("An OpenBUGS procedure was called with the wrong type of argument."), - stop("An OpenBUGS procedure was called with the wrong signature.")) + 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) + ) } .SamplesGlobalsCmd <- function(node){ Modified: branches/linux/BRugs/R/unix/help.R =================================================================== --- branches/linux/BRugs/R/unix/help.R 2011-04-21 15:52:16 UTC (rev 186) +++ branches/linux/BRugs/R/unix/help.R 2011-04-21 16:51:36 UTC (rev 187) @@ -24,6 +24,6 @@ "switch to its window."), exdent = 4)) writeLines("Otherwise, be patient ...") - browseURL(paste(options()$OpenBUGS, "doc", "Manuals", "Contents.html", sep="/")) + browseURL(paste(options()$OpenBUGSdoc, "Manuals", "Contents.html", sep="/")) invisible("") } Modified: branches/linux/BRugs/R/unix/zzz.R =================================================================== --- branches/linux/BRugs/R/unix/zzz.R 2011-04-21 15:52:16 UTC (rev 186) +++ branches/linux/BRugs/R/unix/zzz.R 2011-04-21 16:51:36 UTC (rev 187) @@ -5,12 +5,13 @@ options("BRugsTmpdir" = gsub("\\\\", "/", tempdir())) options("BRugsExtFile" = paste(basename(tempfile()), ".bug", sep="")) options(OpenBUGS = "/usr/local/lib/OpenBUGS") + options(OpenBUGSdoc = "/usr/local/lib/OpenBUGS/doc") + options(OpenBUGSExamples = paste(options()$OpenBUGSdoc, "Examples", sep="/")) if(is.null(getOption("BRugsVerbose"))) options("BRugsVerbose" = TRUE) .initGlobals() - options(OpenBUGSExamples = paste(options()$OpenBUGS, "doc", "Examples", sep="/")) - ver <- system("echo \"modelQuit()\" | OpenBUGS", intern=TRUE) + ver <- system("echo \"modelQuit()\" | /usr/local/lib/OpenBUGS/bin/OpenBUGS", intern=TRUE) ver <- sub("OpenBUGS version (([0-9]\\.)+[0-9]).+","\\1",ver[1]) message("Welcome to BRugs running on OpenBUGS version ", ver) } @@ -18,4 +19,7 @@ ".onUnload" <- function(libpath){ } + ## Windows-only + loadOpenBUGS <- function(dir) { + } } Modified: branches/linux/BRugs/R/unix/zzz.R.in =================================================================== --- branches/linux/BRugs/R/unix/zzz.R.in 2011-04-21 15:52:16 UTC (rev 186) +++ branches/linux/BRugs/R/unix/zzz.R.in 2011-04-21 16:51:36 UTC (rev 187) @@ -5,12 +5,13 @@ 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() - options(OpenBUGSExamples = paste(options()$OpenBUGS, "doc", "Examples", sep="/")) - ver <- system("echo \"modelQuit()\" | OpenBUGS", intern=TRUE) + ver <- system("echo \"modelQuit()\" | @OPENBUGS@/bin/OpenBUGS", intern=TRUE) ver <- sub("OpenBUGS version (([0-9]\\.)+[0-9]).+","\\1",ver[1]) message("Welcome to BRugs running on OpenBUGS version ", ver) } @@ -18,4 +19,7 @@ ".onUnload" <- function(libpath){ } + ## Windows-only + loadOpenBUGS <- function(dir) { + } } Modified: branches/linux/BRugs/R/windows/zzz.R =================================================================== --- branches/linux/BRugs/R/windows/zzz.R 2011-04-21 15:52:16 UTC (rev 186) +++ branches/linux/BRugs/R/windows/zzz.R 2011-04-21 16:51:36 UTC (rev 187) @@ -4,7 +4,7 @@ ob.reg <- try(utils:::readRegistry("Software\\OpenBUGS","HLM")) if (inherits(ob.reg, "try-error")) { warning("OpenBUGS 3.2.1 or greater must be installed") - return + return() } rnames <- names(ob.reg) ver <- gsub("OpenBUGS ", "", rnames) @@ -15,7 +15,7 @@ version.req <- as.numeric(paste(substr(ver, 1, 2), gsub("\\.","",substr(ver, 3, nchar(ver))), sep="")) if (max(version.inst) < version.req) { warning("Found OpenBUGS version ", version.inst, ". Requires ", version.req, " or greater") - return + return() } ## OpenBUGS installation location dir <- utils:::readRegistry(paste("Software","OpenBUGS",rnames[which.max(version.inst)],sep="\\"),"HLM")$InstallPath @@ -28,9 +28,9 @@ libname <- paste(dir, "libOpenBUGS.dll", sep="/") if (!file.exists(libname)) { warning("Shared library \"libOpenBUGS.dll\" not found in ", dir) + return(FALSE) } options(OpenBUGS = dir) - ## All checks passed - load the DLL dyn.load(libname) len <- nchar(dir) .C("SetWorkingDir", as.character(dir), len, PACKAGE="libOpenBUGS") @@ -43,6 +43,7 @@ options("BRugsVerbose" = TRUE) .initGlobals() options(OpenBUGSExamples = paste(dir, "Examples", sep="/")) + invisible() } ".onUnload" <- function(libpath){ Modified: branches/linux/BRugs/configure =================================================================== --- branches/linux/BRugs/configure 2011-04-21 15:52:16 UTC (rev 186) +++ branches/linux/BRugs/configure 2011-04-21 16:51:36 UTC (rev 187) @@ -556,6 +556,7 @@ ac_default_prefix=/usr/local ac_subst_vars='LTLIBOBJS LIBOBJS +OPENBUGSDOC OPENBUGS OBJEXT EXEEXT @@ -1225,9 +1226,8 @@ Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) - --with-openbugs=LIB_PATH - the location of the OpenBUGS installation, by - default /usr/local/lib/OpenBUGS + --with-openbugs=PATH the location of OpenBUGS installed from the source + package, by default /usr/local/lib/OpenBUGS Some influential environment variables: CC C compiler command @@ -1753,9 +1753,19 @@ -## TODO only runs on x86 Linux - give error on other unixes +## Work around the inconsistency between the installation destinations of the 3.2.1 source and binary packages. +## Source installs library in $prefix/lib/OpenBUGS/lib, doc in $prefix/lib/OpenBUGS/doc. +## Binaries install in standards-compliant locations $prefix/lib and $prefix/share/doc/openbugs-version respectively. +## Look in all of these places. +## Return OPENBUGS = $prefix/lib/OpenBUGS for source installations, and +## OPENBUGS = $prefix for binary installations. +## Return OPENBUGSDOC = $prefix/lib/OpenBUGS/doc for source installations, +## and OPENBUGSDOC = $prefix/share/doc/openbugs-version for binary installations. +## If user specifies -with-openbugs, this is interpreted for a source installation. +## TODO only runs on x86 Linux - give error on other unixes. + if test "x$prefix" = xNONE; then $as_echo_n "checking for prefix by " >&6 # Extract the first word of "OpenBUGS", so it can be a program name with args. @@ -1858,18 +1868,23 @@ if test -n "$openbugs_path" ; then OPENBUGS=${openbugs_path} + SOURCEINST=true else - echo ${prefix} - if test "${prefix}" = "NONE" ; then - as_fn_error "\"OpenBUGS installation not found in the default /usr/local/lib/OpenBUGS. Run R CMD INSTALL BRugs --configure-args=' --with-openbugs=...'\"" "$LINENO" 5 + if test "$prefix" = "NONE" ; then + as_fn_error "OpenBUGS not found. Install OpenBUGS 3.2.1 or later, or specify its location using, for example, R CMD INSTALL BRugs --configure-args='--with-openbugs=/usr/local/lib/OpenBUGS' " "$LINENO" 5 else - OPENBUGS=${prefix}/lib/OpenBUGS + if test -e ${prefix}/lib/OpenBUGS/lib/libOpenBUGS.so ; then + OPENBUGS=${prefix}/lib/OpenBUGS + SOURCEINST=true + else + OPENBUGS=${prefix} + SOURCEINST=false + fi fi fi OLDFLAGS=${LDFLAGS} LDFLAGS="-L${OPENBUGS}/lib -m32" -echo $LDFLAGS ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -2706,19 +2721,31 @@ LIBS="-lOpenBUGS $LIBS" else - as_fn_error "\"Cannot load OpenBUGS library in lib subdirectory of ${OPENBUGS}. Run R CMD INSTALL BRugs --configure-args='--with-openbugs=...'\"" "$LINENO" 5 + as_fn_error "\"Cannot load OpenBUGS library in ${OPENBUGS}/lib. Run R CMD INSTALL BRugs --configure-args='--with-openbugs=...'\"" "$LINENO" 5 fi LDFLAGS=${OLDFLAGS} -## TODO any need to check for version? -## could do with -#VERSION=`echo "modelQuit()" | OpenBUGS | sed -ne "s/OpenBUGS version \(.*\) rev \(.*\)/\1/p` -#if test `echo $VERSION |cut -d. -f1` -lt 3 then; echo "Requires OpenBUGS version 3.2.1 or greater"; exit 1; fi -#if test `echo $VERSION |cut -d. -f2` -lt 2 then; echo "Requires OpenBUGS version 3.2.1 or greater"; exit 1; fi -#if test `echo $VERSION |cut -d. -f3` -lt 1 then; echo "Requires OpenBUGS version 3.2.1 or greater"; exit 1; fi +if ${SOURCEINST} ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: Found OpenBUGS installation from source package " >&5 +$as_echo "$as_me: Found OpenBUGS installation from source package " >&6;} + OPENBUGSDOC=${OPENBUGS}/doc +else + { $as_echo "$as_me:${as_lineno-$LINENO}: Found OpenBUGS installation from binary package " >&5 +$as_echo "$as_me: Found OpenBUGS installation from binary package " >&6;} + OPENBUGSDOC=${OPENBUGS}/share/doc/openbugs-${VERSION} +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 + + ac_config_files="$ac_config_files src/Makevars" cat >confcache <<\_ACEOF Modified: branches/linux/BRugs/configure.ac =================================================================== --- branches/linux/BRugs/configure.ac 2011-04-21 15:52:16 UTC (rev 186) +++ branches/linux/BRugs/configure.ac 2011-04-21 16:51:36 UTC (rev 187) @@ -1,40 +1,65 @@ AC_INIT([BRugs], [0.7]) -## TODO only runs on x86 Linux - give error on other unixes +## Work around the inconsistency between the installation destinations of the 3.2.1 source and binary packages. +## Source installs library in $prefix/lib/OpenBUGS/lib, doc in $prefix/lib/OpenBUGS/doc. +## Binaries install in standards-compliant locations $prefix/lib and $prefix/share/doc/openbugs-version respectively. +## Look in all of these places. +## Return OPENBUGS = $prefix/lib/OpenBUGS for source installations, and +## OPENBUGS = $prefix for binary installations. +## Return OPENBUGSDOC = $prefix/lib/OpenBUGS/doc for source installations, +## and OPENBUGSDOC = $prefix/share/doc/openbugs-version for binary installations. +## If user specifies -with-openbugs, this is interpreted for a source installation. +## TODO only runs on x86 Linux - give error on other unixes. + AC_PREFIX_DEFAULT(/usr/local) AC_PREFIX_PROGRAM([OpenBUGS]) AC_ARG_WITH([openbugs], - AC_HELP_STRING([--with-openbugs=LIB_PATH], - [the location of the OpenBUGS installation, by default /usr/local/lib/OpenBUGS]), + AC_HELP_STRING([--with-openbugs=PATH], + [the location of OpenBUGS installed from the source package, by default /usr/local/lib/OpenBUGS]), [openbugs_path=$withval]) if test [ -n "$openbugs_path" ] ; then OPENBUGS=${openbugs_path} + SOURCEINST=true else - echo ${prefix} - if test [ "${prefix}" = "NONE" ] ; then - AC_MSG_ERROR("OpenBUGS installation not found in the default /usr/local/lib/OpenBUGS. Run R CMD INSTALL BRugs --configure-args=' --with-openbugs=...'") + if test [ "$prefix" = "NONE" ]; then + AC_MSG_ERROR( [OpenBUGS not found. Install OpenBUGS 3.2.1 or later, or specify its location using, for example, R CMD INSTALL BRugs --configure-args='--with-openbugs=/usr/local/lib/OpenBUGS'] ) else - OPENBUGS=${prefix}/lib/OpenBUGS + if test [ -e ${prefix}/lib/OpenBUGS/lib/libOpenBUGS.so ] ; then + OPENBUGS=${prefix}/lib/OpenBUGS + SOURCEINST=true + else + OPENBUGS=${prefix} + SOURCEINST=false + fi fi fi OLDFLAGS=${LDFLAGS} LDFLAGS="-L${OPENBUGS}/lib -m32" -echo $LDFLAGS AC_CHECK_LIB(OpenBUGS, CmdInterpreter, [], - [AC_MSG_ERROR("Cannot load OpenBUGS library in lib subdirectory of ${OPENBUGS}. Run R CMD INSTALL BRugs --configure-args='--with-openbugs=...'")]) + [AC_MSG_ERROR("Cannot load OpenBUGS library in ${OPENBUGS}/lib. Run R CMD INSTALL BRugs --configure-args='--with-openbugs=...'")]) LDFLAGS=${OLDFLAGS} -## TODO any need to check for version? -## could do with -#VERSION=`echo "modelQuit()" | OpenBUGS | sed -ne "s/OpenBUGS version \(.*\) rev \(.*\)/\1/p` -#if test `echo $VERSION |cut -d. -f1` -lt 3 then; echo "Requires OpenBUGS version 3.2.1 or greater"; exit 1; fi -#if test `echo $VERSION |cut -d. -f2` -lt 2 then; echo "Requires OpenBUGS version 3.2.1 or greater"; exit 1; fi -#if test `echo $VERSION |cut -d. -f3` -lt 1 then; echo "Requires OpenBUGS version 3.2.1 or greater"; exit 1; 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 + AC_MSG_ERROR([Requires OpenBUGS version 3.2.1 or greater]) +fi +if test [ `echo ${VERSION} |cut -d. -f1` -eq 3 -a `echo ${VERSION} |cut -d. -f2` -lt 2 ]; then + AC_MSG_ERROR([Requires OpenBUGS version 3.2.1 or greater]) +fi +if [ ${SOURCEINST} ] ; then + AC_MSG_NOTICE( [Found OpenBUGS installation from source package] ) + OPENBUGSDOC=${OPENBUGS}/doc +else + AC_MSG_NOTICE( [Found OpenBUGS installation from binary package] ) + OPENBUGSDOC=${OPENBUGS}/share/doc/openbugs-${VERSION} +fi + AC_SUBST(OPENBUGS) +AC_SUBST(OPENBUGSDOC) AC_OUTPUT(src/Makevars) AC_OUTPUT(R/unix/zzz.R) Added: branches/linux/BRugs/man/windows/loadOpenBUGS.Rd =================================================================== --- branches/linux/BRugs/man/windows/loadOpenBUGS.Rd (rev 0) +++ branches/linux/BRugs/man/windows/loadOpenBUGS.Rd 2011-04-21 16:51:36 UTC (rev 187) @@ -0,0 +1,20 @@ +\name{loadOpenBUGS} +\alias{loadOpenBUGS} +\title{Load OpenBUGS from given directory} +\description{Load OpenBUGS from given directory, in case it was not + detected on installation of BRugs.} +\usage{ +loadOpenBUGS(dir) +} +\arguments{ +\item{dir}{Directory where OpenBUGS is installed, typically something + like \code{"c:/Program Files/OpenBUGS/OpenBUGS321"}. This should + contain the OpenBUGS shared library \code{libOpenBUGS.dll}. } +} +\value{ + Returns silently if the library was loaded successfully. +} +\keyword{interface} +\concept{OpenBUGS} +\concept{WinBUGS} +\concept{MCMC} Modified: branches/linux/BRugs/src/Makevars =================================================================== --- branches/linux/BRugs/src/Makevars 2011-04-21 15:52:16 UTC (rev 186) +++ branches/linux/BRugs/src/Makevars 2011-04-21 16:51:36 UTC (rev 187) @@ -1,5 +1,5 @@ -BUGS_LIBS = /usr/local/lib/OpenBUGS/lib/libOpenBUGS.so -BUGS_LDFLAGS = -m32 -Wl,-rpath=/usr/local/lib/OpenBUGS/lib +BUGS_LIBS = /home/chris/usr/lib/OpenBUGS/lib/libOpenBUGS.so +BUGS_LDFLAGS = -m32 -Wl,-rpath=/home/chris/usr/lib/OpenBUGS/lib BugsHelper: mkdir -p ../exec Modified: branches/linux/BRugs/tests/BRugs.R =================================================================== --- branches/linux/BRugs/tests/BRugs.R 2011-04-21 15:52:16 UTC (rev 186) +++ branches/linux/BRugs/tests/BRugs.R 2011-04-21 16:51:36 UTC (rev 187) @@ -19,4 +19,32 @@ modelUpdate(1000) samplesStats("*") +### Four different ways of supplying the data + +beetles <- 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) + +BRugsFit(data = "Beetlesdata.txt", inits = "Beetlesinits.txt", + para = c("alpha", "beta", "rhat"), modelFile = "Beetlesmodel.txt", + numChains = 1, + working.directory = options()$OpenBUGSExamples) + +BRugsFit(data = beetles, inits = "Beetlesinits.txt", + para = c("alpha", "beta", "rhat"), modelFile = "Beetlesmodel.txt", + numChains = 1, + working.directory = options()$OpenBUGSExamples) + +with(beetles, + BRugsFit(data = list("x", "n", "r", "N"), inits = "Beetlesinits.txt", + para=c("alpha", "beta", "rhat"), modelFile = "Beetlesmodel.txt", + numChains = 1, working.directory = options()$OpenBUGSExamples) + ) + +with(beetles, + BRugsFit(data = c("x", "n", "r", "N"), inits = "Beetlesinits.txt", + para=c("alpha", "beta", "rhat"), modelFile = "Beetlesmodel.txt", + numChains = 1, working.directory = options()$OpenBUGSExamples) + ) + } Modified: branches/linux/BRugs/tests/examples.R =================================================================== --- branches/linux/BRugs/tests/examples.R 2011-04-21 15:52:16 UTC (rev 186) +++ branches/linux/BRugs/tests/examples.R 2011-04-21 16:51:36 UTC (rev 187) @@ -1,6 +1,6 @@ source("local.R") -if (test) { +if (test) { library(BRugs) @@ -32,7 +32,7 @@ test.datafile = paste(test.models,"data.txt",sep="") test.inits = paste(test.models,"inits.txt",sep="") -### Test for posterior means within 1 percent of previously saved values +### Test for posterior means within 10 percent of previously saved values res.true <- dget(file="examples.stats.R") for (i in seq(along=test.models)) { @@ -41,7 +41,7 @@ , working.directory=options()$OpenBUGSExamples ) - stopifnot(isTRUE(all.equal(fit$Stats$mean, res.true[[i]]$Stats$mean, tol=1e-02))) + stopifnot(isTRUE(all.equal(fit$Stats$mean, res.true[[i]]$Stats$mean, tol=1e-01))) } } Modified: branches/linux/BRugs/tests/functions.R =================================================================== --- branches/linux/BRugs/tests/functions.R 2011-04-21 15:52:16 UTC (rev 186) +++ branches/linux/BRugs/tests/functions.R 2011-04-21 16:51:36 UTC (rev 187) @@ -1,6 +1,6 @@ source("local.R") -if (test) { +if (test) { library(BRugs) setwd(options()$OpenBUGSExamples) @@ -71,7 +71,7 @@ stopifnot(isTRUE(all.equal(samplesAutoC("alpha0", 1, plot=interactive())$alpha0$acf[1], 1))) stopifnot(all(dim(samplesBgr("alpha0", plot=interactive())$alpha0)==c(50,4))) stopifnot(all.equal(samplesBgr("alpha0", plot=FALSE)$alpha0$pooled[1], 0.411, tol=0.1)) -stopifnot(isTRUE(all.equal(samplesCorrel("alpha[1]", "alpha[2]")[1,1], 0.8924, tol=0.1))) +# stopifnot(isTRUE(all.equal(samplesCorrel("alpha[1]", "alpha[2]")[1,1], 0.8924, tol=0.1))) stopifnot(all(dim(samplesDensity("alpha", plot=interactive(), ask=FALSE))==c(7,30))) stopifnot(all(dim(plotHistory("alpha0", plot=interactive())[[1]])==c(1000,2))) stopifnot(isTRUE(all.equal(plotAutoC("alpha0", 1, plot=interactive())$acf[1], 1))) @@ -120,7 +120,7 @@ ## Info functions stopifnot(infoNodeMethods("alpha")[,"Type"] == "UpdaterNormal.StdUpdater") -stopifnot(infoNodeTypes("alpha")[1,"Type"]=="GraphNormal.StdNode") +stopifnot(infoNodeTypes("alpha")[1,"Type"]=="GraphNormal.Node") stopifnot(infoUpdatersbyName()["alpha.c","Type"]=="conjugatenormalupdater") stopifnot(infoUpdatersbyDepth()["alpha.c","Type"]=="conjugatenormalupdater") mem <- infoMemory() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <li...@us...> - 2011-04-21 15:52:23
|
Revision: 186 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=186&view=rev Author: ligges Date: 2011-04-21 15:52:16 +0000 (Thu, 21 Apr 2011) Log Message: ----------- changes in CITATION to make R >= 2.12.0 calm for citation() calls Modified Paths: -------------- trunk/BRugs/inst/CITATION trunk/R2OpenBUGS/inst/CITATION trunk/R2WinBUGS/inst/CITATION Modified: trunk/BRugs/inst/CITATION =================================================================== --- trunk/BRugs/inst/CITATION 2011-04-08 13:05:01 UTC (rev 185) +++ trunk/BRugs/inst/CITATION 2011-04-21 15:52:16 UTC (rev 186) @@ -2,11 +2,11 @@ citEntry(entry = "article", title = "Making BUGS Open", - author = personList( - person(first="Andrew", last="Thomas", email=""), - person(first="Bob", last="O'Hara", email=""), - person(first="Uwe", last="Ligges", email="Uwe...@R-..."), - person(first="Sibylle", last="Sturtz", email="st...@st...")), + author = c( + person(given="Andrew", family="Thomas", email=""), + person(given="Bob", family="O'Hara", email=""), + person(given="Uwe", family="Ligges", email="Uwe...@R-..."), + person(given="Sibylle", family="Sturtz", email="st...@st...")), journal = "R News", year = 2006, pages = "12--17", Modified: trunk/R2OpenBUGS/inst/CITATION =================================================================== --- trunk/R2OpenBUGS/inst/CITATION 2011-04-08 13:05:01 UTC (rev 185) +++ trunk/R2OpenBUGS/inst/CITATION 2011-04-21 15:52:16 UTC (rev 186) @@ -2,10 +2,10 @@ citEntry(entry = "article", title = "R2WinBUGS: A Package for Running WinBUGS from R", - author = personList( - person(first="Sibylle", last="Sturtz", email="st...@st..."), - person(first="Uwe", last="Ligges", email="Uwe...@R-..."), - person(first="Andrew", last="Gelman", email="ge...@st...")), + author = c( + person(given="Sibylle", family="Sturtz", email="st...@st..."), + person(given="Uwe", family="Ligges", email="Uwe...@R-..."), + person(given="Andrew", family="Gelman", email="ge...@st...")), journal = "Journal of Statistical Software", year = 2005, pages = "1--16", Modified: trunk/R2WinBUGS/inst/CITATION =================================================================== --- trunk/R2WinBUGS/inst/CITATION 2011-04-08 13:05:01 UTC (rev 185) +++ trunk/R2WinBUGS/inst/CITATION 2011-04-21 15:52:16 UTC (rev 186) @@ -2,10 +2,10 @@ citEntry(entry = "article", title = "R2WinBUGS: A Package for Running WinBUGS from R", - author = personList( - person(first="Sibylle", last="Sturtz", email="st...@st..."), - person(first="Uwe", last="Ligges", email="Uwe...@R-..."), - person(first="Andrew", last="Gelman", email="ge...@st...")), + author = c( + person(given="Sibylle", family="Sturtz", email="st...@st..."), + person(given="Uwe", family="Ligges", email="Uwe...@R-..."), + person(given="Andrew", family="Gelman", email="ge...@st...")), journal = "Journal of Statistical Software", year = 2005, pages = "1--16", This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <snt...@us...> - 2011-04-08 13:05:07
|
Revision: 185 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=185&view=rev Author: snthomas99 Date: 2011-04-08 13:05:01 +0000 (Fri, 08 Apr 2011) Log Message: ----------- adding validateInstallOpenBUGS that was inadvertantly missed in the last commit Added Paths: ----------- trunk/R2OpenBUGS/R/validateInstallOpenBUGS.R trunk/R2OpenBUGS/man/validateInstallOpenBUGS.Rd Added: trunk/R2OpenBUGS/R/validateInstallOpenBUGS.R =================================================================== --- trunk/R2OpenBUGS/R/validateInstallOpenBUGS.R (rev 0) +++ trunk/R2OpenBUGS/R/validateInstallOpenBUGS.R 2011-04-08 13:05:01 UTC (rev 185) @@ -0,0 +1,63 @@ +validateInstallOpenBUGS<-function( + OpenBUGS.pgm=ifelse(.Platform$OS.type == "windows" | useWINE==TRUE, + paste("C:/Program Files/OpenBUGS/OpenBUGS", + version,"/OpenBUGS.exe",sep=""),"OpenBUGS"), + version='321', + OpenBUGS.examples=file.path(dirname(OpenBUGS.pgm),'Examples'), + useWINE=FALSE, WINE=NULL, + newWINE=TRUE, WINEPATH=NULL + ) +{ +## Selected examples which take a few seconds in total to run + +test.models <- c("Air", "Asia", "Beetles", "BiRats", "Camel", + "Dugongs", "Dyes", "Equiv", "Eyes", + "Line", "OtreesMVN", "Rats", "Stacks", + "Surgical", "Surgicalrand") + +test.params <- list(Air = c("X", "theta"), + Asia = c("bronchitis", "either", "lung.cancer"), + Beetles = c("alpha", "beta", "rhat"), + BiRats = c("mu.beta", "sigma"), + Camel = c("Sigma2", "rho", "tau"), + Dugongs = c("U3","alpha", "beta", "gamma", "sigma"), + Dyes = c("sigma2.btw", "sigma2.with", "theta"), + Equiv = c("equiv", "mu", "phi", "pi","sigma1", "sigma2", "theta"), + Eyes = c("P", "lambda", "sigma"), + Line = c("alpha", "beta", "sigma"), + OtreesMVN = c("mu","sigma", "sigmaC"), + Rats = c("alpha0", "beta.c", "sigma"), + Stacks = c("b", "b0", "outlier[21]","outlier[3]", "outlier[4]", "sigma"), + Surgical = "p", + Surgicalrand = c("p","pop.mean", "sigma") + ) + +test.modelfile = paste(test.models,"model.txt",sep="") +test.modelfile<-file.path(OpenBUGS.examples,test.modelfile) +test.datafile = paste(test.models,"data.txt",sep="") +test.datafile<-file.path(OpenBUGS.examples,test.datafile) +test.inits = paste(test.models,"inits.txt",sep="") +test.inits<-file.path(OpenBUGS.examples,test.inits) + +### Test for posterior means within 1 percent of previously saved values + +res.true<-dget(file=system.file("validateInstallOpenBUGS/validOpenBUGSResults.R",package="R2OpenBUGS") ) + +cat("The version of OpenBUGS on your computer is being compared to validation\n", + "results created using OpenBUGS version 3.2.1\n") + +for (i in seq(along=test.models)) { + 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)$summary,5) + if(isTRUE(all.equal(fit,res.true[[i]],tol=1e-2))){ + cat(paste('Results matched for example',test.models[[i]],'\n',sep=' ')) + } else{ + cat(paste('Results did not match for example',test.models[[i]],'\n',sep=' ')) + } + flush.console() +} + return(invisible()) +} + + Property changes on: trunk/R2OpenBUGS/R/validateInstallOpenBUGS.R ___________________________________________________________________ Added: svn:executable + * Added: trunk/R2OpenBUGS/man/validateInstallOpenBUGS.Rd =================================================================== --- trunk/R2OpenBUGS/man/validateInstallOpenBUGS.Rd (rev 0) +++ trunk/R2OpenBUGS/man/validateInstallOpenBUGS.Rd 2011-04-08 13:05:01 UTC (rev 185) @@ -0,0 +1,81 @@ +\name{validateInstallOpenBUGS} +\alias{validateInstallOpenBUGS} +\title{Compare OpenBUGS/R2OpenBUGS execution to results supplied with OpenBUGS} + +\description{A selected subset of the examples from the OpenBUGS manual is +executed and compared to results supplied with the package to validate +installation.} + +\usage{ +validateInstallOpenBUGS( + OpenBUGS.pgm=ifelse(.Platform$OS.type == "windows" | useWINE==TRUE, + paste("C:/Program Files/OpenBUGS/OpenBUGS", + version,"/OpenBUGS.exe",sep=""),"OpenBUGS"), + version='321', + OpenBUGS.examples=file.path(dirname(OpenBUGS.pgm),'Examples'), + useWINE=FALSE, WINE=NULL, + newWINE=TRUE, WINEPATH=NULL + ) +} + +\arguments{ + \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 the global option \code{R2OpenBUGS.bugs.directory} is not \code{NULL}, + it will be used as the default.} + \item{version}{The version of OpenBUGS to validate. \code{version} is ignored + with linux execution or if \code{OpenBUGS.pgm} is specified. The current + comparison results were created with OpenBUGS 3.2.1} + \item{OpenBUGS.examples}{A directory with the OpenBUGS examples (text versions of + model, data, and inits). There is currently no default appropriate for linux.} + \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}).} + \item{WINE}{Character, path to \file{wine} binary file, it is + tried hard (by a guess and the utilities \code{which} and \code{locate}) + to get the information automatically if not given.} + \item{newWINE}{Use new versions of Wine that have \file{winepath} + utility} + \item{WINEPATH}{Character, path to \file{winepath} binary file, it is + tried hard (by a guess and the utilities \code{which} and \code{locate}) + to get the information automatically if not given.} +} + +\details{ + Operation system support: + \itemize{ + \item \pkg{MS Windows} Yes + \item \pkg{Linux, intel processors} Yes, but GUI display and graphics not available. + \item \pkg{Mac OS X} and \pkg{Unix} Wine emulation via \code{useWINE=TRUE} + } + + If \code{useWINE=TRUE} is used, all paths (such as + \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 + (e.g. \dQuote{/path/to/wine/folder/dosdevices/c:/Program + Files/OpenBUGS/OpenBUGS311/OpenBUGS.exe}). + +} + +\value{ +No data returned. Prints match/no match result to console for each example. +} + +\references{ + Gelman, A., Carlin, J.B., Stern, H.S., Rubin, D.B. (2003): + \emph{Bayesian Data Analysis}, 2nd edition, CRC Press. + + Sturtz, S., Ligges, U., Gelman, A. (2005): + R2WinBUGS: A Package for Running WinBUGS from R. + \emph{Journal of Statistical Software} 12(3), 1-16. +} + +\author{Neal Thomas based on BRugs examples created by Chris Jackaon.} + +\seealso{\code{\link{bugs}}} + +\keyword{interface} +\keyword{models} Property changes on: trunk/R2OpenBUGS/man/validateInstallOpenBUGS.Rd ___________________________________________________________________ Added: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2011-03-30 16:55:49
|
Revision: 184 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=184&view=rev Author: chris-jackson Date: 2011-03-30 16:55:43 +0000 (Wed, 30 Mar 2011) Log Message: ----------- Don't put Makevars in source package, Makevars.in is sufficient. Modified Paths: -------------- branches/linux/BRugs/.Rbuildignore Modified: branches/linux/BRugs/.Rbuildignore =================================================================== --- branches/linux/BRugs/.Rbuildignore 2011-03-23 11:58:16 UTC (rev 183) +++ branches/linux/BRugs/.Rbuildignore 2011-03-30 16:55:43 UTC (rev 184) @@ -1,3 +1,4 @@ exec/BugsHelper exec .+\.Rout +Makevars$ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |