R2WinBUGS - 如何再次将 WinBUGS 计算结果重新加载到 bug 对象
我使用 R 中的 R2WinBUGS 包在 WinBUGS 中运行了一次漫长的计算(百万次迭代):
bugs.object <- bugs(...)
但 R 崩溃了。 如何将 bugs.object 重新加载到 R 中而不再次运行 winbugs? 我尝试了这个(我有 3 个链):
out <- read.bugs(paste("coda", 1:3, ".txt", sep = ""))
但是 out
数据结构与bugs 对象(事实上,它是不可用的)。我尝试使用 as.bugs.array
转换它:
bugs.object <- as.bugs.array(out, model.file = "ttest.txt", n.iter = 1000000, n.burnin = 300000, n.thin = 2, program = "WinBUGS")
但它不起作用。请帮忙。谢谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能正在阅读一条错误消息,其中 R 内存不足,无法创建
bugs.array
对象。您可以通过在
bugs
函数中设置codaPkg=T
语句来解决此问题。这会将 CODA 文件保存在指定的工作目录中,而不是创建 R2WinBUGS 对象(在 R 崩溃之前)。然后,您可以使用 coda 包中的read.mcmc
读回 coda 文件,如果您确实需要,请将mcmc
对象转换为bugs.array
。如果您的 MCMC 太大或者您没有足够的内存用于 R,这可能不起作用。
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 thebugs
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 usingread.mcmc
in the coda package, and if you really want, convert themcmc
object to abugs.array
.This might not work if your MCMC is too big or you do not have enough memory for R.