R语言:R2OpenBUGS
用这个包调用BUGS model,分别用表格和图形概述inference和convergence,保存估计的结果
as.bugs.array 转换成bugs object
函数把马尔科夫链估计结果(不是来自于BUGS),转成BUGS object,主要用来plot.bugs 展示结果。
as.bugs.array(sims.array, model.file=NULL, program=NULL, DIC=FALSE, DICOutput=NULL, n.iter=NULL, n.burnin=0, n.thin=1)
sims.array :3维数组 n.keep, n.chains和combined parameter vector的长度
model.file : OpenBUGS编写的.odc 模型文件
DIC : 是否计算DIC曲线
DICOutput : DIC值
n.iter :生成sims.array 每条chain 迭代数
n.burnin :丢弃的迭代次数
n.thin :thinning rate
attach.all 添加数据到搜索路径
The database is attached/detached to the search path,While attach.all attaches all elements of an object x to a database called name, attach.bugs attaches all elements of x$sims.list to the database bugs.sims itself making use of attach.all.
attach.all(x, overwrite = NA, name = “attach.all”) attach.bugs(x, overwrite = NA) detach.all(name = “attach.all”) detach.bugs()
x : bugs 对象
overwrite :TRUE 删除全局环境中被掩盖的数据, NA 询问,FALSE
name : 环境name
bugs 最重要,用R运行bugs
自动输入值,启动bugs,保存结果
bugs(data, inits, parameters.to.save, n.iter, model.file=“model.txt”, n.chains=3, n.burnin=floor(n.iter / 2), n.thin=1, saveExec=FALSE,restart=FALSE, debug=FALSE, DIC=TRUE, digits=5, codaPkg=FALSE, OpenBUGS.pgm=NULL, working.directory=NULL, clearWD=FALSE, useWINE=FALSE, WINE=NULL, newWINE=TRUE, WINEPATH=NULL, bugs.seed=1, summary.only=FALSE, save.history=(.Platform$OS.type == “windows” | useWINE==TRUE), over.relax = FALSE)
data :模型中使用的数据
inits :n chain 的元素列表,每一个要素是一个模型初始值列表,或者一个生成初始值得function
parameters.to.save : 需要被记录的参数名向量
model.file : model 文件.txt
n.chains : 默认3条
n.iter :每条链的迭代次数,默认2000
n.thin : Thinning rate. 正整数,默认是1,
saveExec :使用basename(模型.file)保存OpenBUGS执行的重新启动映像。
restart :执行从上次执行的最后状态恢复,存储在工作目录中的.bug文件中。
debug : 默认FALSE,正在运行行时Openbugs 页面关闭
DIC :计算deviance,,pD,和DIC。
digits :有效小数位数
codaPkg :FALSE 返回 bugs对象,否则输出,用coda 包 read.bugs 读取,
OpenBUGS.pgm :通向OpenBUGS可执行程序的完整路径。
working.directory:OpenBUGS的输入和输出将存储在此目录中;
clearWD :是否这些文件的“data.tx