4

I have run a looong computation in WinBUGS (million iterations) using the R2WinBUGS package from within R:

bugs.object <- bugs(...)

but the R crashed. How do I reload the bugs.object into R again without running winbugs again? I tried this (I have 3 chains):

out <- read.bugs(paste("coda", 1:3, ".txt", sep = ""))

but the out data structure is completely diferent from the bugs object (as it is, it is unusable). I tried to convert it with as.bugs.array:

bugs.object <- as.bugs.array(out, model.file = "ttest.txt", n.iter = 1000000, n.burnin = 300000, n.thin = 2, program = "WinBUGS")

but it doesn't work. Please help. Thanks.

Tomas
  • 57,621
  • 49
  • 238
  • 373
  • Cross posted: http://stats.stackexchange.com/questions/15262/how-to-reload-the-winbugs-computation-results-to-bugs-object-again – Chase Sep 06 '11 at 18:11
  • start by looking at `str(out)`, `class(out)` (you could post the results, although `str(out)` might give voluminous output). As specified by `?read.bugs`, you should get an object of class `mcmc.list` which can then be analyzed using `coda` functions ... ? – Ben Bolker Jun 04 '12 at 15:06

1 Answers1

3

It is likely that you are reading a error message, where R ran out of memory to create the bugs.array object.

You can get round this problem by setting the codaPkg=T statement in the bugs function. This saves the CODA files in your specified working directory rather than creating the R2WinBUGS object (before R crashes). Then you can read the coda files back in using read.mcmc in the coda package, and if you really want, convert the mcmc object to a bugs.array.

This might not work if your MCMC is too big or you do not have enough memory for R.

guyabel
  • 8,014
  • 6
  • 57
  • 86