大家好,这两天正在尝试用R语言做生存分析,其中需要贝叶斯统计;主要模型是来自文献资料,但是运行过程中反复出现问题,希望大神们帮忙解答,谢谢!
我用了两种方法,载入Library(BRugs),然后运行如下代码:
以上,前面model check通过,load data通过,model compile通过,但是问题在于,每次到了modelGenInits() 这一步,就会提示:
Rstudio提示:
Error in handleRes(res) : NA
In addition: Warning message:
running command '"d:/Program Files/R/R-3.1.3patched/library/BRugs/exec/BugsHelper.exe" "C:/Users/TONGZ~1/AppData/Local/Temp/RtmpwPtl0g" "C:/Users/TONGZ~1/AppData/Local/Temp/RtmpwPtl0g/trash" "file18382a0663b.bug" "C:/Users/TONGZ~1/AppData/Local/Temp/RtmpwPtl0g/cmds.txt" "1"' had status 144
实在不明白怎么回事,找到了 Bugshelper.exe 双击打开提示
后来我在Openbugs 中找到libOpenBUGS.dll(重新安装了几次,该文件应当没有损坏。。),放到Bugshelper.exe旁边,又出现了第一张图的提示……
反复如此,用R和Rstudio都是一样的……
之后,我只好放弃Openbugs,改用R2WinBUGS
模型仍然是以上模型,读入的数据也是以上数据,最后运行bugs:
bugs.sim<-bugs(data,inits=NULL,parameters,noyear,n.chains=3,n.iter=40000,n.burnin=1000,bugs.directory="D:/winbugs14/WinBUGS14/",working.directory="c:/Bugs",debug=TRUE)
log信息如下:
display(log)
check(c:/Bugs/noyear.bug.txt)
model is syntactically correct
data(c:/Bugs/data.txt)
undefined variable
compile(3)
gen.inits()
command #Bugs:gen.inits cannot be executed (is greyed out)
thin.updater(117)
update(9)
command #Bugs:update cannot be executed (is greyed out)
set(beta)
command #Bugs:set cannot be executed (is greyed out)
set(p1)
command #Bugs:set cannot be executed (is greyed out)
set(p2)
command #Bugs:set cannot be executed (is greyed out)
set(p3)
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(334)
command #Bugs:update cannot be executed (is greyed out)
coda(*,c:/Bugs/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:/Bugs/history.odc)
command #Bugs:history cannot be executed (is greyed out)
save(c:/Bugs/log.odc)
save(c:/Bugs/log.txt)
看这个意思好像是有未定义的变量。。?可是之前在BRugs中应该已经通过了啊。。
总是。。两种办法都卡住了。。。希望高手们看一下帮帮忙撒~~
十分感谢!!!!!