r - 从 R 调用 WinBUGS14

标签 r winbugs r2winbugs

我正在尝试从 R 调用 WinBUGS,但不太成功。

我在 R 中输入了这段代码:

radon.data <- list ("n", "J", "x", "y", "county")
radon.inits <- function (){
  list (a=rnorm(J), b=rnorm(1), mu.a=rnorm(1),
        sigma.y=runif(1), sigma.a=runif(1))
}
radon.parameters <- c ("a", "b", "mu.a", "sigma.y", "sigma.a")

然后,我调用 WinBUGS:

radon.bugs.1 <- bugs (radon.data, radon.inits, radon.parameters, "radon.1.bug", n.iter=10,
        bugs.directory="C:/Program Files/WinBUGS14", working.directory=NULL, clearWD=TRUE, debug=TRUE )

我在 WinBUGS 中收到以下错误:

set(sigma.y)
command #Bugs:set cannot be executed (is greyed out)
set(sigma.a)
command #Bugs:set cannot be executed (is greyed out)
set(deviance)
command #Bugs:set cannot be executed (is greyed out)
dic.set()
command #Bugs:dic.set cannot be executed (is greyed out)
update(5)
command #Bugs:update cannot be executed (is greyed out)
coda(*,C:/Users/Gabriel/AppData/Local/Temp/Rtmpf1rAQa/coda)
command #Bugs:coda cannot be executed (is greyed out)
stats(*)
command #Bugs:stats cannot be executed (is greyed out)
dic.stats()

DIC
history(*,C:/Users/Gabriel/AppData/Local/Temp/Rtmpf1rAQa/history.odc)
command #Bugs:history cannot be executed (is greyed out)
save(C:/Users/Gabriel/AppData/Local/Temp/Rtmpf1rAQa/log.odc)
save(C:/Users/Gabriel/AppData/Local/Temp/Rtmpf1rAQa/log.txt)

如果有人能帮助我,我将不胜感激。我的文件在同一个

最佳答案

当您的错误尚未编译时,会出现这些错误消息。首先尝试在 WinBUGS 中工作,直到可以启动并运行模型。然后保存

model{
    ....
    bayesian model
    ....
}

作为 .bug 文件的一部分。

关于r - 从 R 调用 WinBUGS14,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9857062/

相关文章:

r - 如果我在 r 中有超过 50 个值,我应该使用什么来代替 ifelse nested?

r - 通过 R 在 WinBUGS 中设置种子

python - BUGS模型和PyMC的区别?

r - 在 R 中调用 OpenBUGS 不起作用

bayesian - WinBUGS 威 bool 网络元分析

通过匹配 ID 和列名检索 data.frame 的值

R:按所有因素水平汇总(存在和不存在)

将数据读入向量

r - 显示进度 R2WinBugs