winbugs怎么做蒙特卡罗模拟法

君,已阅读到文档的结尾了呢~~
论文-MATLAB与WinBUGS在贝叶斯方法测量不确定度评定中的应用
MATLAB and WinBUGS Bayesian Approach to Measurement Uncertainty Assessment
扫扫二维码,随身浏览文档
手机或平板扫扫即可继续访问
论文-MATLAB与WinBUGS在贝叶斯方法测量不确定度评定中的应用
MATLAB and WinBUGS Bayesian Approach to Measurement Uncertainty Assessment
举报该文档为侵权文档。
举报该文档含有违规或不良信息。
反馈该文档无法正常浏览。
举报该文档为重复文档。
推荐理由:
将文档分享至:
分享完整地址
文档地址:
粘贴到BBS或博客
flash地址:
支持嵌入FLASH地址的网站使用
html代码:
&embed src='/DocinViewer--144.swf' width='100%' height='600' type=application/x-shockwave-flash ALLOWFULLSCREEN='true' ALLOWSCRIPTACCESS='always'&&/embed&
450px*300px480px*400px650px*490px
支持嵌入HTML代码的网站使用
您的内容已经提交成功
您所提交的内容需要审核后才能发布,请您等待!
3秒自动关闭窗口查看: 838|回复: 0
R语言 R2WinBUGS包 bugs()函数中文帮助文档(中英文对照)
bugs(R2WinBUGS)
bugs()所属R语言包:R2WinBUGS
& && && && && && && && && && && && && & Run WinBUGS and OpenBUGS from R or S-PLUS
& && && && && && && && && && && && && &&&运行WinBUGS和OpenBUGS,R或S-PLUS
& && && && && && && && && && && && && &&&译者:生物统计家园网 机器人LoveR
描述----------Description----------
The bugs function takes data and starting values as input.&&It automatically writes a WinBUGS script, calls the model, and
bugs函数需要作为输入的数据和初始值。它会自动写入一个WinBUGS脚本,调用模型,并
用法----------Usage----------
bugs(data, inits, parameters.to.save, model.file=&model.bug&,
& & n.chains=3, n.iter=2000, n.burnin=floor(n.iter/2),
& & n.thin=max(1, floor(n.chains * (n.iter - n.burnin) / n.sims)),
& & n.sims = 1000, bin=(n.iter - n.burnin) / n.thin,
& & debug=FALSE, DIC=TRUE, digits=5, codaPkg=FALSE,
& & bugs.directory=&c:/Program Files/WinBUGS14/&,
& & program=c(&WinBUGS&, &OpenBUGS&, &winbugs&, &openbugs&),
& & working.directory=NULL, clearWD=FALSE,
& & useWINE=.Platform$OS.type != &windows&, WINE=NULL,
& & newWINE=TRUE, WINEPATH=NULL, bugs.seed=NULL, summary.only=FALSE,
& & save.history=!summary.only, over.relax = FALSE)
参数----------Arguments----------
参数:data
either a named list (names corresponding to variable names in the model.file) of the data for the WinBUGS model, or (which is not recommended and unsafe) a vector or list of the names of the data objects used by the model. If data is a one element character vector (such as &data.txt&),&&it is assumed that data have already been written to the working directory into that file,&&e.g. by the function bugs.data.
无论是命名列表(名称对应的变量名在model.file)WinBUGS模型,或(不建议这样做不安全的)的数据向量或列表的数据对象的名称所用的模型。如果data是一个元素的向量(如&data.txt&),它是假定数据已被写入到工作目录到该文件中,例如bugs.data的功能。
参数:inits
a list with n. each element of the list is itself a list of starting values for the WinBUGS model, or a function creating (possibly random) initial values. Alternatively, if inits=NULL, initial values are generated by WinBUGS. If inits is a character vector with n.chains elements,&&it is assumed that inits have already been written to the working directory into those files,&&e.g. by the function bugs.inits.
列表的列表中的每个元素是与n.chains元素;本身开始WinBUGS模型,或创建(可能是随机的)初始值的函数的值的列表。另外,如果inits=NULL,初始值所产生的WinBUGS。如果inits是一个字符向量n.chains元素,它被认为是初始化设置已被写入到这些文件的工作目录,例如: bugs.inits的功能。
参数:parameters.to.save
character vector of the names of the parameters to save which should be monitored
的参数的名称的字符向量保存应监视
参数:model.file
file containing the model written in WinBUGS code. The extension can be either &.bug& or &.txt&. If the extension is &.bug& and program==&WinBUGS&, a copy of the file with extension &.txt& will be created in the bugs() call and removed afterwards. Note that similarly named &.txt& files will be overwritten. Alternatively, model.file can be an R function that contains a BUGS model that is written to a&&temporary model file (see tempfile) using write.model.
文件中包含该模型写在WinBUGS代码。扩展名可以是无论是.bug或.txt。如果扩展名是.bug和program==&WinBUGS&,扩展名为.txtbugs()调用中创建和删除后的文件副本。请注意,同样命名为“.txt文件将被覆盖。另外,model.file可以是R功能,它包含一个的BUGS模型,被写入到一个临时的模型文件(见tempfile)使用write.model。
参数:n.chains
number of Markov chains (default: 3)
马尔可夫链(默认值:3)
参数:n.iter
number of total iterations per chain ( default: 2000)
的总迭代链(包括燃烧中,默认:2000)
参数:n.burnin
length of burn in, i.e. number of iterations to discard at the beginning. Default is n.iter/2, that is, discarding the first half of the simulations.
烧伤的长度,即迭代次数丢弃的开始。默认是的n.iter/2,也就是丢弃的模拟上半年。
参数:n.thin
thinning rate. Must be a positive integer.&&Set n.thin & 1 to save memory and computation time if n.iter is large.&&Default is max(1, floor(n.chains *& &&&(n.iter-n.burnin) / 1000)) which will only thin if there are at least 2000 simulations.
细化率。必须是一个正整数。设置n.thin& 1,以节省内存和计算时间,如果n.iter是大。默认是max(1, floor(n.chains *& &&&(n.iter-n.burnin) / 1000))只有薄薄的,如果有至少2000模拟。
参数:n.sims
The approximate number of simulations to keep after thinning.
的大概数值模拟研究,不断细化。
number of iterations between saving of results (i.e. the coda files are saved after each bin iterations); default is to save only at the end.
迭代次数之间保存的结果(即结尾的文件被保存后,每个bin迭代),默认是保存在年底。
参数:debug
if FALSE (default), WinBUGS is closed automatically when the script has finished running, otherwise WinBUGS remains open for further investigation
FALSE如果(默认),WinBUGS被关闭时自动运行脚本已经完成,否则WinBUGS保持打开状态,作进一步调查
if TRUE (default), compute deviance, pD, and DIC. This is done in WinBUGS directly using the rule pD =& &&&Dbar - Dhat.&&If there are less iterations than required for the adaptive phase, the rule pD=var(deviance) / 2 is used.
逻辑,如果TRUE(默认),计算偏差,PD和DIC。这是在WinBUGS直接使用规则pD =& &&&Dbar - Dhat。如果有反复次数比较少,所需的适应期,规则pD=var(deviance) / 2。
参数:digits
number of significant digits used for WinBUGS input, see formatC
一些重要的用于WinBUGS输入的数字,请参阅formatC
参数:codaPkg
if FALSE (default) a bugs object is returned, if TRUE file names of WinBUGS output are returned for easy access by the coda package through function read.bugs (not used if program=&OpenBUGS&). A bugs object can be converted to an mcmc.list object as&&used by the coda package with the method as.mcmc.list&&(for which a method is provided by R2WinBUGS).
逻辑,如果FALSE(默认)bugs对象被返回,如果TRUE文件名WinBUGS输出,以方便返回coda包通过函数read.bugs(不使用,如果program=&OpenBUGS&)。 Abugs对象可以被转换为一个mcmc.list的反对由coda包所用的方法as.mcmc.list(它提供了一种方法R2WinBUGS)。
参数:bugs.directory
directory that contains the WinBUGS executable. If the global option R2WinBUGS.bugs.directory is not NULL,&&it will be used as the default.
目录包含WinBUGS可执行。 ,如果全局选项“R2WinBUGS.bugs.directory是不是NULL,它会被用来作为默认值。
参数:program
the program to use, either winbugs/WinBUGS or openbugs/OpenBUGS, the latter makes use of function openbugs and requires the CRAN package BRugs. The openbugs/OpenBUGS choice is not available in S-PLUS.
程序使用,无论是winbugs/WinBUGS或openbugs/OpenBUGS,后者使用的功能openbugs,并要求CRAN包BRugs 。 openbugs/OpenBUGS的选择是不是可以在S-PLUS。
参数:working.directory
sets working directory during execut WinBUGS' in- and output will be stor if NULL, a temporary working directory via tempdir is used.
工作目录设置此功能的执行过程中,WinBUGS的输入和输出将被保存在该目录中,如果NULL,通过一个临时工作目录tempdir使用。
参数:clearWD
indicating whether the files &data.txt&, &inits[1:n.chains].txt&, &log.odc&, &codaIndex.txt&, and &coda[1:nchains].txt& should be removed after WinBUGS has finished.&&If set to TRUE, this argument is only respected if codaPkg=FALSE.
逻辑;指示文件是否data.txt,inits[1:n.chains].txt,log.odc,codaIndex.txt,和 coda[1:nchains].txt应该被删除后WinBUGS已完成。如果设置为TRUE,这种说法是唯一的尊重,如果codaPkg=FALSE。
参数:useWINE
attempt to use the Wine emulator to run WinBUGS, defaults to FALSE on Windows, and TRUE otherwise. Not available in S-PLUS.
逻辑,尝试使用Wine模拟器运行WinBUGS,默认为FALSE在Windows,TRUE否则。不适用于S-PLUS。
参数:WINE
character, path to &wine& binary file, it is tried hard (by a guess and the utilities which and locate)&&to get the information automatically if not given.
字符,路径wine的二进制文件,它努力(的猜测和公用事业which和locate)得到的信息如果不提供自动。
参数:newWINE
Use new versions of Wine that have &winepath& utility
使用新版本的葡萄酒,有winepath实用
参数:WINEPATH
character, path to &winepath& binary file, it is tried hard (by a guess and the utilities which and locate)&&to get the information automatically if not given.
字符,路径winepath的二进制文件,它努力(的猜测和公用事业which和locate)得到的信息如果不提供自动。
参数:bugs.seed
random seed for WinBUGS (default is no seed)
随机种子WinBUGS(默认情况下是没有种子)
参数:summary.only
If TRUE, only a parameter summary for very quick analyses is given,&&temporary created files are not removed in that case.
如果TRUE,只有一个参数非常快速的分析摘要,在这种情况下,临时创建的文件不会被删除。
参数:save.history
If TRUE (the default), trace plots are generated at the end.
如果TRUE(默认值),跟踪曲线结束时生成。
参数:over.relax
If TRUE, over-relaxed form of MCMC is used if available from WinBUGS.
如果TRUE,过度宽松的MCMC(如果可用)WinBUGS。
详细信息----------Details----------
To run:&&&ol& Write a BUGS model in an ASCII file (hint: use write.model).
运行:&OL&写一个BUGS模型的ASCII文件中(提示:使用write.model)。
Go into R / S-PLUS.
进入R / S-PLUS。
Prepare the inputs for the bugs function and run it (see Example section).
准备输入bugs功能,并运行它(见例一节)。
A WinBUGS window will pop up and R / S-PLUS will freeze up. The model will now run in WinBUGS. It might take awhile. You will see things happening in the Log window within WinBUGS. When WinBUGS is done, its window will close and R / S-PLUS will work again.
AWinBUGS窗口会弹出,R / S-PLUS将冻结。现在,该模型将运行在WinBUGS。这可能需要一段时间。你会看到事情发生在“log”窗口内WinBUGS。当WinBUGS是,它的窗口将关闭,R / S-PLUS会再次工作。
If an error message appears, re-run with debug=TRUE. &/ol&
如果出现错误消息,请重新运行与debug=TRUE。 &/ OL&
BUGS version support:&&
BUGS版本支持:
WinBUGS 1.4.*default
WinBUGS 1.4 *默认
OpenBUGS 2.*via argument program=&OpenBUGS& &/ul&
OpenBUGS2。通过参数program=&OpenBUGS&&/ ul&
Operation system support:&&
操作系统支持:
MS Windowsno problem
MS Windows没有问题
Linux, Mac OS X and Unix in generalpossible with Wine emulation via useWINE=TRUE, but only for WinBUGS 1.4.* &/ul&
Linux,Mac OS X和Unix在generalpossible与葡萄酒仿真通过useWINE=TRUE,但仅适用于WinBUGS1.4 * &/ ul&
If useWINE=TRUE is used, all paths (such as working.directory and model.file, must be given in native (Unix) style, but bugs.directory can be given in Windows path style (e.g. &c:/Program Files/WinBUGS14/&) or native (Unix) style (e.g. &/path/to/wine/folder/dosdevices/c:/Program Files/WinBUGS14&).&&This is done to achieve greatest portability with default argument value for bugs.directory.
useWINE=TRUE如果时,所有路径(如working.directory和model.file,必须在本机(UNIX)风格,但bugs.directory可以在Windows路径样式(例如,“C :/程序Files/WinBUGS14个/”)或本机(UNIX)的样式(例如“/路径/到/酒/文件夹/的DosDevices / C :/程序Files/WinBUGS14的”)。这样做是为了实现为bugs.directory的默认参数值最大的可携性。
值----------Value----------
If codaPkg=TRUE the returned values are the names of coda output files written by WinBUGS containing the Markov Chain Monte Carlo output in the CODA format. This is useful for direct access with read.bugs.
如果codaPkg=TRUE的返回值是写的尾波输出文件的名称WinBUGS马尔可夫链蒙特卡罗CODA格式输出。这是可直接访问read.bugs。
If codaPkg=FALSE, the following values are returned: &table summary=&R valueblock&& &tr valign=&top&&&td&n.chains&/td& &td& see Section &Arguments&&/td&&/tr& &tr valign=&top&&&td&n.iter&/td& &td& see Section &Arguments&&/td&&/tr& &tr valign=&top&&&td&n.burnin&/td& &td& see Section &Arguments&&/td&&/tr& &tr valign=&top&&&td&n.thin&/td& &td& see Section &Arguments&&/td&&/tr& &tr valign=&top&&&td&n.keep&/td& &td& number of iterations kept per chain (equal to (n.iter-n.burnin) / n.thin)&/td&&/tr& &tr valign=&top&&&td&n.sims&/td& &td& number of posterior simulations (equal to n.chains * n.keep)&/td&&/tr& &tr valign=&top&&&td&sims.array&/td& &td& 3-way array of simulation output, with dimensions n.keep, n.chains, and length of combined parameter vector&/td&&/tr& &tr valign=&top&&&td&sims.list&/td& &td& list of simulated parameters: for each scalar parameter, a vector of length n.sims for each vector parameter, a 2-way array of simulations, for each matrix parameter, a 3-way array of simulations, etc. (for convenience, the n.keep*n.chains simulations in sims.matrix and sims.list (but NOT sims.array) have been randomly permuted)&/td&&/tr& &tr valign=&top&&&td&sims.matrix&/td& &td& matrix of simulation output, with n.chains*n.keep rows and one column for each element of each saved parameter (for convenience, the n.keep*n.chains simulations in sims.matrix and sims.list (but NOT sims.array) have been randomly permuted)&/td&&/tr& &tr valign=&top&&&td&summary&/td& &td& summary statistics and convergence information for each saved parameter.&/td&&/tr& &tr valign=&top&&&td&mean&/td& &td& a list of the estimated parameter means&/td&&/tr& &tr valign=&top&&&td&sd&/td& &td& a list of the estimated parameter standard deviations&/td&&/tr& &tr valign=&top&&&td&median&/td& &td& a list of the estimated parameter medians&/td&&/tr& &tr valign=&top&&&td&root.short&/td& &td& names of argument parameters.to.save and &deviance&&/td&&/tr& &tr valign=&top&&&td&long.short&/td& &td& programming stuff&/td&&/tr& &tr valign=&top&&&td&dimension.short&/td& &td& dimension of indexes.short&/td&&/tr& &tr valign=&top&&&td&indexes.short&/td& &td& indexes of root.short&/td&&/tr& &tr valign=&top&&&td&last.values&/td& &td& list of simulations from the m they can be used as starting points if you wish to run WinBUGS for further iterations&/td&&/tr& &tr valign=&top&&&td&pD&/td& &td& an estimate of the effective number of parameters, for calculations see the section &Arguments&.&/td&&/tr& &tr valign=&top&&&td&DIC&/td& &td& mean(deviance) + pD&/td&&/tr& &/table&
如果codaPkg=FALSE,返回下面的值:&table summary=&R valueblock&& &tr valign=&top&& &TD&n.chains &/ TD& &TD&组“参数 &/ TD& &/ TR& &tr valign=&top&& &TD&n.iter&/ TD& &TD&组“参数”&/ TD& &/ TR& &TR VALIGN = “顶”& &TD& n.burnin &/ TD& &TD&组“参数”&/ TD& &/ TR& &tr valign=&top&& &TD&n.thin / TD& &TD&组“参数”&/ TD& &/ TR& &tr valign=&top&& &TD&n.keep&/ TD& &TD&保持每个链的迭代次数(等于(n.iter-n.burnin) / n.thin)&/ TD& &/ TR& &tr valign=&top&& &TD&n.sims &/ TD& &TD&后的模拟(等于n.chains * n.keep的)&/ TD& &/ TR& &tr valign=&top&& &TD&sims.array &/ TD& &TD& 3路模拟输出数组,尺寸n.keep,n.chains的组合参数向量,长度&/ TD& &/ TR& &tr valign=&top&& &TD& sims.list &/ TD& &TD&模拟的参数列表:为每一个标量参数,矢量长度n.sims每个向量参数,一个2路的模拟阵列,每个矩阵参数,模拟了3路阵列,等(为方便起见,n.keep*n.chains模拟在sims.matrix和西姆斯随机置换。列表(但不sims.array))&/ TD& &/ TR& &tr valign=&top&& &TD&sims.matrix &/ TD& &TD&矩阵的模拟输出,用n.chains*n.keep行和一列的每个元素保存的每个参数(为方便起见,的n.keep*n.chains的模拟在sims.matrix和sims.list的(但不sims.array)随机置换)&/ TD& &/ TR& &tr valign=&top&& &TD&summary&/ TD& &TD&保存的每个参数的汇总统计和收敛信息。&/ TD& &/ TR& &TR VALIGN =“”& &TD&mean &/ TD& &TD&估计的参数列表,意味着&/ TD& &/ TR& &tr valign=&top&& &TD&sd &/ TD& &td&一个列表中的参数估计标准差&/ TD& &/ TR& &tr valign=&top&& &TD& median&/ TD& &td&一个列表估计参数的中位数&/ TD& &/ TR& &tr valign=&top&& &TD&root.short &/ TD& &TD&名称参数parameters.to.save“和”越轨行为“&/ TD& &/ TR& &tr valign=&top&& &TD& long.short &/ TD& &TD&指标;编程的东西&/ TD& &/ TR& &tr valign=&top&& & dimension.short TD& &/ TD& &TD&尺寸indexes.short&/ TD& &/ TR& &tr valign=&top&& &TD&indexes.short &/ TD& & TD&指标root.short &/ TD& &/ TR& &tr valign=&top&& &TD&last.values &/ TD& &TD&列表从最近的迭代模拟;可作为开始点,如果你想运行WinBUGS进一步的迭代&/ TD& &/ TR& &tr valign=&top&& &TD& pD&/ TD& &TD&的有效的参数个数,计算的估计请参见“参数”。&/ TD& &/ TR& &tr valign=&top&& &TD& DIC&/ TD& &TD& mean(deviance) + pD&/ TD& &/ TR& &/ TABLE&
(作者)----------Author(s)----------
Andrew Gelman, &a href=&mailto:gelman@stat.columbia.edu&&gelman@stat.columbia.edu&/a&,
&a href=&http:/www.stat.columbia.edu/~gelman/bugsR/&&http:/www.stat.columbia.edu/~gelman/bugsR/&/a&; modifications and
packaged by Sibylle Sturtz, &a href=&mailto:sturtz@statistik.tu-dortmund.de&&sturtz@statistik.tu-dortmund.de&/a&,
and Uwe Ligges.
参考文献----------References----------
Gelman, A., Carlin, J.B., Stern, H.S., Rubin, D.B. (2003): Bayesian Data Analysis, 2nd edition, CRC Press.
Sturtz, S., Ligges, U., Gelman, A. (2005): R2WinBUGS: A Package for Running WinBUGS from R. Journal of Statistical Software 12(3), 1-16.
参见----------See Also----------
print.bugs, plot.bugs, as well as
print.bugs,plot.bugs,以及
实例----------Examples----------
# An example model file is given in:[一个例子模型文件:]
model.file &- system.file(package=&R2WinBUGS&, &model&, &schools.txt&)
# Let's take a look:[让我们来看看:]
file.show(model.file)
# Some example data (see ?schools for details):[一些示例数据(见学校的详细信息):]
data(schools)
J &- nrow(schools)
y &- schools$estimate
sigma.y &- schools$sd
data &- list(J=J, y=y, sigma.y=sigma.y)
inits &- function(){
& & list(theta=rnorm(J, 0, 100), mu.theta=rnorm(1, 0, 100),
& && && &sigma.theta=runif(1, 0, 100))
## or alternatively something like:[#或者类似的东西:]
# inits &- list([初始化设置 - 列表(]
#& &list(theta=rnorm(J, 0, 90), mu.theta=rnorm(1, 0, 90),[列表(θ= rnorm mu.theta = rnorm(1,0,90),(J,0,90),]
#& && &&&sigma.theta=runif(1, 0, 90)),[sigma.theta = runif(1,0,90)),]
#& &list(theta=rnorm(J, 0, 100), mu.theta=rnorm(1, 0, 100),[列表(θ= rnorm(J,0,100),mu.theta = rnorm(1,0,100),]
#& && &&&sigma.theta=runif(1, 0, 100))[sigma.theta = runif(1,0,100))]
#& &list(theta=rnorm(J, 0, 110), mu.theta=rnorm(1, 0, 110),[列表(θ= rnorm(J,0,110),mu.theta = rnorm(1,0,110),]
#& && &&&sigma.theta=runif(1, 0, 110)))[sigma.theta = runif(1,0,110)))]
parameters &- c(&theta&, &mu.theta&, &sigma.theta&)
## Not run: [#不运行:]
## You may need to edit &bugs.directory&,[#您可能需要编辑“bugs.directory”的,]
## also you need write access in the working directory:[#你也需要在工作目录的写访问:]
schools.sim &- bugs(data, inits, parameters, model.file,
& & n.chains=3, n.iter=5000,
& & bugs.directory=&c:/Program Files/WinBUGS14/&)
print(schools.sim)
plot(schools.sim)
## End(Not run)[#(不执行)]
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
Powered by 上传我的文档
 下载
 收藏
该文档贡献者很忙,什么也没留下。
 下载此文档
正在努力加载中...
MCMC方法及WinBUGs介绍 (1)
下载积分:2000
内容提示:MCMC方法及WinBUGs介绍 (1)
文档格式:PPT|
浏览次数:16|
上传日期: 13:13:23|
文档星级:
该用户还上传了这些文档
MCMC方法及WinBUGs介绍 (1)
官方公共微信君,已阅读到文档的结尾了呢~~
扫扫二维码,随身浏览文档
手机或平板扫扫即可继续访问
贝叶斯混合处理比较及WinBUGS实现
举报该文档为侵权文档。
举报该文档含有违规或不良信息。
反馈该文档无法正常浏览。
举报该文档为重复文档。
推荐理由:
将文档分享至:
分享完整地址
文档地址:
粘贴到BBS或博客
flash地址:
支持嵌入FLASH地址的网站使用
html代码:
&embed src='/DocinViewer-4.swf' width='100%' height='600' type=application/x-shockwave-flash ALLOWFULLSCREEN='true' ALLOWSCRIPTACCESS='always'&&/embed&
450px*300px480px*400px650px*490px
支持嵌入HTML代码的网站使用
您的内容已经提交成功
您所提交的内容需要审核后才能发布,请您等待!
3秒自动关闭窗口

我要回帖

更多关于 蒙特卡罗模拟 matlab 的文章

 

随机推荐