|
From: <snt...@us...> - 2011-03-21 19:13:34
|
Revision: 181
http://bugs-r.svn.sourceforge.net/bugs-r/?rev=181&view=rev
Author: snthomas99
Date: 2011-03-21 19:13:27 +0000 (Mon, 21 Mar 2011)
Log Message:
-----------
added saveExec and restart features for use with OpenBUGS >3.2.1
Modified Paths:
--------------
trunk/R2OpenBUGS/CreatevalidateOpenBUGS.R
trunk/R2OpenBUGS/DESCRIPTION
trunk/R2OpenBUGS/R/bugs.R
trunk/R2OpenBUGS/R/bugs.script.R
trunk/R2OpenBUGS/R/print.bugs.R
trunk/R2OpenBUGS/inst/NEWS
trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/validOpenBUGSResults.R
trunk/R2OpenBUGS/man/bugs.Rd
trunk/R2OpenBUGS/man/bugs.script.Rd
Modified: trunk/R2OpenBUGS/CreatevalidateOpenBUGS.R
===================================================================
--- trunk/R2OpenBUGS/CreatevalidateOpenBUGS.R 2011-03-07 15:09:12 UTC (rev 180)
+++ trunk/R2OpenBUGS/CreatevalidateOpenBUGS.R 2011-03-21 19:13:27 UTC (rev 181)
@@ -25,11 +25,11 @@
)
test.modelfile = paste(test.models,"model.txt",sep="")
-test.modelfile<-file.path('C:/Program Files/OpenBUGS/OpenBUGS312/Examples',test.modelfile)
+test.modelfile<-file.path('C:/Program Files/OpenBUGS/OpenBUGS321/Examples',test.modelfile)
test.datafile = paste(test.models,"data.txt",sep="")
-test.datafile<-file.path('C:/Program Files/OpenBUGS/OpenBUGS312/Examples',test.datafile)
+test.datafile<-file.path('C:/Program Files/OpenBUGS/OpenBUGS321/Examples',test.datafile)
test.inits = paste(test.models,"inits.txt",sep="")
-test.inits<-file.path('C:/Program Files/OpenBUGS/OpenBUGS312/Examples',test.inits)
+test.inits<-file.path('C:/Program Files/OpenBUGS/OpenBUGS321/Examples',test.inits)
### Test for posterior means within 1 percent of previously saved values
Modified: trunk/R2OpenBUGS/DESCRIPTION
===================================================================
--- trunk/R2OpenBUGS/DESCRIPTION 2011-03-07 15:09:12 UTC (rev 180)
+++ trunk/R2OpenBUGS/DESCRIPTION 2011-03-21 19:13:27 UTC (rev 181)
@@ -1,7 +1,7 @@
Package: R2OpenBUGS
Title: Running OpenBUGS from R / S-PLUS
-Date: 2010-09-30
-Version: 3.1-2
+Date: 2011-03-01
+Version: 3.2-1
Author: originally written as R2WinBUGS by Andrew Gelman <ge...@st...>;
changes and packaged by Sibylle Sturtz <st...@st...>
and Uwe Ligges <li...@st...>.
@@ -12,9 +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.9.2), coda (>= 0.11-0)
-SystemRequirements: OpenBUGS >=3.1
-URL: http://www.stat.columbia.edu/~gelman/bugsR/
+Depends: R (>= 2.10.1), coda (>= 0.11-0)
+SystemRequirements: OpenBUGS >=3.2.1
Maintainer: Uwe Ligges <li...@st...>
License: GPL-2
Dialect: R, S-PLUS
Modified: trunk/R2OpenBUGS/R/bugs.R
===================================================================
--- trunk/R2OpenBUGS/R/bugs.R 2011-03-07 15:09:12 UTC (rev 180)
+++ trunk/R2OpenBUGS/R/bugs.R 2011-03-21 19:13:27 UTC (rev 181)
@@ -1,11 +1,12 @@
"bugs" <-
-function(data, inits, parameters.to.save, n.iter, model.file="model.bug",
+function(data, inits, parameters.to.save, n.iter, model.file="model.txt",
n.chains=3, n.burnin=floor(n.iter / 2), n.thin=1,
+ saveExec=FALSE,restart=FALSE,
debug=FALSE, DIC=TRUE, digits=5, codaPkg=FALSE,
OpenBUGS.pgm=ifelse(.Platform$OS.type == "windows" | useWINE==TRUE,
paste("C:/Program Files/OpenBUGS/OpenBUGS",
version,"/OpenBUGS.exe",sep=""),"OpenBUGS"),
- version='312',
+ version='321',
working.directory=NULL,
clearWD=FALSE, useWINE=FALSE, WINE=NULL,
newWINE=TRUE, WINEPATH=NULL, bugs.seed=1, summary.only=FALSE,
@@ -36,6 +37,11 @@
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")
+
+ if(is.null(working.directory) && (saveExec || restart))stop("The working directory must be specified when saveExec or restart is TRUE")
+
if(!is.null(working.directory)) {
working.directory <- path.expand(working.directory)
savedWD <- getwd()
@@ -120,7 +126,7 @@
}
if(DIC) parameters.to.save <- c(parameters.to.save, "deviance")
- ## Model files with extension ".bug" need to be renamed to ".txt"
+ ## Model files must have extension ".txt"
if(!length(grep("\\.txt$", tolower(model.file)))) {
new.model.file <- paste(basename(model.file), ".txt", sep="")
if(!is.null(working.directory)) new.model.file <- file.path(working.directory, new.model.file)
@@ -129,11 +135,18 @@
} else {
new.model.file <- model.file
}
+
+ ## Create a filename model.file + .bug
+ model.file.bug<-gsub('\\.txt','.bug',basename(new.model.file))
+
+ if(restart && !file.exists(model.file.bug))stop("The .bug restart file was not found in the working directory")
+
if(useWINE){
## Some tweaks for wine (particularly required for Mac OS)
new.model.file <- gsub("//", "/", new.model.file)
}
bugs.script(parameters.to.save, n.chains, n.iter, n.burnin, n.thin,
+ saveExec,restart,model.file.bug,
new.model.file, debug=debug, is.inits=!is.null(inits),
DIC=DIC, useWINE=useWINE, newWINE=newWINE,
WINEPATH=WINEPATH, bugs.seed=bugs.seed,
Modified: trunk/R2OpenBUGS/R/bugs.script.R
===================================================================
--- trunk/R2OpenBUGS/R/bugs.script.R 2011-03-07 15:09:12 UTC (rev 180)
+++ trunk/R2OpenBUGS/R/bugs.script.R 2011-03-21 19:13:27 UTC (rev 181)
@@ -1,6 +1,7 @@
"bugs.script" <-
function(parameters.to.save, n.chains, n.iter, n.burnin,
- n.thin, model.file, debug=FALSE, is.inits,
+ n.thin, saveExec, restart, model.file.bug,
+ model.file, debug=FALSE, is.inits,
DIC=FALSE, useWINE=FALSE,
newWINE=TRUE, WINEPATH=NULL, bugs.seed=NULL, summary.only=FALSE,
save.history=(.Platform$OS.type == "windows" | useWINE==TRUE),
@@ -26,6 +27,9 @@
coda <- file.path(working.directory, "/")
coda <- native2win(coda, useWINE=useWINE, newWINE=newWINE, WINEPATH=WINEPATH)
+ model.file.bug<-file.path(working.directory,model.file.bug)
+ model.file.bug<-native2win(model.file.bug, useWINE=useWINE, newWINE=newWINE, WINEPATH=WINEPATH)
+
logFile <- file.path(working.directory, "log.odc")
logFile <- native2win(logFile, useWINE=useWINE, newWINE=newWINE, WINEPATH=WINEPATH)
logFileTxt <- file.path(working.directory, "log.txt")
@@ -51,30 +55,40 @@
cat(
if(.Platform$OS.type == "windows" | useWINE) "modelDisplay('log')\n",
- "modelCheck('", model, "')\n",
- "modelData('", data, "')\n",
- "modelCompile(", n.chains, ")\n",
- bugs.seed.cmd,
- if(is.inits) initlist,
- "modelGenInits()\n",
- if(over.relax) 'over.relax("yes")\n',
+ if(restart)c("modelInternalize('", model.file.bug, "')\n"),
+ if(restart && n.burnin>0)c(
+ "samplesClear('*')\n",
+ "summaryClear('*')\n"
+ ),
+ if(!restart)c(
+ "modelCheck('", model, "')\n",
+ "modelData('", data, "')\n",
+ "modelCompile(", n.chains, ")\n"
+ ),
+ if(!restart)bugs.seed.cmd,
+ if(!restart && is.inits) initlist,
+ if(!restart)"modelGenInits()\n",
+ if(!restart && over.relax) 'over.relax("yes")\n',
+ if((!restart) || (n.burnin>0))c(
thinUpdate,
savelist,
- summarylist,
- if(DIC) "dicSet()\n",
+ summarylist
+ ),
+ if(((!restart) || (n.burnin>0)) && DIC) "dicSet()\n",
"modelUpdate(", formatC(n.iter-n.burnin, format='d'), ",", n.thin,
",",formatC(n.iter-n.burnin, format='d'),")\n",
"samplesCoda('*', '", coda, "')\n",
"summaryStats('*')\n",
if(DIC) "dicStats()\n",
if (save.history) "samplesHistory('*')\n",
+ if(saveExec)c("modelExternalize('",model.file.bug,"')\n"),
if(.Platform$OS.type == "windows" | useWINE) c("modelSaveLog('", logFile, "')\n",
"modelSaveLog('", logFileTxt, "')\n"),
file=script, sep="", append=FALSE)
- if(!debug) cat("modelQuit('y')\n", file=script, append=TRUE)
+ if(!debug) cat("modelQuit('y')\n", file=script, append=TRUE)
- sims.files <- paste(coda, "CODAchain", 1:n.chains, ".txt", sep="")
+ sims.files <- paste("CODAchain", 1:n.chains, ".txt", sep="")
for(i in 1:n.chains)
cat("OpenBUGS did not run correctly.\n", file=sims.files[i], append=FALSE)
}
Modified: trunk/R2OpenBUGS/R/print.bugs.R
===================================================================
--- trunk/R2OpenBUGS/R/print.bugs.R 2011-03-07 15:09:12 UTC (rev 180)
+++ trunk/R2OpenBUGS/R/print.bugs.R 2011-03-21 19:13:27 UTC (rev 181)
@@ -7,10 +7,10 @@
cat("Inference for Bugs model at \"", x$model.file, "\", ", sep="")
if(!is.null(x$program))
cat("fit using ", x$program, ",", sep="")
- cat("\n ", x$n.chains, " chains, each with ", x$n.iter,
+ cat("\nCurrent: ", x$n.chains, " chains, each with ", x$n.iter,
" iterations (first ", x$n.burnin, " discarded)", sep = "")
if(x$n.thin > 1) cat(", n.thin =", x$n.thin)
- cat("\n n.sims =", x$n.sims, "iterations saved\n")
+ cat("\nCumulative: n.sims =", x$n.sims, "iterations saved\n")
print(round(x$summary, digits.summary), ...)
if(x$n.chains > 1) {
Modified: trunk/R2OpenBUGS/inst/NEWS
===================================================================
--- trunk/R2OpenBUGS/inst/NEWS 2011-03-07 15:09:12 UTC (rev 180)
+++ trunk/R2OpenBUGS/inst/NEWS 2011-03-21 19:13:27 UTC (rev 181)
@@ -1,6 +1,15 @@
Changes to R2OpenBUGS:
======================
+Update 3.2-1
+- Added saveExec and restart options to the bugs function that uses
+ the OpenBUGS internalize/externalize feature to allow a user to
+ store the state of the OpenBUGS execution and continue
+ execution after checking results in R.
+
+Update 3.1-2.1
+- Corrected bug in WINE execution
+
Update 3.1-2
- Set default version of OpenBUGS to 3.1.2
- Fixed upper/lower case error in read.bugs
Modified: trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/validOpenBUGSResults.R
===================================================================
--- trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/validOpenBUGSResults.R 2011-03-07 15:09:12 UTC (rev 180)
+++ trunk/R2OpenBUGS/inst/validateInstallOpenBUGS/validOpenBUGSResults.R 2011-03-21 19:13:27 UTC (rev 181)
@@ -20,116 +20,111 @@
53.13, 55.19025, 60.39, 59.36), .Dim = c(10L, 7L), .Dimnames = list(
c("alpha", "beta", "rhat[1]", "rhat[2]", "rhat[3]", "rhat[4]",
"rhat[5]", "rhat[6]", "rhat[7]", "rhat[8]"), c("mean", "sd",
- "2.5%", "25%", "50%", "75%", "97.5%"))), structure(c(106.56037,
-6.18615, 6.15259, 2.34291, 0.10596, 0.47872, 101.9, 5.977, 5.304,
-105, 6.117, 5.817, 106.5, 6.187, 6.1185, 108.1, 6.255, 6.452,
-111.1025, 6.397, 7.177), .Dim = c(3L, 7L), .Dimnames = list(c("mu.beta[1]",
+ "2.5%", "25%", "50%", "75%", "97.5%"))), structure(c(106.56034,
+6.18619, 6.15206, 2.34366, 0.10595, 0.47828, 101.9, 5.976, 5.30397,
+105, 6.117, 5.818, 106.5, 6.187, 6.118, 108.1, 6.254, 6.451,
+111.2, 6.397, 7.18002), .Dim = c(3L, 7L), .Dimnames = list(c("mu.beta[1]",
"mu.beta[2]", "sigma"), c("mean", "sd", "2.5%", "25%", "50%",
-"75%", "97.5%"))), structure(c(3.2445, 0.02929, 0.02929, 3.20989,
-0.0081, 0.85113, -0.00963, -0.00963, 0.86281, 2.1011, 2.50802,
-2.50802, 2.13451, 0.65922, 0.50825, 0.71045, 0.71045, 0.50962,
-1.14395, -4.77203, -4.77203, 1.101, -0.9073, 0.22139, -1.40502,
--1.40502, 0.2234, 1.926, -1.638, -1.638, 1.917, -0.66862, 0.49587,
--0.48102, -0.48102, 0.50065, 2.6875, 0.04017, 0.04017, 2.663,
-0.01868, 0.7305, -0.00773, -0.00773, 0.74375, 3.89225, 1.715,
-1.715, 3.82125, 0.68585, 1.07, 0.4545, 0.4545, 1.10125, 8.5671,
-4.82202, 4.82202, 8.5781, 0.9098, 2.13205, 1.40205, 1.40205,
-2.18202), .Dim = c(9L, 7L), .Dimnames = list(c("Sigma2[1,1]",
-"Sigma2[1,2]", "Sigma2[2,1]", "Sigma2[2,2]", "rho", "tau[1,1]",
-"tau[1,2]", "tau[2,1]", "tau[2,2]"), c("mean", "sd", "2.5%",
-"25%", "50%", "75%", "97.5%"))), structure(c(1.85767, 2.64973,
-0.96989, 0.86209, 0.09887, 0.26392, 0.07107, 0.07684, 0.03153,
-0.0148, 1.323, 2.528, 0.8224, 0.7898, 0.07502, 1.701, 2.604,
-0.9188, 0.8457, 0.08841, 1.854, 2.642, 0.9689, 0.8646, 0.09723,
-2.026, 2.691, 1.018, 0.8836, 0.1074, 2.36802, 2.802, 1.122, 0.9144,
-0.1326), .Dim = c(5L, 7L), .Dimnames = list(c("U3", "alpha",
-"beta", "gamma", "sigma"), c("mean", "sd", "2.5%", "25%", "50%",
-"75%", "97.5%"))), structure(c(2399.81116, 2970.23731, 1526.76347,
-9152.71052, 1072.50035, 22.42927, 0.01173, 1559, 1483, 573.04999,
-2217, 1515, 1388.49991, 2748, 1526, 2769.24997, 3466, 1539, 10140.49952,
-5596.37451, 1570), .Dim = c(3L, 7L), .Dimnames = list(c("sigma2.btw",
-"sigma2.with", "theta"), c("mean", "sd", "2.5%", "25%", "50%",
-"75%", "97.5%"))), structure(c(0.99767, 1.43476, -0.00865, -0.1804,
-0.11034, 0.1406, 0.99274, 0.04825, 0.0552, 0.05217, 0.05175,
-0.03333, 0.05436, 0.05185, 1, 1.327, -0.113, -0.2831, 0.06521,
-0.04439, 0.8931, 1, 1.4, -0.04039, -0.2121, 0.08657, 0.1057,
-0.9604, 1, 1.435, -0.00813, -0.1808, 0.1033, 0.1356, 0.9919,
-1, 1.469, 0.02322, -0.1495, 0.12722, 0.169, 1.023, 1, 1.544,
-0.0942, -0.07637, 0.1929, 0.2663, 1.099), .Dim = c(7L, 7L), .Dimnames = list(
- c("equiv", "mu", "phi", "pi", "sigma1", "sigma2", "theta"
- ), c("mean", "sd", "2.5%", "25%", "50%", "75%", "97.5%"))),
- structure(c(0.6029, 0.3971, 536.75923, 548.90934, 3.75937,
- 0.08421, 0.08421, 0.92221, 1.21365, 0.6111, 0.4326, 0.2359,
- 535.1, 546.5, 2.917, 0.54737, 0.34, 536.2, 548.2, 3.36175,
- 0.6039, 0.3961, 536.7, 548.9, 3.654, 0.66, 0.45262, 537.3,
- 549.7, 4.019, 0.7641, 0.5674, 538.6, 551.2, 5.27107), .Dim = c(5L,
- 7L), .Dimnames = list(c("P[1]", "P[2]", "lambda[1]", "lambda[2]",
- "sigma"), c("mean", "sd", "2.5%", "25%", "50%", "75%", "97.5%"
- ))), structure(c(2.99564, 0.79689, 1.02513, 0.56926, 0.39621,
- 0.72729, 1.914, 0.04475, 0.4099, 2.743, 0.6218, 0.625, 2.997,
- 0.7995, 0.82675, 3.255, 0.9782, 1.16825, 4.08502, 1.541,
- 2.82), .Dim = c(3L, 7L), .Dimnames = list(c("alpha", "beta",
- "sigma"), c("mean", "sd", "2.5%", "25%", "50%", "75%", "97.5%"
- ))), structure(c(5.26374, 2.19866, -5.88024, 0.25869, 0.27042,
- 0.2265, 7.82296, 0.1335, 0.16648, 0.14127, 0.11614, 0.137,
- 0.1076, 1.18539, 4.996, 1.87997, -6.165, 0.1277, 0.1201,
- 0.1085, 5.90897, 5.187, 2.094, -5.964, 0.1849, 0.1843, 0.1586,
- 6.984, 5.264, 2.197, -5.879, 0.2318, 0.24, 0.2008, 7.684,
- 5.342, 2.3, -5.795, 0.2995, 0.3184, 0.26312, 8.521, 5.529,
- 2.535, -5.603, 0.54651, 0.6038, 0.495, 10.5), .Dim = c(7L,
- 7L), .Dimnames = list(c("mu[1]", "mu[2]", "mu[3]", "sigma[1]",
- "sigma[2]", "sigma[3]", "sigmaC"), c("mean", "sd", "2.5%",
- "25%", "50%", "75%", "97.5%"))), structure(c(106.61227, 6.18568,
- 6.0953, 3.63673, 0.1075, 0.46858, 99.40975, 5.97597, 5.27197,
- 104.2, 6.114, 5.776, 106.6, 6.187, 6.058, 109.1, 6.258, 6.386,
- 113.6, 6.394, 7.106), .Dim = c(3L, 7L), .Dimnames = list(
- c("alpha0", "beta.c", "sigma"), c("mean", "sd", "2.5%",
- "25%", "50%", "75%", "97.5%"))), structure(c(0.71462,
- 1.2978, -0.15277, -39.85965, 0.0106, 0.05567, 0.3192, 0.0106,
- 0.05567, 0.3192, 0.0106, 0.05567, 0.3192, 3.38943, 0.14307,
- 0.38863, 0.16594, 12.71407, 0.10241, 0.22928, 0.46618, 0.10241,
- 0.22928, 0.46618, 0.10241, 0.22928, 0.46618, 0.62795, 0.43279,
- 0.529, -0.4842, -65.22025, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2.417,
- 0.62217, 1.049, -0.26012, -48.11, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 2.945, 0.7155, 1.294, -0.15245, -39.96, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 3.299, 0.8063, 1.545, -0.04546, -31.5775, 0,
- 0, 1, 0, 0, 1, 0, 0, 1, 3.742, 0.9984, 2.076, 0.1763, -14.38925,
- 0, 1, 1, 0, 1, 1, 0, 1, 1, 4.84702), .Dim = c(14L, 7L), .Dimnames = list(
- c("b[1]", "b[2]", "b[3]", "b0", "outlier[3]", "outlier[4]",
- "outlier[21]", "outlier[3]", "outlier[4]", "outlier[21]",
- "outlier[3]", "outlier[4]", "outlier[21]", "sigma"),
- c("mean", "sd", "2.5%", "25%", "50%", "75%", "97.5%"))),
- structure(c(0.02054, 0.12633, 0.07461, 0.05794, 0.04233,
- 0.07062, 0.06659, 0.14758, 0.07197, 0.09058, 0.11631, 0.06903,
- 0.01981, 0.0272, 0.02389, 0.00813, 0.01381, 0.01821, 0.02022,
- 0.02414, 0.01787, 0.02864, 0.01984, 0.01339, 0.00053, 0.07787,
- 0.03467, 0.04313, 0.01952, 0.03927, 0.03268, 0.1034, 0.04114,
- 0.0432, 0.08016, 0.04533, 0.00614, 0.107, 0.0575, 0.05223,
- 0.03235, 0.05768, 0.05224, 0.1307, 0.05927, 0.06978, 0.1024,
- 0.05962, 0.01446, 0.1246, 0.07216, 0.0576, 0.04099, 0.06919,
- 0.06439, 0.1463, 0.07056, 0.08795, 0.1156, 0.06826, 0.02884,
- 0.1438, 0.08924, 0.06318, 0.05081, 0.08204, 0.07907, 0.1635,
- 0.08303, 0.1081, 0.1293, 0.07747, 0.07305, 0.1833, 0.1272,
- 0.07477, 0.073, 0.1104, 0.1108, 0.1976, 0.1112, 0.1544, 0.1578,
- 0.09787), .Dim = c(12L, 7L), .Dimnames = list(c("p[1]", "p[2]",
- "p[3]", "p[4]", "p[5]", "p[6]", "p[7]", "p[8]", "p[9]", "p[10]",
- "p[11]", "p[12]"), c("mean", "sd", "2.5%", "25%", "50%",
- "75%", "97.5%"))), structure(c(0.05312, 0.10302, 0.07048,
- 0.05924, 0.05155, 0.06905, 0.06683, 0.12337, 0.07011, 0.07828,
- 0.10214, 0.06848, 0.07268, 0.40333, 0.01954, 0.02166, 0.01741,
- 0.00786, 0.01312, 0.01486, 0.01593, 0.02261, 0.01464, 0.01993,
- 0.01758, 0.01165, 0.0101, 0.1541, 0.01824, 0.06663, 0.03985,
- 0.04467, 0.02805, 0.04259, 0.03845, 0.08327, 0.04392, 0.04419,
- 0.07166, 0.04744, 0.05319, 0.1655, 0.03923, 0.08746, 0.05844,
- 0.05381, 0.04215, 0.0587, 0.05584, 0.1072, 0.06004, 0.06443,
- 0.08969, 0.06035, 0.06617, 0.2989, 0.05219, 0.101, 0.06913,
- 0.05897, 0.05093, 0.0683, 0.06577, 0.1217, 0.06922, 0.07633,
- 0.1009, 0.06796, 0.07253, 0.3818, 0.0656, 0.1163, 0.08104,
- 0.06431, 0.06019, 0.07812, 0.07685, 0.1379, 0.07919, 0.08994,
- 0.1132, 0.07595, 0.07898, 0.48342, 0.09467, 0.1511, 0.1088,
- 0.07536, 0.07873, 0.101, 0.1011, 0.1716, 0.1015, 0.1226,
- 0.1401, 0.09301, 0.09334, 0.76511), .Dim = c(14L, 7L), .Dimnames = list(
- c("p[1]", "p[2]", "p[3]", "p[4]", "p[5]", "p[6]", "p[7]",
- "p[8]", "p[9]", "p[10]", "p[11]", "p[12]", "pop.mean",
- "sigma"), c("mean", "sd", "2.5%", "25%", "50%", "75%",
- "97.5%"))))
+"75%", "97.5%"))), structure(c(3.199, 0.11791, 0.11791, 3.22327,
+0.03519, 0.84975, -0.03162, -0.03162, 0.84991, 2.0602, 2.46612,
+2.46612, 2.13682, 0.65527, 0.50303, 0.69675, 0.69675, 0.50508,
+1.13, -4.57602, -4.57602, 1.11997, -0.9017, 0.22159, -1.38405,
+-1.38405, 0.2153, 1.93675, -1.571, -1.571, 1.921, -0.65055, 0.4941,
+-0.49565, -0.49565, 0.4931, 2.663, 0.23045, 0.23045, 2.662, 0.10835,
+0.7321, -0.04676, -0.04676, 0.73415, 3.804, 1.777, 1.777, 3.848,
+0.6978, 1.08225, 0.4324, 0.4324, 1.079, 8.43205, 4.69405, 4.69405,
+8.66835, 0.9054, 2.13005, 1.346, 1.346, 2.16), .Dim = c(9L, 7L
+), .Dimnames = list(c("Sigma2[1,1]", "Sigma2[1,2]", "Sigma2[2,1]",
+"Sigma2[2,2]", "rho", "tau[1,1]", "tau[1,2]", "tau[2,1]", "tau[2,2]"
+), c("mean", "sd", "2.5%", "25%", "50%", "75%", "97.5%"))), structure(c(1.85767,
+2.64973, 0.96989, 0.86209, 0.09887, 0.26392, 0.07107, 0.07684,
+0.03153, 0.0148, 1.323, 2.528, 0.8224, 0.7898, 0.07502, 1.701,
+2.604, 0.9188, 0.8457, 0.08841, 1.854, 2.642, 0.9689, 0.8646,
+0.09723, 2.026, 2.691, 1.018, 0.8836, 0.1074, 2.36802, 2.802,
+1.122, 0.9144, 0.1326), .Dim = c(5L, 7L), .Dimnames = list(c("U3",
+"alpha", "beta", "gamma", "sigma"), c("mean", "sd", "2.5%", "25%",
+"50%", "75%", "97.5%"))), structure(c(2399.81116, 2970.23731,
+1526.76347, 9152.71052, 1072.50035, 22.42927, 0.01173, 1559,
+1483, 573.04999, 2217, 1515, 1388.49991, 2748, 1526, 2769.24997,
+3466, 1539, 10140.49952, 5596.37451, 1570), .Dim = c(3L, 7L), .Dimnames = list(
+ c("sigma2.btw", "sigma2.with", "theta"), c("mean", "sd",
+ "2.5%", "25%", "50%", "75%", "97.5%"))), structure(c(0.99767,
+1.43476, -0.00865, -0.1804, 0.11034, 0.1406, 0.99274, 0.04825,
+0.0552, 0.05217, 0.05175, 0.03333, 0.05436, 0.05185, 1, 1.327,
+-0.113, -0.2831, 0.06521, 0.04439, 0.8931, 1, 1.4, -0.04039,
+-0.2121, 0.08657, 0.1057, 0.9604, 1, 1.435, -0.00813, -0.1808,
+0.1033, 0.1356, 0.9919, 1, 1.469, 0.02322, -0.1495, 0.12722,
+0.169, 1.023, 1, 1.544, 0.0942, -0.07637, 0.1929, 0.2663, 1.099
+), .Dim = c(7L, 7L), .Dimnames = list(c("equiv", "mu", "phi",
+"pi", "sigma1", "sigma2", "theta"), c("mean", "sd", "2.5%", "25%",
+"50%", "75%", "97.5%"))), structure(c(0.6029, 0.3971, 536.75923,
+548.90934, 3.75937, 0.08421, 0.08421, 0.92221, 1.21365, 0.6111,
+0.4326, 0.2359, 535.1, 546.5, 2.917, 0.54737, 0.34, 536.2, 548.2,
+3.36175, 0.6039, 0.3961, 536.7, 548.9, 3.654, 0.66, 0.45262,
+537.3, 549.7, 4.019, 0.7641, 0.5674, 538.6, 551.2, 5.27107), .Dim = c(5L,
+7L), .Dimnames = list(c("P[1]", "P[2]", "lambda[1]", "lambda[2]",
+"sigma"), c("mean", "sd", "2.5%", "25%", "50%", "75%", "97.5%"
+))), structure(c(2.99564, 0.79689, 1.02513, 0.56926, 0.39621,
+0.72729, 1.914, 0.04475, 0.4099, 2.743, 0.6218, 0.625, 2.997,
+0.7995, 0.82675, 3.255, 0.9782, 1.16825, 4.08502, 1.541, 2.82
+), .Dim = c(3L, 7L), .Dimnames = list(c("alpha", "beta", "sigma"
+), c("mean", "sd", "2.5%", "25%", "50%", "75%", "97.5%"))), structure(c(5.26188,
+2.19814, -5.8793, 0.25999, 0.26441, 0.22576, 7.8008, 0.13613,
+0.16157, 0.14278, 0.11727, 0.12765, 0.10712, 1.17804, 4.991,
+1.883, -6.17302, 0.1279, 0.11789, 0.1088, 5.88897, 5.185, 2.09675,
+-5.964, 0.1859, 0.18, 0.1573, 6.964, 5.263, 2.195, -5.877, 0.2326,
+0.2333, 0.1999, 7.6745, 5.34, 2.296, -5.79, 0.30132, 0.3123,
+0.263, 8.483, 5.527, 2.525, -5.61, 0.55141, 0.59261, 0.492, 10.46
+), .Dim = c(7L, 7L), .Dimnames = list(c("mu[1]", "mu[2]", "mu[3]",
+"sigma[1]", "sigma[2]", "sigma[3]", "sigmaC"), c("mean", "sd",
+"2.5%", "25%", "50%", "75%", "97.5%"))), structure(c(106.61227,
+6.18568, 6.0953, 3.63673, 0.1075, 0.46858, 99.40975, 5.97597,
+5.27197, 104.2, 6.114, 5.776, 106.6, 6.187, 6.058, 109.1, 6.258,
+6.386, 113.6, 6.394, 7.106), .Dim = c(3L, 7L), .Dimnames = list(
+ c("alpha0", "beta.c", "sigma"), c("mean", "sd", "2.5%", "25%",
+ "50%", "75%", "97.5%"))), structure(c(0.71462, 1.2978, -0.15277,
+-39.85965, 0.0106, 0.05567, 0.3192, 0.0106, 0.05567, 0.3192,
+0.0106, 0.05567, 0.3192, 3.38943, 0.14307, 0.38863, 0.16594,
+12.71407, 0.10241, 0.22928, 0.46618, 0.10241, 0.22928, 0.46618,
+0.10241, 0.22928, 0.46618, 0.62795, 0.43279, 0.529, -0.4842,
+-65.22025, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2.417, 0.62217, 1.049,
+-0.26012, -48.11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2.945, 0.7155, 1.294,
+-0.15245, -39.96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3.299, 0.8063, 1.545,
+-0.04546, -31.5775, 0, 0, 1, 0, 0, 1, 0, 0, 1, 3.742, 0.9984,
+2.076, 0.1763, -14.38925, 0, 1, 1, 0, 1, 1, 0, 1, 1, 4.84702), .Dim = c(14L,
+7L), .Dimnames = list(c("b[1]", "b[2]", "b[3]", "b0", "outlier[3]",
+"outlier[4]", "outlier[21]", "outlier[3]", "outlier[4]", "outlier[21]",
+"outlier[3]", "outlier[4]", "outlier[21]", "sigma"), c("mean",
+"sd", "2.5%", "25%", "50%", "75%", "97.5%"))), structure(c(0.02054,
+0.12633, 0.07461, 0.05794, 0.04233, 0.07062, 0.06659, 0.14758,
+0.07197, 0.09058, 0.11631, 0.06903, 0.01981, 0.0272, 0.02389,
+0.00813, 0.01381, 0.01821, 0.02022, 0.02414, 0.01787, 0.02864,
+0.01984, 0.01339, 0.00053, 0.07787, 0.03467, 0.04313, 0.01952,
+0.03927, 0.03268, 0.1034, 0.04114, 0.0432, 0.08016, 0.04533,
+0.00614, 0.107, 0.0575, 0.05223, 0.03235, 0.05768, 0.05224, 0.1307,
+0.05927, 0.06978, 0.1024, 0.05962, 0.01446, 0.1246, 0.07216,
+0.0576, 0.04099, 0.06919, 0.06439, 0.1463, 0.07056, 0.08795,
+0.1156, 0.06826, 0.02884, 0.1438, 0.08924, 0.06318, 0.05081,
+0.08204, 0.07907, 0.1635, 0.08303, 0.1081, 0.1293, 0.07747, 0.07305,
+0.1833, 0.1272, 0.07477, 0.073, 0.1104, 0.1108, 0.1976, 0.1112,
+0.1544, 0.1578, 0.09787), .Dim = c(12L, 7L), .Dimnames = list(
+ c("p[1]", "p[2]", "p[3]", "p[4]", "p[5]", "p[6]", "p[7]",
+ "p[8]", "p[9]", "p[10]", "p[11]", "p[12]"), c("mean", "sd",
+ "2.5%", "25%", "50%", "75%", "97.5%"))), structure(c(0.05312,
+0.10302, 0.07048, 0.05924, 0.05155, 0.06905, 0.06683, 0.12337,
+0.07011, 0.07828, 0.10214, 0.06848, 0.07268, 0.40333, 0.01954,
+0.02166, 0.01741, 0.00786, 0.01312, 0.01486, 0.01593, 0.02261,
+0.01464, 0.01993, 0.01758, 0.01165, 0.0101, 0.1541, 0.01824,
+0.06663, 0.03985, 0.04467, 0.02805, 0.04259, 0.03845, 0.08327,
+0.04392, 0.04419, 0.07166, 0.04744, 0.05319, 0.1655, 0.03923,
+0.08746, 0.05844, 0.05381, 0.04215, 0.0587, 0.05584, 0.1072,
+0.06004, 0.06443, 0.08969, 0.06035, 0.06617, 0.2989, 0.05219,
+0.101, 0.06913, 0.05897, 0.05093, 0.0683, 0.06577, 0.1217, 0.06922,
+0.07633, 0.1009, 0.06796, 0.07253, 0.3818, 0.0656, 0.1163, 0.08104,
+0.06431, 0.06019, 0.07812, 0.07685, 0.1379, 0.07919, 0.08994,
+0.1132, 0.07595, 0.07898, 0.48342, 0.09467, 0.1511, 0.1088, 0.07536,
+0.07873, 0.101, 0.1011, 0.1716, 0.1015, 0.1226, 0.1401, 0.09301,
+0.09334, 0.76511), .Dim = c(14L, 7L), .Dimnames = list(c("p[1]",
+"p[2]", "p[3]", "p[4]", "p[5]", "p[6]", "p[7]", "p[8]", "p[9]",
+"p[10]", "p[11]", "p[12]", "pop.mean", "sigma"), c("mean", "sd",
+"2.5%", "25%", "50%", "75%", "97.5%"))))
Modified: trunk/R2OpenBUGS/man/bugs.Rd
===================================================================
--- trunk/R2OpenBUGS/man/bugs.Rd 2011-03-07 15:09:12 UTC (rev 180)
+++ trunk/R2OpenBUGS/man/bugs.Rd 2011-03-21 19:13:27 UTC (rev 181)
@@ -7,13 +7,14 @@
saves the simulations for easy access in \R or S-PLUS.}
\usage{
-bugs(data, inits, parameters.to.save, n.iter, model.file="model.bug",
+bugs(data, inits, parameters.to.save, n.iter, model.file="model.txt",
n.chains=3, n.burnin=floor(n.iter / 2), n.thin=1,
+ saveExec=FALSE,restart=FALSE,
debug=FALSE, DIC=TRUE, digits=5, codaPkg=FALSE,
OpenBUGS.pgm=ifelse(.Platform$OS.type == "windows" | useWINE==TRUE,
paste("C:/Program Files/OpenBUGS/OpenBUGS",
version,"/OpenBUGS.exe",sep=""),"OpenBUGS"),
- version='312',
+ version='321',
working.directory=NULL,
clearWD=FALSE, useWINE=FALSE, WINE=NULL,
newWINE=TRUE, WINEPATH=NULL, bugs.seed=1, summary.only=FALSE,
@@ -37,12 +38,12 @@
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{OpenBUGS} code.
- The extension can be either \file{.bug} or \file{.txt}.
- If the extension is \file{.bug} and \code{program=="OpenBUGS"},
- a copy of the file with extension \file{.txt} will be created
- in the \code{bugs()} call and removed afterwards. Note that
- similarly named \file{.txt} files will be overwritten.
+ \item{model.file}{File containing the model written in \pkg{OpenBUGS} code.
+ The extension must be \file{.txt}.
+ The old convention allowing model.file to be named \file{.bug} has been eliminated
+ because the new \pkg{OpenBUGS} feature that allows the program image
+ to be saved and later restarted uses the .bug extension for the saved
+ images.
Alternatively, \code{model.file} can be an R function that contains a BUGS model that is written to a
temporary model file (see \code{\link{tempfile}}) using \code{\link{write.model}}.}
\item{n.chains}{number of Markov chains (default: 3)}
@@ -57,6 +58,22 @@
\code{n.iter}. Setting \code{n.thin}=2, doubles the number of iterations OpenBUGS
performs, but does not change \code{n.iter} or \code{n.burnin}. Thinning implemented
in this manner is not captured in summaries created by packages such as \pkg{coda}.}
+ \item{saveExec}{If TRUE, a re-startable image of the OpenBUGS execution is
+ saved with \code{basename(model.file)} and extension .bug in the working
+ directory, which must be specified. The .bug files can be large, so
+ users should monitor them carefully and remove them when not needed.
+}
+ \item{restart}{If TRUE, execution resumes with the final status from
+ the previous execution stored in the .bug file in the working directory.
+ If \code{n.burnin=0},additional iterations are performed and all iterations since
+ the previous burnin are used (including those from past executions). If
+ \code{n.burnin>0}, a new burnin is performed, and the previous iterations are
+ discarded, but execution continues from the status at the end of the previous
+ execution. When \code{restart=TRUE}, only \code{n.burnin}, \code{n.iter},
+ and \code{saveExec} inputs
+ should be changed from the call creating the .bug file, otherwise
+ failed or erratic results may be produced. Note the default has \code{n.burnin>0}.
+}
\item{debug}{if \code{FALSE} (default), \pkg{OpenBUGS} is closed automatically
when the script has finished running, otherwise \pkg{OpenBUGS} remains open
for further investigation. The debug option is not available for linux execution.}
Modified: trunk/R2OpenBUGS/man/bugs.script.Rd
===================================================================
--- trunk/R2OpenBUGS/man/bugs.script.Rd 2011-03-07 15:09:12 UTC (rev 180)
+++ trunk/R2OpenBUGS/man/bugs.script.Rd 2011-03-21 19:13:27 UTC (rev 181)
@@ -8,7 +8,8 @@
\usage{
bugs.script(parameters.to.save, n.chains, n.iter, n.burnin,
- n.thin, model.file, debug=FALSE, is.inits,
+ n.thin, saveExec, restart, model.file.bug,
+ model.file, debug=FALSE, is.inits,
DIC=FALSE, useWINE=FALSE,
newWINE=TRUE, WINEPATH=NULL, bugs.seed=NULL, summary.only=FALSE,
save.history=(.Platform$OS.type == "windows" | useWINE==TRUE),
@@ -21,6 +22,26 @@
\item{n.iter}{number of total iterations (including burn in)}
\item{n.burnin}{length of burn in}
\item{n.thin}{thinning parameter}
+ \item{saveExec}{If TRUE, a re-startable image of the OpenBUGS execution is
+ saved with \code{basename(model.file)} and extension .bug in the working
+ directory, which must be specified. The .bug files can be large, so
+ users should monitor them carefully and remove them when not needed.
+}
+ \item{restart}{If TRUE, execution resumes with the final status from
+ the previous execution stored in the .bug file in the working directory.
+ If \code{n.burnin=0},additional iterations are performed and all iterations since
+ the previous burnin are used (including those from past executions). If
+ \code{n.burnin>0}, a new burnin is performed, and the previous iterations are
+ discarded, but execution continues from the status at the end of the previous
+ execution. When \code{restart=TRUE}, only \code{n.burnin}, \code{n.iter},
+ and \code{saveExec} inputs
+ should be changed from the call creating the .bug file, otherwise
+ failed or erratic results may be produced.
+}
+ \item{model.file.bug}{If saveExec or restart is TRUE, then \code{model.file.bug}
+ receives/contains the OpenBUGS program image for restarting the program.
+ \code{model.file.bug} is the name of the file with its full path
+ }
\item{model.file}{file containing the model written in \pkg{OpenBUGS} code}
\item{debug}{if \code{FALSE}, \pkg{OpenBUGS} is closed automatically,
otherwise \pkg{OpenBUGS} remains open for further investigation. With
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|