From: <woo...@us...> - 2007-04-17 14:21:51
|
Revision: 12 http://svn.sourceforge.net/bugs-r/?rev=12&view=rev Author: woodard_ Date: 2007-04-17 07:21:52 -0700 (Tue, 17 Apr 2007) Log Message: ----------- 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. Modified Paths: -------------- trunk/R2WinBUGS/R/bugs.script.R Modified: trunk/R2WinBUGS/R/bugs.script.R =================================================================== --- trunk/R2WinBUGS/R/bugs.script.R 2007-04-16 11:21:38 UTC (rev 11) +++ trunk/R2WinBUGS/R/bugs.script.R 2007-04-17 14:21:52 UTC (rev 12) @@ -21,6 +21,24 @@ 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 + } + cat( "display ('log')\n", "check ('", native2win(model), "')\n", @@ -28,8 +46,7 @@ "compile (", n.chains, ")\n", if(is.inits) initlist, "gen.inits()\n", - "thin.updater (", n.thin, ")\n", - "update (", ceiling(n.burnin/n.thin), ")\n", + thinUpdateCommand, savelist, if(DIC) "dic.set()\n", rep( This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |