From: <gg...@us...> - 2007-06-12 09:12:58
|
Revision: 23 http://svn.sourceforge.net/bugs-r/?rev=23&view=rev Author: ggorjan Date: 2007-06-12 02:12:59 -0700 (Tue, 12 Jun 2007) Log Message: ----------- bugs.script.R - using Dawn's solution for proper indexing of CODA files also for R side - removed one commented and useless line at the top read.bugs.Rd - documented Dawn's solution Modified Paths: -------------- trunk/R2WinBUGS/R/bugs.script.R trunk/R2WinBUGS/man/read.bugs.Rd Modified: trunk/R2WinBUGS/R/bugs.script.R =================================================================== --- trunk/R2WinBUGS/R/bugs.script.R 2007-05-23 17:44:29 UTC (rev 22) +++ trunk/R2WinBUGS/R/bugs.script.R 2007-06-12 09:12:59 UTC (rev 23) @@ -3,7 +3,6 @@ n.thin, model.file, debug=FALSE, is.inits, bin, DIC = FALSE, useWINE = FALSE, newWINE = FALSE, WINEPATH = NULL){ ### Write file script.txt for Bugs to read -### if (n.chains<2) stop ("n.chains must be at least 2") if((ceiling(n.iter/n.thin) - ceiling(n.burnin/n.thin)) < 2) stop ("(n.iter-n.burnin)/n.thin must be at least 2") @@ -17,29 +16,16 @@ coda <- file.path(working.directory, "coda") logfile <- file.path(working.directory, "log.odc") logfileTxt <- file.path(working.directory, "log.txt") - inits <- sapply(paste(working.directory, "/inits", 1:n.chains, ".txt", sep=""), + inits <- sapply(paste(working.directory, "/inits", 1:n.chains, ".txt", sep=""), function(x) native2win(x, , 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)) - - if (is.R()){ - thinUpdateCommand <- paste("thin.updater (", n.thin, ")\n", - "update (", ceiling(n.burnin/n.thin), ")\n", sep = "") - } else{ - ## In S-PLUS, the handling of the thinning is done differently than in R. - ## bin represents the number of iterations between saves, before thinning, - ## where in R it is the number of iterations between saves, after thinning. - ## This alternative handling of the thinning is done so that the resulting - ## samples have the correct iteration indexes in the output (coda) files. - ## Therefore, if the samples are read into S-PLUS using the coda package, - ## the thinning will be correctly labelled in the resulting mcmc object. - ## In R, the thinning is always labelled as 1, even if thinning was done. - thinUpdateCommand <- paste("update (", n.burnin, ")\n", - "thin.samples (", n.thin, ")\n", sep = "") - bin = bin * n.thin - } - + + thinUpdateCommand <- paste("update (", n.burnin, ")\n", + "thin.samples (", n.thin, ")\n", sep = "") + bin = bin * n.thin + cat( "display ('log')\n", "check ('", native2win(model, WINEPATH=WINEPATH), "')\n", @@ -56,7 +42,7 @@ "stats (*)\n", if(DIC) "dic.stats()\n", "history (*, '", native2win(history, WINEPATH=WINEPATH), "')\n", - "save ('", native2win(logfile, WINEPATH=WINEPATH), "')\n", + "save ('", native2win(logfile, WINEPATH=WINEPATH), "')\n", "save ('", native2win(logfileTxt, WINEPATH=WINEPATH), "')\n", file=script, sep="", append=FALSE) if (!debug) cat ("quit ()\n", file=script, append=TRUE) Modified: trunk/R2WinBUGS/man/read.bugs.Rd =================================================================== --- trunk/R2WinBUGS/man/read.bugs.Rd 2007-05-23 17:44:29 UTC (rev 22) +++ trunk/R2WinBUGS/man/read.bugs.Rd 2007-06-12 09:12:59 UTC (rev 23) @@ -1,19 +1,34 @@ \name{read.bugs} \alias{read.bugs} \title{Read output files in CODA format} -\description{This function reads Markov Chain Monte Carlo output in the CODA format produced by WinBUGS - and returns an object of class \code{\link[coda]{mcmc.list}} for further output analysis - using the \sQuote{coda} package.} + +\description{This function reads Markov Chain Monte Carlo output in the + CODA format produced by WinBUGS and returns an object of class + \code{\link[coda]{mcmc.list}} for further output analysis using the + \pkg{coda} package.} + \usage{ read.bugs(codafiles, ...) } + \arguments{ - \item{codafiles}{character vector of filenames (e.g. returned from \code{\link{bugs}} - in call such as \code{bugs(....., codaPkg = TRUE, .....)}). - Each of the files contains coda output for one chain produced by WinBUGS, - the \emph{directory} name of the corresponding file \file{codaIndex.txt} - is extracted from the first element of \code{codafiles}.} - \item{...}{further arguments to be passed to \code{\link[coda]{read.coda}}} + \item{codafiles}{character vector of filenames (e.g. returned from + \code{\link{bugs}} in call such as \code{bugs(....., codaPkg=TRUE, + .....)}). Each of the files contains coda output for one chain + produced by WinBUGS, the \emph{directory} name of the corresponding + file \file{codaIndex.txt} is extracted from the first element of + \code{codafiles}.} + \item{...}{further arguments to be passed to + \code{\link[coda]{read.coda}}} } -\seealso{\code{\link{bugs}}, \code{\link[coda]{read.coda}}, \code{\link[coda]{mcmc.list}}} + +\details{ + \code{\link{bugs}} (actually it is \code{\link{bugs.script}}) writes + BUGS script in such a way that iteration numbers in resulting CODA + files correspond to iteration numbers before burnin and thinning. +} + +\seealso{\code{\link{bugs}}, \code{\link[coda]{read.coda}}, +\code{\link[coda]{mcmc.list}}} + \keyword{file} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |