From: <li...@us...> - 2008-01-06 18:17:53
|
Revision: 77 http://bugs-r.svn.sourceforge.net/bugs-r/?rev=77&view=rev Author: ligges Date: 2008-01-06 10:17:57 -0800 (Sun, 06 Jan 2008) Log Message: ----------- Some major changes contributed by Jouni Kerman, citing from his message the relevant changes: (In function bugs:) - Add bugs.seed parameter and the corresponding bugs script entry to specify random seed in WinBUGS - Add summary.only parameter (default FALSE) which prevents outputting the coda and only returns the parameter summary - Add save.history parameter (default TRUE) which controls whether the trace plots are generated at end - Add n.sims parameter (number of simulations to keep). I often specify this and n.iter only. - Fix definition of n.thin which assumes output of 1000 simulations (divide by n.sims instead) - If the global option 'R2WinBUGS.bugs.directory' exists, bugs uses it for the R2WinBUGS directory - Allow specification of data file that can be named something else than data.txt - Allow specification of inits file names I have also rewritten the bugs.log routine so it does not crash if DIC is not specified; it also does not make assumptions about the column names. Modified Paths: -------------- trunk/R2WinBUGS/DESCRIPTION trunk/R2WinBUGS/R/bugs.R trunk/R2WinBUGS/R/bugs.data.R trunk/R2WinBUGS/R/bugs.inits.R trunk/R2WinBUGS/R/bugs.log.R trunk/R2WinBUGS/R/bugs.script.R trunk/R2WinBUGS/R/openbugs.R trunk/R2WinBUGS/man/bugs.Rd trunk/R2WinBUGS/man/bugs.data.Rd trunk/R2WinBUGS/man/bugs.inits.Rd trunk/R2WinBUGS/man/bugs.log.Rd trunk/R2WinBUGS/man/bugs.script.Rd trunk/R2WinBUGS/man/openbugs.Rd Modified: trunk/R2WinBUGS/DESCRIPTION =================================================================== --- trunk/R2WinBUGS/DESCRIPTION 2007-10-17 10:09:41 UTC (rev 76) +++ trunk/R2WinBUGS/DESCRIPTION 2008-01-06 18:17:57 UTC (rev 77) @@ -1,6 +1,6 @@ Package: R2WinBUGS Title: Running WinBUGS and OpenBUGS from R / S-PLUS -Date: 2007-09-25 +Date: 2008-01-06 Version: 2.1-7 Author: originally written by Andrew Gelman <ge...@st...>; changes and packaged by Sibylle Sturtz <st...@st...> Modified: trunk/R2WinBUGS/R/bugs.R =================================================================== --- trunk/R2WinBUGS/R/bugs.R 2007-10-17 10:09:41 UTC (rev 76) +++ trunk/R2WinBUGS/R/bugs.R 2008-01-06 18:17:57 UTC (rev 77) @@ -1,21 +1,26 @@ "bugs" <- function(data, inits, parameters.to.save, model.file="model.bug", n.chains=3, n.iter=2000, n.burnin=floor(n.iter / 2), - n.thin=max(1, floor(n.chains * (n.iter - n.burnin) / 1000)), + n.thin=max(1, floor(n.chains * (n.iter - n.burnin) / n.sims)), n.sims = 1000, bin=(n.iter - n.burnin) / n.thin, debug=FALSE, DIC=TRUE, digits=5, codaPkg=FALSE, bugs.directory="c:/Program Files/WinBUGS14/", program=c("WinBUGS", "OpenBUGS", "winbugs", "openbugs"), working.directory=NULL, clearWD=FALSE, useWINE=.Platform$OS.type != "windows", WINE=NULL, - newWINE=TRUE, WINEPATH=NULL) + newWINE=TRUE, WINEPATH=NULL, bugs.seed=NULL, summary.only=FALSE, + save.history=!summary.only) { program <- match.arg(program) + if (missing(bugs.directory) && + !is.null(bugs.dir <- getOption("R2WinBUGS.bugs.directory"))) { # requested by Jouni Kerman + bugs.directory <- bugs.dir + } if(program %in% c("openbugs", "OpenBUGS", "OpenBugs")) { if(!is.R()) stop("OpenBUGS is not yet available in S-PLUS") ## If OpenBUGS, we only call openbugs() and exit... return(openbugs(data, inits, parameters.to.save, model.file, - n.chains, n.iter, n.burnin, n.thin, DIC=DIC, + n.chains, n.iter, n.burnin, n.thin, n.sims, DIC=DIC, bugs.directory, working.directory, digits)) } ## Checking number of inits, which is NOT save here: @@ -52,12 +57,32 @@ stop(paste(model.file, "does not exist.")) if(file.info(model.file)$isdir) stop(paste(model.file, "is a directory, but a file is required.")) - if(!(length(data) == 1 && is.vector(data) && is.character(data) && data == "data.txt")) { - bugs.data(data, dir=getwd(), digits) + if (!(length(data) == 1 && is.vector(data) && is.character(data) && + (regexpr("\\.txt$", data) > 0))) { + bugs.data.file <- bugs.data(data, dir = getwd(), digits) } else { - if(!file.exists(data)) stop("File data.txt does not exist.") + if(!file.exists(data)) + stop("File", data, "does not exist.") + bugs.data.file <- data } - bugs.inits(inits, n.chains, digits) + + + if (is.character(inits)) { + if (!all(file.exists(inits))) { + stop("One or more inits files are missing") + } + if (length(inits)!=n.chains) { + stop("Need one inits file for each chain") + } + bugs.inits.files <- inits + } else { + if (!is.function(inits) && !is.null(inits) && (length(inits) != n.chains)) { + stop("Number of initialized chains (length(inits)) != n.chains") + } + bugs.inits.files <- bugs.inits(inits, n.chains, digits) + } + + if(DIC) parameters.to.save <- c(parameters.to.save, "deviance") ## Model files with extension ".bug" need to be renamed to ".txt" if(length(grep("[.]bug$", model.file))) { @@ -70,17 +95,24 @@ bugs.script(parameters.to.save, n.chains, n.iter, n.burnin, n.thin, new.model.file, debug=debug, is.inits=!is.null(inits), bin=bin, DIC=DIC, useWINE=useWINE, newWINE=newWINE, - WINEPATH=WINEPATH) + WINEPATH=WINEPATH, bugs.seed=bugs.seed, + summary.only=summary.only, save.history=save.history, + bugs.data.file = bugs.data.file, + bugs.inits.files = bugs.inits.files) bugs.run(n.burnin, bugs.directory, WINE=WINE, useWINE=useWINE, newWINE=newWINE, WINEPATH=WINEPATH) if(codaPkg) return(file.path(getwd(), paste("coda", 1:n.chains, ".txt", sep=""))) + if (summary.only) { + return(log("log.txt")) + } + sims <- c(bugs.sims(parameters.to.save, n.chains, n.iter, n.burnin, n.thin, DIC), model.file=model.file, program=program) if(clearWD) { - file.remove(c("data.txt", "log.odc", "log.txt", "codaIndex.txt", - paste("inits", 1:n.chains, ".txt", sep=""), + file.remove(c(bugs.data.file, "log.odc", "log.txt", "codaIndex.txt", + bugs.inits.files, paste("coda", 1:n.chains, ".txt", sep=""))) } class(sims) <- "bugs" Modified: trunk/R2WinBUGS/R/bugs.data.R =================================================================== --- trunk/R2WinBUGS/R/bugs.data.R 2007-10-17 10:09:41 UTC (rev 76) +++ trunk/R2WinBUGS/R/bugs.data.R 2008-01-06 18:17:57 UTC (rev 77) @@ -1,26 +1,27 @@ "bugs.data" <- -function(data, dir = getwd(), digits = 5){ +function(data, dir = getwd(), digits = 5, data.file = "data.txt"){ if(is.numeric(unlist(data))) if(is.R()) { write.datafile(lapply(data, formatC, digits = digits, format = "E"), - file.path(dir, "data.txt")) + file.path(dir, data.file)) } else { - writeDatafileS4(data, towhere = "data.txt") + writeDatafileS4(data, towhere = data.file) } else { if(is.R()) { data.list <- lapply(as.list(data), get, pos = parent.frame(2)) names(data.list) <- as.list(data) write.datafile(lapply(data.list, formatC, digits = digits, format = "E"), - file.path(dir, "data.txt")) + file.path(dir, data.file)) } else { data.list <- lapply(as.list(data), get, where = parent.frame(2)) names(data.list) <- unlist(data) - writeDatafileS4(data.list, towhere = "data.txt") + writeDatafileS4(data.list, towhere = data.file) } - } + } + return(data.file) } Modified: trunk/R2WinBUGS/R/bugs.inits.R =================================================================== --- trunk/R2WinBUGS/R/bugs.inits.R 2007-10-17 10:09:41 UTC (rev 76) +++ trunk/R2WinBUGS/R/bugs.inits.R 2008-01-06 18:17:57 UTC (rev 77) @@ -1,22 +1,22 @@ "bugs.inits" <- -function (inits, n.chains, digits){ +function (inits, n.chains, digits, + inits.files = paste("inits", 1:n.chains, ".txt", sep = "")){ if(!is.null(inits)) { for(i in 1:n.chains) { if(is.function(inits)) if(is.R()) { write.datafile(lapply(inits(), formatC, digits = digits, format = "E"), - paste("inits", i, ".txt", sep = "")) + inits.files[i]) } else { - writeDatafileS4(inits(), towhere = - paste("inits", i, ".txt", sep = "")) + writeDatafileS4(inits(), towhere = inits.files[i]) } else if(is.R()) { write.datafile(lapply(inits[[i]], formatC, digits = digits, format = "E"), - paste("inits", i, ".txt", sep = "")) + inits.files[i]) } else { - writeDatafileS4(inits[[i]], towhere = paste( - "inits", i, ".txt", sep = "")) + writeDatafileS4(inits[[i]], towhere = inits.files[i]) } } } + return(inits.files) } Modified: trunk/R2WinBUGS/R/bugs.log.R =================================================================== --- trunk/R2WinBUGS/R/bugs.log.R 2007-10-17 10:09:41 UTC (rev 76) +++ trunk/R2WinBUGS/R/bugs.log.R 2008-01-06 18:17:57 UTC (rev 77) @@ -1,49 +1,34 @@ -bugs.log <- function(file) +bugs.log <- function (file) { - if(!file.exists(file)) - stop("Log file", file, "does not exist") - logfile <- readLines(file) + # Extracts the summary statistics from log.txt written by WinBUGS. + # Jouni Kerman 2007-01-30 + # does essentially the same thing as bugs.log() but + # - won't crash if DIC is not there + # - makes fewer assumptions about the structure of the matrix - ## --- Stats --- - - statsStart <- which(logfile == "Node statistics") + 2 - if(!length(statsStart)) - stop("Log file", file, "does not contain node statistics.") - ## + 2 to remove - ## "Node statistics" - ## "\t node\t mean\t sd\t MC error\t2.5%\tmedian\t97.5%\tstart\tsample" - - statsEnd <- which(logfile == "dic.stats()") - 1 - ## - 1 to remove - ## "dic.stats()" - - statsTable <- logfile[statsStart:statsEnd] - statsTable <- sub("\t", "", statsTable) - statsTable <- sapply(strsplit(statsTable, "\t"), "[") - colnames(statsTable) <- statsTable[1,] - statsTable <- t(apply(statsTable[-1,], 2, as.numeric)) - colnames(statsTable) <- c("mean", "sd", "MC error", "2.5%", "median", "97.5%", "start", "sample") - - ## --- DIC --- - - DICStart <- which(logfile == "DIC") + 3 - ## + 3 to remove - ## "DIC" - ## "Dbar = post.mean of -2logL; Dhat = -2LogL at post.mean of stochastic nodes" - ## "\tDbar\tDhat\tpD\tDIC\t" - - DICEnd <- grep("history(", logfile, fixed=TRUE) - 1 - ## - 1 to remove - ## "history(..." - - if(!length(DICEnd) || !length(DICStart) || (DICEnd < DICStart)){ - DICTable <- NA - } else { - DICTable <- logfile[DICStart:DICEnd] - DICTable <- sapply(strsplit(DICTable, "\t"), "[") - colnames(DICTable) <- DICTable[1,] - DICTable <- t(apply(DICTable[-1,], 2, as.numeric)) - colnames(DICTable) <- c("Dbar", "Dhat", "pD", "DIC") - } - list(stats=statsTable, DIC=DICTable) + if(!file.exists(file)) + stop("Log file", file, "does not exist") + log.txt <- readLines(file) + extract <- function (m, line.match, skip=0, empty.left.col=TRUE) { + start <- (skip + which(log.txt == line.match)[1]) + if(is.na(start)) return(NULL) + if(length(start) < 1) return(NULL) + mx <- strsplit(m[-(1:start)], "\t") + n.cols <- length(mx[[1]]) + mxlen <- sapply(mx, length) + end <- which(mxlen!=n.cols)[1] - 1 + mx <- mx[1:end] + cm <- matrix(unlist(mx), ncol=n.cols, byrow=TRUE) # character format + if(empty.left.col) cm <- cm[,-1] # empty column + col.names <- cm[1, -1] # first column is just "node" + row.names <- cm[,1][-1] # first row is just "" + col.names <- gsub("[[:space:]]+", "", col.names) # get rid of spaces + cm <- cm[-1,-1] # delete dimname row/columns + m <- matrix(as.numeric(cm), nrow=nrow(cm)) # convert to numeric + dimnames(m) <- list(row.names, col.names) + return(m) + } + stats <- extract(log.txt, "Node statistics") + DIC <- extract(log.txt, "DIC", skip=1, empty.left.col=FALSE) + list(stats=stats, DIC=DIC) } Modified: trunk/R2WinBUGS/R/bugs.script.R =================================================================== --- trunk/R2WinBUGS/R/bugs.script.R 2007-10-17 10:09:41 UTC (rev 76) +++ trunk/R2WinBUGS/R/bugs.script.R 2008-01-06 18:17:57 UTC (rev 77) @@ -2,20 +2,28 @@ function(parameters.to.save, n.chains, n.iter, n.burnin, n.thin, model.file, debug=FALSE, is.inits, bin, DIC=FALSE, useWINE=.Platform$OS.type != "windows", - newWINE=TRUE, WINEPATH=NULL) + newWINE=TRUE, WINEPATH=NULL, bugs.seed=NULL, summary.only=FALSE, + save.history=TRUE, bugs.data.file, bugs.inits.files) { + + output.coda <- (!summary.only) ## Write file script.txt for Bugs - if((ceiling(n.iter/n.thin) - ceiling(n.burnin/n.thin)) < 2) stop ("(n.iter-n.burnin)/n.thin must be at least 2") working.directory <- getwd() script <- "script.txt" - test <- length(grep("\\\\", model.file)) || length(grep("/", model.file)) - model <- ifelse(test, model.file, file.path(working.directory, model.file)) + model <- + if (length(grep("\\\\", model.file)) || length(grep("/", model.file))) { + model.file + } + else file.path(working.directory, model.file) model <- native2win(model, useWINE=useWINE, newWINE=newWINE, WINEPATH=WINEPATH) - data <- file.path(working.directory, "data.txt") + history <- file.path(working.directory, "history.odc") + history <- native2win(history, useWINE=useWINE, newWINE=newWINE, WINEPATH=WINEPATH) + + data <- file.path(working.directory, bugs.data.file) data <- native2win(data, useWINE=useWINE, newWINE=newWINE, WINEPATH=WINEPATH) coda <- file.path(working.directory, "coda") @@ -26,16 +34,21 @@ logFileTxt <- file.path(working.directory, "log.txt") logFileTxt <- native2win(logFileTxt, useWINE=useWINE, newWINE=newWINE, WINEPATH=WINEPATH) - inits <- paste(working.directory, "/inits", 1:n.chains, ".txt", sep="") + inits <- paste(working.directory, "/", bugs.inits.files, sep="") inits <- sapply(inits, useWINE=useWINE, newWINE=newWINE, WINEPATH=WINEPATH, - function(x, useWINE, newWINE, WINEPATH) - {native2win(x, useWINE=useWINE, newWINE=newWINE, WINEPATH=WINEPATH)}) + function(x, useWINE, newWINE, WINEPATH) + {native2win(x, useWINE=useWINE, newWINE=newWINE, WINEPATH=WINEPATH)}) initlist <- paste("inits (", 1:n.chains, ", '", inits, "')\n", sep="") savelist <- paste("set (", parameters.to.save, ")\n", sep="") redo <- ceiling((n.iter-n.burnin)/(n.thin*bin)) + bugs.seed.cmd <- "" + if (!is.null(bugs.seed)) { + bugs.seed.cmd <- paste("set.seed(", bugs.seed, ")\n", sep="") + } + thinUpdate <- paste("thin.updater (", n.thin, ")\n", "update (", ceiling(n.burnin/n.thin), ")\n", sep="") @@ -43,18 +56,19 @@ "display ('log')\n", "check ('", model, "')\n", "data ('", data, "')\n", + bugs.seed.cmd, "compile (", n.chains, ")\n", if(is.inits) initlist, "gen.inits()\n", thinUpdate, - savelist, + savelist, if(DIC) "dic.set()\n", - rep( - c("update (", formatC(ceiling(bin), format="d"), ")\n", - "coda (*, '", coda, "')\n"),redo), + rep(c("update (", formatC(ceiling(bin), format = "d"), ")\n", + if (output.coda) c("coda (*, '", coda, "')\n")), + redo), "stats (*)\n", if(DIC) "dic.stats()\n", - "history (*)\n", + if (save.history) c("history (*, '", history, "')\n"), "save ('", logFile, "')\n", "save ('", logFileTxt, "')\n", file=script, sep="", append=FALSE) Modified: trunk/R2WinBUGS/R/openbugs.R =================================================================== --- trunk/R2WinBUGS/R/openbugs.R 2007-10-17 10:09:41 UTC (rev 76) +++ trunk/R2WinBUGS/R/openbugs.R 2008-01-06 18:17:57 UTC (rev 77) @@ -3,7 +3,7 @@ openbugs <- function(data, inits, parameters.to.save, model.file="model.txt", n.chains = 3, n.iter = 2000, n.burnin = floor(n.iter/2), - n.thin = max(1, floor(n.chains *(n.iter - n.burnin)/1000)), + n.thin = max(1, floor(n.chains *(n.iter - n.burnin) / n.sims)), n.sims = 1000, DIC = TRUE, bugs.directory = "c:/Program Files/OpenBUGS/", working.directory=NULL, digits = 5) { Modified: trunk/R2WinBUGS/man/bugs.Rd =================================================================== --- trunk/R2WinBUGS/man/bugs.Rd 2007-10-17 10:09:41 UTC (rev 76) +++ trunk/R2WinBUGS/man/bugs.Rd 2008-01-06 18:17:57 UTC (rev 77) @@ -9,28 +9,31 @@ \usage{ bugs(data, inits, parameters.to.save, model.file="model.bug", n.chains=3, n.iter=2000, n.burnin=floor(n.iter/2), - n.thin=max(1, floor(n.chains * (n.iter - n.burnin)/1000)), - bin=(n.iter - n.burnin) / n.thin, + n.thin=max(1, floor(n.chains * (n.iter - n.burnin) / n.sims)), + n.sims = 1000, bin=(n.iter - n.burnin) / n.thin, debug=FALSE, DIC=TRUE, digits=5, codaPkg=FALSE, bugs.directory="c:/Program Files/WinBUGS14/", program=c("WinBUGS", "OpenBUGS", "winbugs", "openbugs"), working.directory=NULL, clearWD=FALSE, useWINE=.Platform$OS.type != "windows", WINE=NULL, - newWINE=TRUE, WINEPATH=NULL) + newWINE=TRUE, WINEPATH=NULL, bugs.seed=NULL, summary.only=FALSE, + save.history=!summary.only) } \arguments{ \item{data}{either a named list (names corresponding to variable names in the \code{model.file}) of the data for the \pkg{WinBUGS} model, \emph{or} a vector or list of the names of the data objects used by - the model. If \code{data="data.txt"}, it is assumed that data have - already been written to the working directory in a file called - \file{data.txt}, e.g. by the function \code{\link{bugs.data}}.} + the model. If \code{data} is a one element character vector (such as \code{"data.txt"}), + it is assumed that data have already been written to the working directory into that file, + e.g. by the function \code{\link{bugs.data}}.} \item{inits}{a list with \code{n.chains} elements; each element of the list is itself a list of starting values for the \pkg{WinBUGS} model, \emph{or} a function creating (possibly random) initial values. Alternatively, if \code{inits=NULL}, initial values are generated - by \pkg{WinBUGS}.} + by \pkg{WinBUGS}. If \code{inits} is a character vector with \code{n.chains} elements, + it is assumed that inits have already been written to the working directory into those files, + e.g. by the function \code{\link{bugs.inits}}.} \item{parameters.to.save}{character vector of the names of the parameters to save which should be monitored} \item{model.file}{file containing the model written in \pkg{WinBUGS} code. @@ -52,6 +55,7 @@ \code{n.iter} is large. Default is \code{max(1, floor(n.chains * (n.iter-n.burnin) / 1000))} which will only thin if there are at least 2000 simulations.} + \item{n.sims}{The approximate number of simulations to keep after thinning.} \item{bin}{number of iterations between saving of results (i.e. the coda files are saved after each \code{bin} iterations); default is to save only at the end.} @@ -68,7 +72,9 @@ is returned, if \code{TRUE} file names of \pkg{WinBUGS} output are returned for easy access by the \pkg{coda} package through function \code{\link{read.bugs}} (not used if \code{program="OpenBUGS"}).} - \item{bugs.directory}{directory that contains the \pkg{WinBUGS} executable} + \item{bugs.directory}{directory that contains the \pkg{WinBUGS} executable. + If the global option \code{R2WinBUGS.bugs.directory} is not \code{NULL}, + it will be used as the default.} \item{program}{the program to use, either \code{winbugs}/\code{WinBUGS} or \code{openbugs}/\code{OpenBUGS}, the latter makes use of function \code{\link{openbugs}} and requires @@ -92,6 +98,10 @@ utility} \item{WINEPATH}{character, path to \file{winepath} binary file, it is tried hard to get the information automatically if not given.} + \item{bugs.seed}{random seed for \pkg{WinBUGS} (default is no seed)} + \item{summary.only}{If \code{TRUE}, only a parameter summary for very quick analyses is given, + temporary created files are not removed in that case.} + \item{save.history}{If \code{TRUE} (the default), trace plots are generated at the end.} } \details{ Modified: trunk/R2WinBUGS/man/bugs.data.Rd =================================================================== --- trunk/R2WinBUGS/man/bugs.data.Rd 2007-10-17 10:09:41 UTC (rev 76) +++ trunk/R2WinBUGS/man/bugs.data.Rd 2008-01-06 18:17:57 UTC (rev 77) @@ -2,11 +2,11 @@ \alias{bugs.data} \title{Writing input for WinBUGS} -\description{Write file \file{data.txt} for \pkg{WinBUGS} to read - for +\description{Write file for \pkg{WinBUGS} to read - for internal use.} \usage{ -bugs.data(data, dir = getwd(), digits = 5) +bugs.data(data, dir = getwd(), digits = 5, data.file = "data.txt") } \arguments{ \item{data}{either a named list (names corresponding to variable names @@ -16,10 +16,11 @@ \item{dir}{the directory to write the file \file{data.txt} to} \item{digits}{number of significant digits used for \pkg{WinBUGS} input, see \code{\link{formatC}}} + \item{data.file}{name for the file R writes the data into.} } -\value{Nothing, but as a side effect, the data file \file{data.txt} is - written} +\value{The name of \code{data.file} is returned and as a side effect, + the data file is written} \seealso{The main function to be called by the user is \code{\link{bugs}}.} \keyword{internal} Modified: trunk/R2WinBUGS/man/bugs.inits.Rd =================================================================== --- trunk/R2WinBUGS/man/bugs.inits.Rd 2007-10-17 10:09:41 UTC (rev 76) +++ trunk/R2WinBUGS/man/bugs.inits.Rd 2008-01-06 18:17:57 UTC (rev 77) @@ -6,7 +6,8 @@ the working directory for \pkg{WinBUGS} to read - for internal use.} \usage{ -bugs.inits(inits, n.chains, digits) +bugs.inits(inits, n.chains, digits, + inits.files = paste("inits", 1:n.chains, ".txt", sep = "")) } \arguments{ \item{inits}{a list with \code{n.chains} elements; each element of the @@ -15,9 +16,10 @@ \item{n.chains}{number of Markov chains} \item{digits}{number of significant digits used for \pkg{WinBUGS} input, see \code{\link{formatC}}} + \item{inits.file}{name for the inits files R write the inits into.} } -\value{Nothing, but as a side effect, the inits files \file{inits*.txt} +\value{Vector of names of \code{inits.files}; as a side effect, the inits files \file{inits*.txt} are written} \seealso{The main function to be called by the user is \code{\link{bugs}}.} Modified: trunk/R2WinBUGS/man/bugs.log.Rd =================================================================== --- trunk/R2WinBUGS/man/bugs.log.Rd 2007-10-17 10:09:41 UTC (rev 76) +++ trunk/R2WinBUGS/man/bugs.log.Rd 2008-01-06 18:17:57 UTC (rev 77) @@ -17,11 +17,6 @@ \item{DIC}{A matrix containing the DIC statistics as returned from \pkg{WinBUGS}.} } - -\details{ In later releases of \pkg{R2WinBUGS}, this function is -considered to read the relevant data from the log file rather than -analysing and calculating the relevant data in \R / S-PLUS again. } - \seealso{The main function that generates the log file is \code{\link{bugs}}.} \keyword{IO} \keyword{file} Modified: trunk/R2WinBUGS/man/bugs.script.Rd =================================================================== --- trunk/R2WinBUGS/man/bugs.script.Rd 2007-10-17 10:09:41 UTC (rev 76) +++ trunk/R2WinBUGS/man/bugs.script.Rd 2008-01-06 18:17:57 UTC (rev 77) @@ -9,7 +9,9 @@ \usage{ bugs.script(parameters.to.save, n.chains, n.iter, n.burnin, n.thin, model.file, debug=FALSE, is.inits, bin, DIC=FALSE, - useWINE=.Platform$OS.type != "windows", newWINE=TRUE, WINEPATH=NULL) + useWINE=.Platform$OS.type != "windows", newWINE=TRUE, WINEPATH=NULL, + bugs.seed=NULL, summary.only=FALSE, save.history=TRUE, + bugs.data.file, bugs.inits.files) } \arguments{ \item{parameters.to.save}{parameters that should be monitored} @@ -28,6 +30,12 @@ \item{useWINE}{as in \code{\link{bugs}} meta function} \item{newWINE}{as in \code{\link{bugs}} meta function} \item{WINEPATH}{as in \code{\link{bugs}} meta function} + \item{bugs.seed}{random seed for \pkg{WinBUGS} (default is no seed)} + \item{summary.only}{If \code{TRUE}, only a parameter summary for very quick analyses is given, + temporary created files are not removed in that case.} + \item{save.history}{If \code{TRUE} (the default), trace plots are generated at the end.} + \item{bugs.data.file}{character name of the data file} + \item{bugs.inits.files}{character vector of names of the inits files} } \value{Nothing, but as a side effect, the script file \file{script.txt} Modified: trunk/R2WinBUGS/man/openbugs.Rd =================================================================== --- trunk/R2WinBUGS/man/openbugs.Rd 2007-10-17 10:09:41 UTC (rev 76) +++ trunk/R2WinBUGS/man/openbugs.Rd 2008-01-06 18:17:57 UTC (rev 77) @@ -10,8 +10,9 @@ openbugs(data, inits, parameters.to.save, model.file = "model.txt", n.chains = 3, n.iter = 2000, n.burnin = floor(n.iter/2), - n.thin = max(1, floor(n.chains * (n.iter - n.burnin) / 1000)), - DIC = TRUE, bugs.directory = "c:/Program Files/OpenBUGS/", + n.thin = max(1, floor(n.chains * (n.iter - n.burnin) / n.sims)), + n.sims = 1000, DIC = TRUE, + bugs.directory = "c:/Program Files/OpenBUGS/", working.directory = NULL, digits = 5) } @@ -19,9 +20,9 @@ \item{data}{either a named list (names corresponding to variable names in the \code{model.file}) of the data for the \pkg{OpenBUGS} model, \emph{or} a vector or list of the names of the data objects used by - the model. If \code{data = "data.txt"}, it is assumed that data - have already been written to the working directory in a file called - \file{data.txt}, e.g. by the function \code{\link{bugs.data}}.} + the model. If \code{data} is a one element character vector (such as \code{"data.txt"}), + it is assumed that data have already been written to the working directory into that file, + e.g. by the function \code{\link{bugs.data}}.} \item{inits}{a list with \code{n.chains} elements; each element of the list is itself a list of starting values for the \pkg{OpenBUGS} model, \emph{or} a function creating (possibly random) initial values. @@ -45,7 +46,8 @@ \code{n.iter} is large. Default is \code{max(1, floor(n.chains * (n.iter-n.burnin) / 1000))} which will only thin if there are at least 2000 simulations.} - \item{DIC}{logical; if \code{TRUE} (default), compute deviance, pD, and + \item{n.sims}{The approximate number of simulations to keep after thinning.} + \item{DIC}{logical; if \code{TRUE} (default), compute deviance, pD, and DIC. This is done in \pkg{BRugs} directly.} \item{digits}{number of significant digits used for \pkg{OpenBUGS} input, see \code{\link{formatC}}} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |