run.jagsfile(runjags)
run.jagsfile()所属R语言包:runjags
Read a User Specified Model in a WinBUGS Type Textfile or
在WinBUGS类类型的文本文件读取用户指定的模型或
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Runs a user specified JAGS (similar to WinBUGS) model in a WinBUGS type textfile or character variable from within R, returning a list of the MCMC chain(s) along with optional convergence diagnostics, autocorrelation diagnostics and monitored variable summaries. JAGS is called using the lower level function run.jags, and read.winbugs is used to extract model and data definitions from the specified file or string.
运行一个用户指定的模型在一个WinBUGS类类型的文本文件或字符变量从在R,返回一个列表的MCMC链(),沿与可选的收敛诊断,自相关的诊断和监视的变量摘要JAGS(类似于WinBUGS类)。 JAGS被称为使用较低级别的功能run.jags,read.winbugs从指定的文件或字符串,用于提取模型和数据定义。
用法----------Usage----------
run.jagsfile(path=stop("No path or model string supplied"),
datalist = NA, initlist = NA, n.chains=NA, data=NA,
model=NA, inits=NA, monitor=NA, call.jags=TRUE,
autorun=FALSE, ...)
参数----------Arguments----------
参数:path
either a relative or absolute path to a textfile (including the file extension) containing a model in the JAGS language and possibly monitored variable names, data and/or initial values, or a character string of the same. May also be a vector of paths to different text files, possibly separately containing the model, data and intitial values. No default. The model must be started with the string 'model{' and ended with '}' on new lines. Data must be similarly started with 'data{', monitored variables with 'monitor{', and initial values as 'inits{', and all ended with '}'. If multiple models are found, all but the first one are ignored with a warning. Multiple data blocks and monitor blocks are combined, multiple inits blocks are used for different chains. The model block may also contain automatically generated data and initial values variables using '#data# variable' and '#inits# variable', and more monitored variables using '#monitor# variable'. See read.winbugs for more information.
无论是相对或绝对路径到一个文本文件(包括文件扩展名)包含模型在JAGS语言,并可能监视的变量名,数据和/或初始值,或相同的字符串。也可以是不同的文本文件,可能分别包含的模型,数据和intitial值的矢量路径。无默认值。该模型必须以字符串模型{“,结束了”}“上新的生产线开始。数据,必须将同样的数据{开始,被监视的变量与“监视器{”,和初始值初始化设置{和}结束。如果有多个型号被发现,被忽略,但第一个警告。多个数据块和监视器块相结合,多个初始化设置的块被用于不同的链。的模型块可能还包含自动生成的数据和初始值的变量,使用#数据#变量“和”##初始化设置变量,和更多的被监视的变量使用#监控#变量。见read.winbugs更多信息。
参数:datalist
an optional named list containing variables used as data, or alternatively a function (with no arguments) that returns a named list. If any variables are specified in the model block using '#data# variable', the value for the corresponding named variable is taken from datalist if present (or the result of datalist() if specified as a function which is useful for specifying randomly generated data), or the parent environment, or finally the global environment if not found anywhere else. Ignored if '#data# variable' is not used in the model block. Default NA.
一个可选的列表,其中包含的数据,或者一个函数(不带参数),返回一个已命名的列表中使用的变量。如果任何变量中指定的模型中的块使用#数据#变量,为相应的命名的变量的值是取自的DataList如果存在(或结果的DataList(),如果指定为一个函数,它是有用的,用于特别指定随机生成数据),或父环境,最后是全球性的环境中,如果每个人都能找到。忽略,如果#数据#变量中不使用的模型块。默认情况下不适用。
参数:initlist
an optional named list containing variables used as initial values, or alternatively a function (with a single argument representing the chain number) that returns a named list. If any variables are specified in the model block using '#inits# variable', the value for the corresponding named variable is taken from initlist if present (or the result of datalist(chain.no) if specified as a function which allows both randomly generated initial values and different values for each chain), or the parent environment, or finally the global environment if not found anywhere else. Ignored if '#inits# variable' is not used in the model block. Note: different chains are all given the same starting values if specified as a named list or taken from any envirnoment; if different values are desired for each chain initlist should be specified as a function. Default NA.
一个可选的列表,其中包含变量作为初始值,或者返回一个函数(一个参数代表的链数),命名列表。如果任何变量中指定的模型块使用##初始化设置变量,如果存在(或DataList中(chain.no)的的结果,如果作为一个函数指定,同时允许随机相应命名的变量的值是取自initlist生成的初始值和链的每个不同的值),或父环境,最后是全球性的环境中,如果每个人都能找到。如果#初始化设置#变量没有用于模型中的块,忽略。注:不同的链都在同一起跑线值,如果命名列表或指定为从任何envirnoment;如果需要不同的值应被指定为每个链initlist的功能。默认情况下不适用。
参数:n.chains
the number of chains to use with the simulation. More chains will improve the sensitivity of the convergence diagnostic, but will cause the simulation to run more slowly. If NA, the number of chains will be taken from the number of inits blocks in the model file. If NA and no inits blocks are found, 2 chains are used with a warning. Default NA.
链的数目,使用与模拟。更多的链将改善的收敛诊断的灵敏度,但将导致仿真运行更慢。如果不适用,链的数量将取自初始化设置在模型文件中块的数量。如果被发现,NA和没有初始化设置块2链的一个警告。默认情况下不适用。
参数:data
OPTIONAL character vector in the R dump format (or named list) containing the data. If supplied (!=NA), all data in the model file is ignored. Default NA.
可选字符在R转储文件格式的矢量(或称列表)包含的数据。如果供应量(= NA),模型文件中的所有数据将被忽略。默认情况下不适用。
参数:model
OPTIONAL model in JAGS syntax. If supplied (!=NA), the model in the model file is ignored. Default NA.
可选型号JAGS语法。如果供应量(= NA),该模型在模型文件中被忽略。默认情况下不适用。
参数:inits
OPTIONAL character vector(s) in the R dump format containing the initial value(s). If supplied (!=NA), all inits in the model file are ignored. Default NA.
在R转储文件格式的可选字符矢量(S)包含初始值(S)。如果供应量(= NA),在模型文件中的所有初始化设置将被忽略。默认情况下不适用。
参数:monitor
OPTIONAL character vector containing the monitored variables. If supplied (!=NA), all monitor statements in the model block are ignored. Default NA.
可选字符向量被监视的变量。如果供应量(= NA),所有监测报表模型中的块将被忽略。默认情况下不适用。
参数:call.jags
option results in either simulation being called if TRUE, or returns a named list of the data, model, initial values, monitored variables and number of chains (which can be supplied to run.jags) if FALSE.
被称为在任一模拟的选项结果如果为TRUE,否则返回一个命名列表的数据,模型,初始值,被监视的变量和链数(可以供给到run.jags的)如果为FALSE。
参数:autorun
option to call autorun.jags rather than run.jags for the simulation, which allows automatic calculation of the necessary run length and convergence diagnostics. If TRUE, burnin, sample and check.conv are ignored. See also autorun.jagsfile for a wrapper for this function. Default FALSE.
选项来调用autorun.jags,而不是run.jags的模拟,它允许必要的运行长度,并自动计算的收敛诊断。如果是TRUE,燃尽的,样品和check.conv的的将被忽略。 autorun.jagsfile此功能的包装。默认为false。
参数:...
other options to be passed directly to run.jags (see run.jags) or autorun.jags (see autorun.jags).
其他选项直接传递到run.jags(见run.jags$)或autorun.jags(见autorun.jags“)。
值----------Value----------
The output of run.jags (or autorun.jags if autorun==TRUE). See the help file run.jags or autorun.jags for more information.
的输出run.jags(或autorun.jags的自动运行== TRUE)。请参阅帮助文件run.jags或autorun.jags的详细信息。
(作者)----------Author(s)----------
Matthew Denwood <a href="mailto:matthew.denwood@glasgow.ac.uk">matthew.denwood@glasgow.ac.uk</a>
参见----------See Also----------
autorun.jagsfile,
autorun.jagsfile,
run.jags,
run.jags,
autorun.jags,
autorun.jags,
read.winbugs
read.winbugs
实例----------Examples----------
# run a model to calculate the intercept and slope of the expression [运行模型计算的截距和斜率的表达]
# y = m x + c, assuming normal observation errors for y:[为y = mx + C,假设正常观测误差为y:]
## Not run: [#不运行:]
# Model in the JAGS format[模型的JAGS格式]
# Model in the JAGS format[模型的JAGS格式]
model <- "model {
for(i in 1 : N){ #data# N[数据#N]
Y[i] ~ dnorm(true.y[i], precision); #data# Y[数据#Y]
true.y[i] <- (m * X[i]) + c; #data# X[数据#X]
}
m ~ dunif(-1000,1000); #inits# m[初始化设置#M]
c ~ dunif(-1000,1000);
precision ~ dexp(1);
#monitor# m, c, precision[监控#M,C,精度]
}"
# Simulate the data[模拟数据]
X <- 1:100
Y <- rnorm(length(X), 2*X + 10, 1)
N <- length(X)
initfunction <- function(chain) return(switch(chain,
"1"=list(m=-10), "2"=list(m=10)))
results <- run.jagsfile(model, n.chains=2, initlist=initfunction)
# Analyse the results[分析结果]
results$summary
## End(Not run)[#(不执行)]
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|