read.winbugs(runjags)
read.winbugs()所属R语言包:runjags
Extract Any Models, Data, Monitored Variables or Initial Values
提取任何模型,数据,监视的变量或初始值
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Read a user specified WinBUGS type textfile or character variable and extract any models, data, monitored variables or initial values as character vectors. Used by (auto)run.jagsfile to interpret the input file(s) or strings.
阅读用户指定的WinBUGS类型的文本文件或字符变量和提取任何模型,数据,监视的变量或初始值的特征向量。由(自动)run.jagsfile的解释输入文件(或字符串)。
用法----------Usage----------
read.winbugs(path)
参数----------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 '}'. Seperate variables in such blocks must be separated by a line break. 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. Monitors may also be given using the phrase '#monitor# variable' within the model block, in which case 'variable' is added to the list of monitored variables found in the monitor block(s). The use of automatically generated data and initial values is also supported using similar syntax, with '#data# variable' for automatically generated data variables or '#inits# variable' for automatically generated initial value variables in which case 'variable' is used as data or initial values with a value taken by run.jagsfile from datalist, initlist or R objects as appropriate. '#inits#', '#data#' and '#monitor#' statements can appear on the same line as model code, but no more than one of these statements should be used on the same line. Examples of acceptable model syntax is given below.
无论是相对或绝对路径到一个文本文件(包括文件扩展名)包含模型在JAGS语言,并可能监视的变量名,数据和/或初始值,或相同的字符串。也可以是不同的文本文件,可能分别包含的模型,数据和intitial值的矢量路径。无默认值。该模型必须以字符串模型{“,结束了”}“上新的生产线开始。数据,必须将同样的数据{开始,被监视的变量与“监视器{”,和初始值初始化设置{和}结束。在这样的块,必须由换行符分隔的独立变量。如果有多个型号被发现,被忽略,但第一个警告。多个数据块和监视器块相结合,多个初始化设置的块被用于不同的链。显示器也可以被给予使用的短语“##监测变量模型内的块,在这种情况下”可变“被添加到监视器块(s)中发现被监视的变量的列表。使用自动生成的数据和初始值也使用类似的语法,以“##变量的数据自动生成的数据变量或#初始化设置#变量自动生成的初始值,其中的变量的情况下变量被用作支持数据采取run.jagsfile从DataList的initlist或R对象适当的值或初始值。 “#初始化设置#”,“#数据#”和“#显示器#语句可以出现在同一行上为型号代码,但不超过一个,应使用这些语句在同一行上。可接受的模型的语法的例子在下面给出。
值----------Value----------
A named list of 'model' containing the model description, 'data' containing the data given in the data block(s), 'autodata' containing data variables specified using '#data#' in the model block, 'inits' containing the initial values given in the initial value block(s), 'autoinits' containing initial value variables specified using '#inits#' in the model block, and 'monitor' containing the monitored variables specified in the monitor blocks and by using '#monitor#' within the model block. This function is specified primarily for WinBugs compatibility, so data blocks would normally contain the data in a list format rather than the code format that is allowed in JAGS to perform data transformations (see JAGS manual section 7.0.5). These JAGS format data blocks can be specified, and the function will attempt to differentiate the two types of data from the presence of syntactical cues such as square brackets, for loops, 'list' and .Dim structural assignments. If none of these are found, the data block is assumed to be a WinBugs type data block and is passed to JAGS as data. This behaviour can be over-ridden by inserting '#jagsdata#' or '#bugsdata#' into the data block as appropriate. More than one data block is allowed, and each will be differentiated independently.
命名列表包含该模型描述的“模型”,“数据”包含的数据块(s)提供的数据,“数据研究机构Autodata的数据变量指定使用”#数据#在模型块,“初始化设置”包含中给出的初始值块(s),autoinits包含使用指定的初始值变量#初始化设置#模型中的块中,和含有被监视的变量中指定的监视器块的“显示器”的初始值,通过使用#监测#在模型块。此功能被指定为主要用于WinBUGS类的相容性,所以通常会包含数据块的数据列表中的格式,而不是允许JAGS的代码格式来执行数据转换(参见JAGS手册第7.0.5)。可以指定这些JAGS格式的数据块,将尝试区分这两种类型的数据的语法线索,如方括号的存在,循环,名单功能。昏暗的结构分配。如果没有这些被发现的,该数据块被假设为是WinBugs的类型的数据块,并作为数据被传递给JAGS。这种行为可以覆盖插入“#jagsdata#或的”#bugsdata#到适当的数据块。一个以上的数据块被允许的,并且每个独立加以区分。
(作者)----------Author(s)----------
Matthew Denwood <a href="mailto:matthew.denwood@glasgow.ac.uk">matthew.denwood@glasgow.ac.uk</a>
参见----------See Also----------
run.jagsfile
run.jagsfile
实例----------Examples----------
## Not run: [#不运行:]
# ALL SYNTAX GIVEN BELOW IS EQUIVALENT[下面给出的是等效的所有语法]
# Use a modified WinBUGS text file with manual inits and manual data and[使用修改过的WinBUGS手动初始化设置和手动数据和文本文件,]
# a seperate monitor block (requires least modification from a WinBUGS[一个单独的显示器模块(需要至少修改一个WinBUGS]
# file). For compatibility with WinBUGS, the use of list() to enclose[文件)。对于WinBUGS的兼容性,使用列表()以包围]
# data and initial values is allowed and ignored, however all seperate[数据和初始值是允许的,忽略不计,然而,所有独立的]
# variables in the data and inits blocks must be seperated with a line[的数据中的变量和初始化设置块必须用线分隔]
# break (commas or semicolons before linebreaks are ignored). 'data{'[打破(逗号或分号之前的换行符将被忽略)。数据{]
# and 'inits{' must also be added to WinBUGS textfiles so that the[和初始化设置{也必须被添加WinBUGS的文本文件,所以]
# function can seperate data from initial values. Iterative loops are[功能可以来自初始值的数据分开。迭代循环]
# allowed in data blocks but not in init blocks. See also the differences[允许在数据块中,但不是在init块。也参看差异]
# in JAGS versus WinBUGS syntax in the JAGS help file.[,在JAGS对WinBUGS在JAGS帮助文件的语法。]
# Contents of a textfile 'mymodel.bug':[的内容文本文件的mymodel.bug“:]
model{
for(i in 1:N){
Count[i] ~ dpois(mean)
}
mean ~ dgamma(0.01, 100)
}
data{
list(Count <- c(1,2,3,4,5,6,7,8,9,10),
N <- 10)
}
inits{
list(
mean <- 1)
}
inits{
list(
mean <- 100)
}
monitor{
mean
}
# end text file[最终文本文件]
read.winbugs('pathtofile/mymodel.bug')
# Use internal character variable, define monitors in the model, [使用内部的字符变量,在模型中定义显示器,]
# use autodata and manual initial values:[使用数据研究机构Autodata和手动初始值的:]
string <- "
model{
for(i in 1:N){
Count[i] ~ dpois(mean) #data# Count, N[数据#计数,N]
}
mean ~ dgamma(0.01, 100)
#monitor# mean[监控#的意思]
}
inits{
mean <- 1
}
inits{
mean <- 100
}
"
read.winbugs(string)
# Use autoinits and a mixture of manual and autodata:[使用autoinits手册和数据研究机构Autodata的混合物:]
string <- "
model{
for(i in 1:N){
Count[i] ~ dpois(mean) #data# Count[数据#计数]
}
mean ~ dgamma(0.01, 100)
#monitor# mean[监控#的意思]
#inits# mean[初始化设置#的意思]
}
data{
N <- 10
}
"
read.winbugs(string)
## End(Not run)[#(不执行)]
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|