找回密码
 注册
查看: 618|回复: 0

R语言 runjags包 xgrid.run.jags()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-9-28 23:45:11 | 显示全部楼层 |阅读模式
xgrid.run.jags(runjags)
xgrid.run.jags()所属R语言包:runjags

                                        Run a JAGS Model using an Xgrid distributed computing cluster
                                         运行一个JAGS的型号,使用Xgrid的分布式计算聚类

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

Extends the functionality of the (auto)run.jags(file) family of functions to use with Apple Xgrid distributed computing clusters.  Jobs can either be run synchronously using xgrid.(auto)run.jags(file) in which case the process will wait for the model to complete before returning the results, or asynchronously using xgrid.submit.jags(file) in which case the process will terminate on submission of the job and results are retrieved at a later time using xgrid.results.jags.  The latter function can also be used to check the progress of incomplete simulations without stopping or retrieving the full job.  Access to an Xgrid cluster with JAGS (although not necessarily R) installed is required.  Due to the dependance on Xgrid software to perform the underlying submission and retrieval of jobs, these functions can only be used on machines running Mac OS X.  Further details of required environmental variables and the optional mgrid script to enable multi-task jobs can be found in the details section.
(自动)run.jags的(文件)家庭的功能,使用与苹果公司的Xgrid的分布式计算聚类扩展的功能。乔布斯可以同步运行使用XGRID。(自动)run.jags“(文件)的模型,在这种情况下,进程将等待完成,然后返回结果,或异步使用xgrid.submit.jags(文件),在这种情况下,过程将终止,在以后的使用xgrid.results.jags提交作业和检索结果。后者的功能也可以被用来检查不停止或检索的充分的作业不完全模拟的进展。访问JAGS Xgrid的聚类(尽管不一定R)安装是必需的。的DEPENDANCE利用Xgrid软件执行基本的提交和检索的工作,这些功能只能用在机器上运行Mac OS X的进一步详情所需的环境变量和可选的MGRID脚本,使多任务的工作可以发现在细节部分。


用法----------Usage----------



xgrid.run.jags(wait.interval="10 min", xgrid.method='simple',
jagspath='/usr/local/bin/jags', jobname=NA, cleanup=TRUE,
sub.app=if(!file.exists(Sys.which('mgrid')))
'xgrid -job submit -in "$indir"'
else 'mgrid -t $ntasks -i "$indir"', sub.options="",
sub.command=paste(sub.app, sub.options, '"$cmd"',
sep=' '), ...)

xgrid.run.jagsfile(wait.interval="10 min", xgrid.method='simple',
jagspath='/usr/local/bin/jags', jobname=NA, cleanup=TRUE,
sub.app=if(!file.exists(Sys.which('mgrid')))
'xgrid -job submit -in "$indir"'
else 'mgrid -t $ntasks -i "$indir"', sub.options="",
sub.command=paste(sub.app, sub.options, '"$cmd"',
sep=' '), ...)

xgrid.autorun.jags(wait.interval="10 min", xgrid.method='simple',
jagspath='/usr/local/bin/jags', jobname=NA, cleanup=TRUE,
sub.app=if(!file.exists(Sys.which('mgrid')))
'xgrid -job submit -in "$indir"'
else 'mgrid -t $ntasks -i "$indir"', sub.options="",
sub.command=paste(sub.app, sub.options, '"$cmd"',
sep=' '), ...)

xgrid.autorun.jagsfile(wait.interval="10 min", xgrid.method='simple',
jagspath='/usr/local/bin/jags', jobname=NA, cleanup=TRUE,
sub.app=if(!file.exists(Sys.which('mgrid')))
'xgrid -job submit -in "$indir"'
else 'mgrid -t $ntasks -i "$indir"', sub.options="",
sub.command=paste(sub.app, sub.options, '"$cmd"',
sep=' '), ...)

xgrid.submit.jags(xgrid.method='simple', jagspath='/usr/local/bin/jags',
jobname=NA, sub.app=if(!file.exists(Sys.which('mgrid')))
'xgrid -job submit -in "$indir"' else 'mgrid -t $ntasks -i "$indir"',
sub.options="", sub.command=paste(sub.app, sub.options, '"$cmd"',
sep=' '), ...)


xgrid.submit.jagsfile(xgrid.method='simple',
jagspath='/usr/local/bin/jags',
jobname=NA, sub.app=if(!file.exists(Sys.which('mgrid')))
'xgrid -job submit -in "$indir"' else 'mgrid -t $ntasks -i "$indir"',
sub.options="", sub.command=paste(sub.app, sub.options, '"$cmd"',
sep=' '), ...)

xgrid.results.jags(jobname, cleanup=TRUE, ...)




参数----------Arguments----------

参数:wait.interval
when running xgrid jobs synchronously, the waiting time between retrieving the status of the job.  If the job is found to be finished on retrieving the status then results are returned, otherwise the function waits for 'wait.interval' before repeating the process.  Time units of seconds, minutes, hours, days or weeks can be specified.  If no units are given the number is assumed to represent minutes.  Default "10 min".
Xgrid的工作同步运行时,检索的工作状态之间的等待时间。如果作业完成检索的状态,然后结果被返回,否则功能等待wait.interval“,然后重复这个过程。单位为秒,分钟,小时,天或数周的时间,可以指定。如果没有单位给出的数字被假定为代表分钟。默认的“10分钟”。


参数:xgrid.method
the method of submitting the simulation to Xgrid - one of 'simple', 'separatejobs' or 'separatetasks'.  The former runs all chains on a single node, whereas 'separatejobs' runs all chains as individual xgrid jobs and 'separatetasks' runs all chains as individual tasks within the same job (this makes the job information in Xgrid Admin easier to read).  Note that the 'seperatejobs' and 'seperatetasks' methods use separate JAGS instances to speed up execution of models with multiple chains, but cannot be used with monitor.pd, monitor.pd.i or monitor.popt.  Each chain is specified using a different random number generator (.RNG.name) for up to 4 chains (the number of different RNG available in JAGS), unless .RNG.name is specified in the initial values.  Because each chain uses a separate JAGS instance, JAGS has no way of ensuring independence between multiple chains using the same random number generator (as would normally be done when calling a single JAGS instance with multiple chains).  Using more than 4 chains with the 'separatejobs' or 'separatetasks' method without the use of new RNG factories may therefore produce dependence between chains, and is not recommended (a warning is given if trying to do so).  Also, the 'separatetasks' method requires a submission script that is capable of supporting multi-task jobs, such as the mgrid script included with the runjags package (see the details section for more details and installation instructions).  If each chain is likely to return a large amount of information then 'separatejobs' should be used in preference to 'separatetasks'; this is because jobs are retrieved individually which reduces the chances of overloading the Xgrid controller.  Default 'simple'.
提交模拟Xgrid的 - 一个“简单”,“separatejobs”或“separatetasks”的方法。前者在单个节点上运行的所有链条,,而“separatejobs”运行所有个人的Xgrid的工作和“separatetasks”链链运行的所有个人在同一个工作任务(这使得Xgrid的管理员更容易阅读的作业信息)。注意seperatejobs和seperatetasks的方法,使用单独的JAGS实例以加快执行与多个链的模型,但不能用于与monitor.pd,monitor.pd.i或monitor.popt。每个链指定使用一个不同的随机数发生器(。RNG.name)最多至4个链(的RNG在JAGS提供不同数量的),,除非。RNG.name指定在初始值。因为每个链使用一个单独的JAGS实例,JAGS有没有办法确保多个链,使用相同的随机数发生器(如时,通常会通过调用一个单一JAGS实例与多个链)之间的独立性。因此,使用超过4链“separatejobs”或separatetasks的方法,而无需使用新的RNG工厂生产链之间的依赖,不推荐(警告如果试图这样做)。此外,的“separatetasks”的方法需要提交的脚本,它是能够支持多任务工作,如MGRID脚本的runjags包(见细节部分更多的细节和安装说明)。如果每个链是可能返回一个大量的信息应使用偏好separatetasks然后separatejobs的,这是因为检索作业单独的机会减少超载Xgrid控制器。默认的“简单”。


参数:method
the method with which to call JAGS; one of 'simple', 'interruptible' or 'parallel'.  The former runs JAGS as a foreground process (the default behaviour for runjags < 0.9.6), 'interruptible' allows the JAGS process to be terminated immediately using the interrupt signal 'control-c' (terminal/console versions of R only), and 'parallel' runs each chain as a separate process on a separate core.  Note that the latter uses separate JAGS instances to speed up execution of models with multiple chains (at the expense of using more RAM), but cannot be used with monitor.pd, monitor.pd.i or monitor.popt.  Each chain is specified using a different random number generator (.RNG.name) for up to 4 chains (the number of different RNG available in JAGS), unless .RNG.name is specified in the initial values.  Using more than 4 chains without the use of new RNG factories may produce dependence between chains, and is not recommended (a warning is given if trying to do so).  Only the 'simple' method is available for Windows.  On machines running Mac OS X and with access to an Apple Xgrid cluster, the method may be a list with an element 'xgrid.method="simple"' (see xgrid.run.jags for more information).  Default 'interruptible' on terminal/console versions of R, or 'simple' on GUI versions of R or when running over xgrid (methods other than 'simple' require the use of 'ps' which is not available when running jobs as 'nobody' via xgrid).
打检测JAGS的方法,一个简单,中断或水货。前者运行JAGS作为一个前台进程(runjags <0.9.6的默认行为),“中断”允许的JAGS过程将立即终止使用的中断信号的控制C(仅R的终端/主机版本) ,水货运行的每一条链作为一个单独的进程在一个单独的核心。请注意,后者使用单独JAGS的实例来加快执行速度的模型与多个链(在使用更多的RAM的费用),但不能用于与monitor.pd,monitor.pd.i或monitor.popt。每个链指定使用一个不同的随机数发生器(。RNG.name)最多至4个链(的RNG在JAGS提供不同数量的),,除非。RNG.name指定在初始值。新的RNG工厂使用的情况下使用4个以上的连锁链之间,可能会产生依赖性,因此不建议(警告如果试图这样做)。只有“简单”的方法,是适用于Windows。机器上运行Mac OS X和一个苹果利用Xgrid聚类,该方法可能是一个列表元素xgrid.method =“简单”(见xgrid.run.jags的详细信息)。终端/主机版本的R默认的中断“,或”简单“的GUI版本的R或运行时超过XGRID(需要使用其他方法比”简单“的”PS“,这是不是正在运行的作业时,”人“通过XGRID)。


参数:jagspath
the path to the JAGS executable on the xgrid machines. Note that /usr/local/bin is not included in the path when running Xgrid jobs, so it is safer to provide the full path.  If not all machines on the xgrid cluster have JAGS installed then it is possible to use an ART script to ensure the job is sent to only machines that do - see the examples section for details.  Default '/usr/local/bin/jags' (this is the default install location for JAGS).
路径到可执行文件的XGRID机JAGS。注意:不包括在/ usr / local / bin目录的路径中运行时,Xgrid的工作,所以它是提供更安全的完整路径。如果不是所有的机器的XGRID聚类JAGS安装,那么它可以使用ART的脚本,以确保作业被发送,只有机器 - 参见范例章节的细节。默认的/ usr / local / bin中/锯齿“(这是默认的安装位置JAGS)。


参数:jobname
for all functions except xgrid.results.jags, the jobname can be provided to make identification of the job using Xgrid Admin easier.  If none is provided, then one is generated using a combination of the username and hostname of the submitting machine.  If the provided jobname is already used by a file/folder in the working directory, then the name is altered to be unique using new_unique().  For xgrid.results.jags, the jobname must be supplied to match the jobname value returned by xgrid.submit.jags(file) during job submission.
除了xgrid.results.jags的所有功能,在JOBNAME可以通过Xgrid管理员更容易的工作作出鉴定。如果没有提供,再一个是使用相结合的提交机器的用户名和主机名。如果提供的工作名已被使用的工作目录中的文件/文件夹,然后改变了是唯一使用new_unique的()。 xgrid.results.jags,jobName必须提供相匹配的工作名在作业提交由xgrid.submit.jags(文件)返回的值。


参数:cleanup
option to delete the job(s) from Xgrid after retrieving result.  Default TRUE.
选项删除作业(S),从检索结果后,利用Xgrid。默认为true。


参数:sub.app
the submission application or script to use for job running/submission.  The inbuilt Xgrid application supports most options, but greater functionality is provided by the mgrid script (see the details section for more information and installation instructions). Any other custom script can be used with the requirements that it submit the job provided and print the Xgrid job ID to screen before exiting (as the only numerical value printed), or alternatively the script may submit the job and create a 'jobid.txt' file in the working directory containing the job id.  If xgrid.method is 'separatejobs' then the argument may be of length equal to the number of chains, in which case each job is submitted using a different application/script. Paths with spaces in them must be quoted when the command is passed to the shell (this may mean escaping quotes if necessary).  Default uses mgrid if installed, otherwise 'xgrid -job submit'.
提交应用程序或脚本,用于运行/提交工作。内置的Xgrid的应用程序支持大多数的选择,但更强大的功能,是由MGRID脚本(见细节部分更多的信息和安装说明)。任何其他自定义脚本可以使用的要求,提交作业和打印的Xgrid的工作ID的屏幕,在退出之前(作为唯一的数值打印),或者脚本提交作业,并创建一个“jobid.txt 文件在工作目录中包含的作业ID。 ,如果xgrid.method是separatejobs,则该参数可能是长度等于链的数量,在这种情况下,每个作业提交使用不同的应用程序/脚本。带空格的路径必须用引号时,该命令传递给shell(这可能意味着转义引号,如果必要的话)。默认情况下使用MGRID如果已安装,否则“的Xgrid的工作。


参数:sub.options
one or more option flags to be passed through to the submission application (as a character string).  Examples include ART scripts, email on job completion, and when using the mgrid script many other possibilities (see the details section).  When providing links to files as part of the command, all links must be absolute (ie start with / or ~) as xgrid/mgrid will be will not be called in the working directory, and paths with spaces must be quoted.  If xgrid.method is 'separatejobs' then the argument may be of length equal to the number of chains, in which case each job receives a different set of options.  Some options require the Xgrid controller to be running OS X Leopard (10.5) or later.  Default none.
通过一个或多个选项标志提交应用程序(如字符串)。例子包括ART脚本,电子邮件作业完成,当使用MGRID脚本许多其他的可能性(见细节部分)。提供链接的文件作为命令的一部分时,所有的链接必须是绝对的(即开始与/或~)Xgrid的/ MGRID将不会被调用的工作目录,并带有空格的路径必须用引号。 ,如果xgrid.method是separatejobs,则该参数可能是长度等于链的数量,在这种情况下,每个作业接收一组不同的选项。有些选项需要Xgrid控制器执行OS X Leopard(10.5)或更高版本。默认没有。


参数:sub.command
the actual command to be executed using system() to submit the job.  Changing this results in sub.app and sub.options being ignored, and is probably the best option to use for custom submission scripts (see the sub.app argument for the requirements for custom scripts).  The environmental variables $cmd (the name of the BASH script to be run), $ntasks (the number of tasks), $job (the job number for multiple jobs), and $indir (the input directory) will be available to the script.  For multiple tasks, the custom script should ensure that the task number is supplied as the (only) argument to the BASH script (requires xgrid.method="separatetasks" to function).  If xgrid.method is 'separatejobs' then the argument may be of length equal to the number of chains, in which case each job receives a different command.  Paths with spaces in them must be quoted when the command is passed to the shell (this may mean escaping quotes if necessary).  Default uses the values of sub.app and sub.options.
实际要执行的命令,用system()来提交作业。改变这个结果sub.app sub.options被忽略,可能是最好的选择使用自定义提交脚本(看到的sub.app的参数的要求自定义脚本)。环境变量$(CMD运行的bash脚本的名称),$ ntasks(任务数),工作(工号为多个作业),和美元的间接输入(目录)将提供给脚本。对于多任务,应确保任务数(只)的BASH脚本的参数(需要xgrid.method的“separatetasks”功能)提供的自定义脚本。 ,如果xgrid.method是separatejobs,则该参数可能是长度等于链的数量,在这种情况下,每个作业接收一个不同的命令。带空格的路径必须用引号时,该命令传递给shell(这可能意味着转义引号,如果必要的话)。默认使用的sub.app和sub.options。


参数:...
other options to be passed to the (auto)run.jags(file) functions as if the model were being run locally.  The following options to be applied after running the simulation can be specified to xgrid.results.jags, and will be ignored for other functions:  keep.jags.files, check.conv, plots, psrf.target, normalise.mcmc, check.stochastic, silent.jags
被传递到别的选项(自动)run.jags(文件)的功能,如果该模型被本地运行。以下选项适用于运行仿真可以被指定为xgrid.results.jags后,将被忽略其他功能:keep.jags.files,check.conv,图,psrf.target,normalise.mcmc,检查。随机,silent.jags


Details

详细信息----------Details----------

These functions allow JAGS models to be run on Xgrid distributed computing clusters from within R using the same syntax as required to run the models locally.  All the functionality could be replicated by saving all necessary objects to files and using the Xgrid command line utility to submit and retrieve the job manually; these functions merely provide the convenience of not having to do this manually.  Xgrid support is only available on Mac OS X machines.  
这些功能允许JAGS机型上运行的分布式计算聚类在R Xgrid的使用相同的语法需要在本地运行模式。保存所有必要的文件和使用对象的Xgrid的命令行实用程序提交和手工检索作业的所有功能都可以被复制,这些功能只是提供了方便,不必手动执行此操作。 Xgrid的支持仅适用于Mac OS X的机器。

The xgrid controller hostname and password must be set as environmental variables. The command line version of R knows about environmental variables set in the .profile file, but unfortunately the GUI version does not and requires them to be set from within R using:
Xgrid控制器的主机名和密码,必须设置环境变量。 。profile文件中设置环境变量的命令行版本的R知道,但不幸的是,GUI版本并不需要来设置,使用在R:

Sys.setenv(XGRID_CONTROLLER_HOSTNAME="<hostname>")
Sys.setenv(XGRID_CONTROLLER_HOSTNAME =“<HOSTNAME>”)

Sys.setenv(XGRID_CONTROLLER_PASSWORD="<password>")
Sys.setenv(XGRID_CONTROLLER_PASSWORD =“<密码>”)

(These lines could be copied into your .Rprofile file for a 'set and forget' solution)
(这些行复制到。Rprofile文件“设置和忘记的解决方案)

All functions can be run using the built-in xgrid commands, however some added functionality (including multi-tasks jobs to enable the 'separatetasks' method) is provided by the 'mgrid.sh' BASH shell script which is included with the runjags package (in the 'inst/xgrid' folder for the package source or the 'xgrid' folder for the installed package). More details about this script is given at the top of the mgrid.sh file. To install (optional), see the install.mgrid function.
所有的功能都可以运行Xgrid的命令,但一些附加功能(包括多任务工作,使“separatetasks”方法)所提供的“mgrid.sh”的bash shell脚本,包括的runjags包在“安装/ XGRID”文件夹中的包的源或“XGRID”文件夹中已安装的软件包。有关此脚本的更多细节是在顶部的mgrid.sh文件中。 (可选)要安装,请参阅install.mgrid功能。


值----------Value----------

For xgrid.submit.jags and xgrid.submit.jagsfile, a list containing the jobname (which will be required by xgrid.results.jags to retrieve the job) and the job ID(s) for use with the xgrid command line facilities.  For all other functions, the results of the simulation are returned as with the respective (auto)run.jags(file) functions.
用于xgrid.submit.jags和xgrid.submit.jagsfile的,一个列表,其中包含工作名称(这将需要xgrid.results.jags检索作业)和作业ID(S)的的Xgrid的命令行设施的使用。对于所有其他功能,返回的模拟结果与各自(自动)run.jags“(文件)功能。


(作者)----------Author(s)----------


Matthew Denwood <a href="mailto:matthew.denwood@glasgow.ac.uk">matthew.denwood@glasgow.ac.uk</a>



参见----------See Also----------

run.jags, autorun.jags and run.jagsfile for more information on JAGS models.
run.jags,autorun.jags和run.jagsfile更多信息JAGS模型。

xgrid.run for functions to execute user-specified functions on Xgrid.
xgrid.run上Xgrid的函数来执行用户指定的功能。

install.mgrid to install the mgrid script.
install.mgrid安装在MGRID脚本。


实例----------Examples----------



# run a simple model on Xgrid using a single job:[运行单个作业Xgrid的使用一个简单的模型:]

## Not run: [#不运行:]

# Ensure the required environmental variables are set:[确保所需的环境变量的设置:]
Sys.setenv(XGRID_CONTROLLER_HOSTNAME="<hostname>")
Sys.setenv(XGRID_CONTROLLER_PASSWORD="<password>")

# Simulate the data[模拟数据]
X <- 1:100
Y <- rnorm(length(X), 2*X + 10, 1)

# Model in the JAGS format[模型的JAGS格式]
model <- "model {
for(i in 1 : N){
Y[i] ~ dnorm(true.y[i], precision);
true.y[i] <- (m * X[i]) + c;
}
m ~ dunif(-1000,1000);
c ~ dunif(-1000,1000);
precision ~ dexp(1);
}"

# Run the model synchronously using the 'simple' method [同步运行模型使用“简单”的方法]
# and a wait interval of 1 minute:[等待的时间间隔为1分钟:]
results <- xgrid.run.jags(xgrid.method='simple',
        wait.interval='1 min', model=model, monitor=c("m", "c",
        "precision"), data=list(N=length(X), X=X, Y=Y), n.chains=2,
        plots = FALSE)

# Analyse the results:[分析结果如下:]
results$summary


## End(Not run)[#(不执行)]


# Submit a job to xgrid and (later) retrieve the results.  Use an [将作业提交到XGRID(后下)检索结果。使用一个]
# ART script to ensure the job is only sent to nodes with JAGS installed:[ART脚本,以确保这项工作只发送与JAGS安装的节点:]

## Not run: [#不运行:]

# Ensure the required environmental variables are set:[确保所需的环境变量的设置:]
Sys.setenv(XGRID_CONTROLLER_HOSTNAME="<hostname>")
Sys.setenv(XGRID_CONTROLLER_PASSWORD="<password>")

# Create the ART script we need to ensure JAGS is installed:[创建的艺术脚本我们需要确保JAGS安装的:]
cat('#!/bin/bash[!/斌/庆典]
if [ -f /usr/local/bin/jags ]; then
echo 1
else
echo 0
fi
', file='jagsART.sh')

# Simulate the data[模拟数据]
X <- 1:100
Y <- rnorm(length(X), 2*X + 10, 1)

# Model in the JAGS format[模型的JAGS格式]
model <- "model {
for(i in 1 : N){
Y[i] ~ dnorm(true.y[i], precision);
true.y[i] <- (m * X[i]) + c;
}
m ~ dunif(-1000,1000);
c ~ dunif(-1000,1000);
precision ~ dexp(1);
}"

# Run the model asynchronously (the ART script path must [异步运行模式(ART脚本的路径必须]
# be specified as an absolute link as xgrid won't be called [被指定为一个绝对的链接将不会被调用XGRID]
# in the current working directory, and all paths must be [在当前的工作目录,所有的路径都必须]
# enclosed in quotes to preserve spaces):[包含在引号中保留空格):]
name <- xgrid.submit.jags(xgrid.method='separatejobs',
sub.options=if(!file.exists(Sys.which('mgrid'))) paste('-art
"', getwd(), '/jagsART.sh"', sep='') else paste('-a "', getwd(),
'/jagsART.sh"', sep=''), model=model, monitor=c("m", "c", "precision"),
data=list(N=length(X), X=X, Y=Y), n.chains=2, plots = FALSE,
inits=list(list(.RNG.name='base::Wichmann-Hill'),
list(.RNG.name='base::Marsaglia-Multicarry')))

# Cleanup (remove jagsART file):[清理(删除jagsART文件):]
unlink('jagsART.sh')

# Retrieve the results:[检索结果:]
results <- xgrid.results.jags(name)

## End(Not run)[#(不执行)]



# Autorun a model to convergence using separate tasks on xgrid.  [使用单独的任务XGRID自动运行模型,以收敛。]
# Ensure the tasks are sent to the 2 fastest nodes (called 'Bugati' [确保的任务被发送到最快的2节点(称为Bugati]
# and 'McLaren') in our (fictional) cluster using arguments to mgrid.[和迈凯轮车队)在我们的(虚构的)聚类使用的参数MGRID。]

## Not run: [#不运行:]

# Ensure the required environmental variables are set:[确保所需的环境变量的设置:]
Sys.setenv(XGRID_CONTROLLER_HOSTNAME="<hostname>")
Sys.setenv(XGRID_CONTROLLER_PASSWORD="<password>")

# Ensure mgrid is installed:[确保MGRID的安装:]
if(!file.exists(Sys.which('mgrid'))) install.mgrid()

# Simulate the data[模拟数据]
X <- 1:100
Y <- rnorm(length(X), 2*X + 10, 1)

# Model in the JAGS format[模型的JAGS格式]
model <- "model {
for(i in 1 : N){
Y[i] ~ dnorm(true.y[i], precision);
true.y[i] <- (m * X[i]) + c;
}
m ~ dunif(-1000,1000);
c ~ dunif(-1000,1000);
precision ~ dexp(1);
}"

# Run the model synchronously using the 'separatetasks' method and [同步运行模型使用“separatetasks”的方法,]
# a wait interval of 1 minute:[一个等待间隔1分钟:]
results <- xgrid.autorun.jags(xgrid.method='separatetasks',
        wait.interval='1 min', sub.options='-h "Bugati:McLaren"',
        model=model, monitor=c("m", "c", "precision"),
        data=list(N=length(X), X=X, Y=Y), n.chains=2,
        inits=list(list(.RNG.name='base::Wichmann-Hill'),
        list(.RNG.name='base::Marsaglia-Multicarry')), plots = FALSE)


## End(Not run)[#(不执行)]






转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2024-11-28 06:51 , Processed in 0.031698 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表