如何在R2Openbugs中获得蒙特卡洛错误?
在运行贝叶斯型号UN R2OPENBUGS时,是否有人设法获得蒙特卡洛错误?
它是在openbugs的标准输出中提供的,但是当在r2openbugs下运行时,日志文件没有MC错误。是否可以要求R2Openbugs计算MC错误?或者也许有一种手动计算的方法?请让我知道您是否听说过任何方法。谢谢你!
这是R2openbugs的标准日志输出:
$stats
mean sd val2.5pc median val97.5pc sample
beta0 1.04700 0.13250 0.8130 1.03800 1.30500 1500
beta1 -0.31440 0.18850 -0.6776 -0.31890 0.03473 1500
beta2 -0.05437 0.05369 -0.1648 -0.05408 0.04838 1500
deviance 588.70000 7.87600 575.3000 587.50000 606.90000 1500
$DIC
Dbar Dhat DIC pD
t 588.7 570.9 606.5 17.78
total 588.7 570.9 606.5 17.78
Has anyone managed to obtain a Monte Carlo error for a parameter when running bayesian model un R2OpenBugs?
It is provided in a standard output of OpenBugs, but when run under R2OpenBugs, the log file doesn't have MC error.Is there a way to ask R2OpenBugs to calculate MC error? Or maybe there is a way to calculate it manually? Please, let me know if you heard of any way to do that. Thank you!
Here is the standard log output of R2OpenBugs:
$stats
mean sd val2.5pc median val97.5pc sample
beta0 1.04700 0.13250 0.8130 1.03800 1.30500 1500
beta1 -0.31440 0.18850 -0.6776 -0.31890 0.03473 1500
beta2 -0.05437 0.05369 -0.1648 -0.05408 0.04838 1500
deviance 588.70000 7.87600 575.3000 587.50000 606.90000 1500
$DIC
Dbar Dhat DIC pD
t 588.7 570.9 606.5 17.78
total 588.7 570.9 606.5 17.78
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
计算蒙特卡洛标准误差(MCSE)的一种简单方法是将链的标准偏差除以有效数量的样品的平方根。输出中提供了标准偏差,但是当您打印模型输出时,应以N.eff(最右列)给出有效的样本量 - 或至少这是我从:
https://cran.r-project.org/web/packages/r2openbugs/vignettes/r2openbugs.pdf
我不再使用openbugs在那里表明有效样本量(这与您采样的迭代次数不同,因为它也考虑到应得的信息丢失在链中相关联)。
否则,您可以通过提取RAW MCMC链,然后使用CODA软件包(?coda ::有效化)来获取有效的样本大小来获得它,或者只需使用laplacesdemon :: McSe直接计算Monte Carlo Standard错误。有关更多信息,请参见:
https://rdrr.io/cran/cran/laplacedemon/laplacedemon/laplaceedemon/man/man/mmcse .html
请注意,有些人(包括我!)建议直接关注有效的样本量在MCSE上,作为旧的“经验法则”,MCSE应小于样品标准偏差的5%等同于说有效样本量至少应为400(1/0.05^2)。但是意见确实有所不同:)
A simple way to calculate Monte Carlo standard error (MCSE) is to divide the standard deviation of the chain by the square root of the effective number of samples. The standard deviation is provided in your output, but the effective sample size should be given as n.eff (the rightmost column) when you print the model output - or at least that is the impression I get from:
https://cran.r-project.org/web/packages/R2OpenBUGS/vignettes/R2OpenBUGS.pdf
I don't use OpenBugs any more so can't easily check for you, but there should be something there that indicates the effective sample size (this is NOT the same as the number of iterations you have sampled, as it also takes into account the loss of information due to correlation within the chains).
Otherwise you can obtain it yourself by extracting the raw MCMC chains and then either computing the effective sample size using the coda package (?coda::effectiveSize) or just use LaplacesDemon::MCSE to calculate the Monte Carlo standard error directly. For more information see:
https://rdrr.io/cran/LaplacesDemon/man/MCSE.html
Note that some people (including me!) would suggest focusing on the effective sample size directly rather than looking at the MCSE, as the old "rule of thumb" that MCSE should be less than 5% of the sample standard deviation is equivalent to saying that the effective sample size should be at least 400 (1/0.05^2). But opinions do vary :)
MCMC-ERROR被命名为“时间序列” SE,可以在CODA对象摘要的统计部分中找到:
The MCMC-error is named Time-series SE, and can be found in the statistics section of the summary of the coda object: