combine.mcmc(runjags)
combine.mcmc()所属R语言包:runjags
Combine Two or More MCMC Objects With the Same Number of Chains Into One Longer MCMC Object
将MCMC对象使用两个或两个以上相同数量的链进入一个较长的MCMC对象中
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Allows an MCMC object (with 1 or more chains) to be combined with another (or several other) MCMC object(s) representing extensions of the same simulation, to produce one MCMC object that contains the continuous combined Markov chains of the other MCMC objects. Also provides a safe way to thin a single MCMC object or list.
允许一个的MCMC对象(有1个以上连锁)结合(或几个)的MCMC对象(S)代表相同的模拟扩展,产生一个的MCMC对象,包含连续合并的其他MCMC对象的马尔可夫链。此外,还提供了一个安全的方式,薄薄的一单MCMC对象或列表。
用法----------Usage----------
combine.mcmc(mcmc.objects=list(), thin=1, return.samples=NA,
collapse.chains=if(length(mcmc.objects)==1) TRUE else FALSE)
参数----------Arguments----------
参数:mcmc.objects
a list of MCMC objects, all with the same number of chains, or a single MCMC object or list. No default.
MCMC中的对象的列表,与相同数量的链,或一个单一的MCMC对象或列表。无默认值。
参数:thin
an integer to use to thin the (final) MCMC object by, in addition to any thinning already applied to the objects before being passed to combine.mcmc. Ignored if return.samples is specified (!is.na). Default 1 (no additional thinning is performed).
一个整数,使用薄的(最终)的MCMC对象的,在任何变薄已经应用到的对象被传递给combine.mcmc之前。如果忽略return.samples指定(is.na)。缺省值1(没有额外的细化执行)。
参数:return.samples
the number of samples to return after thinning. The chains will be thinned to as close to this minimum value as possible, and any excess iterations discarded. Supersedes thin if both are specified. Ignored if niter(mcmc.objects) < return.samples. Default NA.
的样本数,返回后变薄。链将被减薄到尽可能靠近该最小值,和任何多余的迭代丢弃。取代薄,如果两者都指定。如果的硝石(mcmc.objects)<return.samples忽略。默认情况下不适用。
参数:collapse.chains
option to combine all MCMC chains into a single MCMC chain with more iterations. Can be used for combining chains prior to calculating results in order to reduce the Monte Carlo error of estimates. Default TRUE if a single mcmc.object is provided, or FALSE otherwise.
选项将所有MCMC链成一个单一的MCMC链的迭代次数越多。可用于结合链计算结果之前,以减少的蒙特卡洛误差估计。如果单mcmc.object默认为true,否则返回FALSE。
值----------Value----------
A single MCMC object of length equal to the sum of the lengths of the input MCMC objects (if thin=1)
一个单一的MCMC对象输入MCMC对象的长度的总和的长度等于(薄的话= 1)
(作者)----------Author(s)----------
Matthew Denwood <a href="mailto:matthew.denwood@glasgow.ac.uk">matthew.denwood@glasgow.ac.uk</a>
参见----------See Also----------
run.jags,
run.jags,
testjags
testjags
实例----------Examples----------
# run a model, then extend the simulation and combine the two MCMC [运行模型,然后再扩展的模拟,并结合两个MCMC]
# objects, with thinning to 5000 samples.[对象,细化到5000个样本。]
## Not run: [#不运行:]
# 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);
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)
results1 <- run.jagsfile(model, n.chains=2, burnin=5000, sample=10000)
results2 <- run.jagsfile(model, inits=results1$end.state, burnin=0,
sample=10000)
results <- combine.mcmc(list(results1$mcmc, results2$mcmc),
return.samples=5000)
# Analyse the results[分析结果]
summary(results)
## End(Not run)[#(不执行)]
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|