# OpenBUGS

**OpenBUGS** 是一款开源软件包，用于借助马尔可夫链蒙特卡洛（MCMC）技术对复杂统计模型进行贝叶斯分析。模型以声明式的 BUGS 语言描述，或以 Doodles 图形方式呈现——后者可转换为基于文本的描述——随后程序从模型参数的后验分布中抽样。<sup>[1](https://chjackson.github.io/openbugsdoc/Manuals/Introduction.html)</sup> 它是 BUGS 系列软件中首个开源版本，该系列始于 ClassicBUGS，历经 WinBUGS 延续而来。<sup>[2](https://www.annualreviews.org/content/journals/10.1146/annurev-statistics-122121-040905?crawler=true&mimetype=application%2Fpdf)</sup>

| 关键事实 | 详情 |
|---|---|
| 用途 | 通过 MCMC 抽样对复杂统计模型进行贝叶斯分析<sup>[1](https://chjackson.github.io/openbugsdoc/Manuals/Introduction.html)</sup> |
| 模型设定 | BUGS 语言文本，或可转换为文本的 Doodles 图形模型<sup>[1](https://chjackson.github.io/openbugsdoc/Manuals/Introduction.html)</sup> |
| 起源 | 始于 2004 年，首席开发者安德鲁·托马斯（Andrew Thomas）迁至赫尔辛基（Helsinki）之时；是首个开源的 BUGS，依据 GNU 通用公共许可证第 2 版发布<sup>[2](https://www.annualreviews.org/content/journals/10.1146/annurev-statistics-122121-040905?crawler=true&mimetype=application%2Fpdf)</sup> |
| 平台 | Windows 上配有图形界面；Linux 上通过命令行界面使用；R 语言可通过 BRugs 包访问<sup>[2](https://www.annualreviews.org/content/journals/10.1146/annurev-statistics-122121-040905?crawler=true&mimetype=application%2Fpdf)</sup> |
| 最终版本 | 版本 3.2.3，记录于一套已归档的手册中<sup>[2](https://www.annualreviews.org/content/journals/10.1146/annurev-statistics-122121-040905?crawler=true&mimetype=application%2Fpdf)</sup><sup> • </sup><sup>[3](https://chjackson.github.io/openbugsdoc/)</sup> |
| 实现语言 | 源码以 Blackbox Component Pascal 编写（.odc 文件）；Linux 共享库在 Windows 上编译并链接<sup>[4](https://github.com/jsta/openbugs)</sup> |
| 并行后继者 | MultiBUGS 复用 OpenBUGS 算法并并行化 MCMC，将一个含 425,112 个观测的层次模型的计算耗时从 32 小时缩短至在 48 核上的 28 分钟<sup>[5](https://www.multibugs.org/)</sup> |

## 历史及与 WinBUGS 的关系

自 1989 年以来，BUGS 项目历经三个主要版本：ClassicBUGS，然后是 WinBUGS，再到开源的 OpenBUGS。<sup>[6](https://pmc.ncbi.nlm.nih.gov/articles/PMC7116196/)</sup> OpenBUGS 与 WinBUGS 是在一种刻意的角色分工下并行开发的：WinBUGS 作为稳定发布版本，而 OpenBUGS 则充当实验性开发版本，不同发布版本之间可能存在不兼容的改动。从版本 3.0.7 起，OpenBUGS 被认为已足够稳定，可作为 WinBUGS 的可靠替代品，而版本 3.2.3 则是最终发布版。<sup>[2](https://www.annualreviews.org/content/journals/10.1146/annurev-statistics-122121-040905?crawler=true&mimetype=application%2Fpdf)</sup>

该项目的方法由其开发者本人在 2009 年《Statistics in Medicine》的一篇论文中作了描述，题为《BUGS 项目：演进、评述与未来方向》（The BUGS project: Evolution, critique and future directions），作者为大卫·伦恩（David Lunn）、大卫·斯皮格霍尔特（David Spiegelhalter）、安德鲁·托马斯（Andrew Thomas）和妮基·贝斯特（Nicky Best），作者当时所属机构包括 MRC 生物统计单位（MRC Biostatistics Unit）、圣安德鲁斯大学（University of St Andrews）及圣玛丽医院（St Mary's Hospital）。<sup>[7](https://bibbase.org/network/publication/lunn-spiegelhalter-thomas-best-thebugsprojectevolutioncritiqueandfuturedirectionswithdiscussion-2009)</sup>

## 模型的设定与抽样方式

用户以 BUGS 语言将模型写为一组关系式，提供数据和初始值，然后编译模型。随后 OpenBUGS 为模型有向无环图的每个节点选择一种更新（采样）算法，可按“按方法”顺序或按节点名称排序，取决于编译选项；可用的采样算法列于“更新器选项”（Updater Options）对话框中，节点或节点块的算法可在编译后更改。<sup>[8](https://chjackson.github.io/openbugsdoc/Manuals/ModelMenu.html)</sup>

自适应调优内置于非共轭采样器中：Metropolis 算法和切片采样算法分别具有 4000 次和 500 次迭代的自适应阶段，这些迭代会从所有统计量中剔除。<sup>[8](https://chjackson.github.io/openbugsdoc/Manuals/ModelMenu.html)</sup> 当运行多条链时，每个周期为每条链生成一次更新，随机数取自同一个共享序列。<sup>[8](https://chjackson.github.io/openbugsdoc/Manuals/ModelMenu.html)</sup>

该软件试图针对模型设定、数据、初始值或采样算法中的问题给出有信息量的错误消息，并在采样器出现数值问题时生成详细的异常诊断窗口。在极少数情况下，它无法为某个节点找到合适的采样算法，此时会报告“无法为节点 x 选择更新方法”（Unable to choose update method for node x）。<sup>[9](https://chjackson.github.io/openbugsdoc/Manuals/TipsTroubleshooting.html)</sup>

## 扩展与接口

**GeoBUGS** 是一个附加模块，提供接口用于生成疾病制图及其他空间模型输出的地图，并用于创建和操作 OpenBUGS 中可用的条件自回归（car.normal、car.l1、mv.car）空间平滑分布所需的邻接矩阵。它附带的地图文件涵盖苏格兰各区、大不列颠各郡、法国各省及希腊各州等区域，并可导入 Splus、ArcInfo、Epimap 以及（经由转换程序）ArcView 格式的多边形数据。<sup>[10](https://chjackson.github.io/openbugsdoc/GeoBUGS/Manuals/Manual.html)</sup>

在 Linux 上，OpenBUGS 通过标准的 configure、make 和 make install 步骤从源码安装，并提供命令行程序和共享库（libOpenBUGS.so）。R 包 BRugs 提供了编程接口。<sup>[2](https://www.annualreviews.org/content/journals/10.1146/annurev-statistics-122121-040905?crawler=true&mimetype=application%2Fpdf)</sup><sup> • </sup><sup>[4](https://github.com/jsta/openbugs)</sup>

## 性能及与其他软件的比较

OpenBUGS 属于 BUGS 语言工具家族，该家族还包括 JAGS——后者拥有完全独立的代码库，但追求相似的功能。<sup>[2](https://www.annualreviews.org/content/journals/10.1146/annurev-statistics-122121-040905?crawler=true&mimetype=application%2Fpdf)</sup> 关于网络荟萃分析软件的比较研究将 OpenBUGS 列为 WinBUGS 的候选替代品之一，与 JAGS、GeMTC、LaplacesDemon、Mamba、PyMC、SAS PROC MCMC、MCMCpack 和 Stan 并列。<sup>[11](https://www.valueinhealthjournal.com/article/S1098-3015%2815%2904806-8/fulltext)</sup>

在一项多水平建模基准测试中，OpenBUGS 和 WinBUGS 产生的后验估计几乎相同（例如，两者的 Beta0 估计值均为 −0.790，标准误约为 0.17），但 OpenBUGS 对大多数参数产生了大得多的有效样本量，Beta0 为 2595 对 396，且实际耗时更少，为 313 秒对 391 秒。<sup>[12](https://www.bristol.ac.uk/cmm/media/migrated/1-0-1/manual-tree-beginners.pdf)</sup> 一篇关于群体药物计量学模型的综述报告称，在所比较的工具中，OpenBUGS 和 Stan 在单位执行时间的有效样本量方面表现更优。<sup>[13](https://www.page-meeting.org/wp-content/uploads/pdf_abstracts/5486-PAOLOMAGNI_ELISA_BORELLA70X100.pdf)</sup> 诸如 BUGS 软件中所用的吉布斯式采样器，在后验相关性较低的共轭模型上仍可与 Stan 竞争，因为此时吉布斯采样快速而高效。<sup>[14](https://journals.sagepub.com/doi/10.3102/1076998615606113)</sup>

## 后继者：MultiBUGS

由于 OpenBUGS 不使用多核硬件，拟合极大型模型通常极其耗时。<sup>[6](https://pmc.ncbi.nlm.nih.gov/articles/PMC7116196/)</sup> MultiBUGS 是 BUGS 的当前版本，专为多核计算而设计：它将 OpenBUGS 模块链接成一个计算引擎，在多个核心上通过 MPI 协议通信运行，并自动并行化独立的 MCMC 链及链内计算，拆分乘积形式的似然计算并对条件独立的参数进行采样。<sup>[2](https://www.annualreviews.org/content/journals/10.1146/annurev-statistics-122121-040905?crawler=true&mimetype=application%2Fpdf)</sup><sup> • </sup><sup>[6](https://pmc.ncbi.nlm.nih.gov/articles/PMC7116196/)</sup> 对于一个含 425,112 个观测和 20,426 个随机效应的层次回归模型，OpenBUGS 耗时 32 小时，而 MultiBUGS 在 48 核上仅需 28 分钟。<sup>[5](https://www.multibugs.org/)</sup><sup> • </sup><sup>[15](https://www.annualreviews.org/docserver/fulltext/statistics/10/1/annurev-statistics-122121-040905.pdf?accname=guest&checksum=50FAFB9374DB0FEBEF8D01D0B89BE9D6&expires=1776295468&id=id)</sup> 链的混合性质与 OpenBUGS 相同，因为使用的是相同的底层采样算法，因此严重的混合问题不会因并行化而解决，不过更长的运行变得可行。<sup>[6](https://pmc.ncbi.nlm.nih.gov/articles/PMC7116196/)</sup>

## References

1. [OpenBUGS User Manual: Introduction](https://chjackson.github.io/openbugsdoc/Manuals/Introduction.html)
2. [Simulation-Based Bayesian Analysis, Annual Review of Statistics and Its Application](https://www.annualreviews.org/content/journals/10.1146/annurev-statistics-122121-040905?crawler=true&mimetype=application%2Fpdf)
3. [OpenBUGS 3.2.3 documentation archive](https://chjackson.github.io/openbugsdoc/)
4. [jsta/openbugs: Source code mirror for OpenBUGS, GitHub](https://github.com/jsta/openbugs)
5. [MultiBUGS: A parallel implementation of the BUGS modelling framework](https://www.multibugs.org/)
6. [Goudie, Turner, De Angelis, Thomas (2020). MultiBUGS: A Parallel Implementation of the BUGS Modelling Framework for Faster Bayesian Inference. Journal of Statistical Software 95(7).](https://pmc.ncbi.nlm.nih.gov/articles/PMC7116196/)
7. [Lunn, Spiegelhalter, Thomas, Best (2009). The BUGS Project: Evolution, Critique and Future Directions. Statistics in Medicine 28:3049–3082.](https://bibbase.org/network/publication/lunn-spiegelhalter-thomas-best-thebugsprojectevolutioncritiqueandfuturedirectionswithdiscussion-2009)
8. [OpenBUGS User Manual: Model Menu](https://chjackson.github.io/openbugsdoc/Manuals/ModelMenu.html)
9. [OpenBUGS User Manual: Tips and Troubleshooting](https://chjackson.github.io/openbugsdoc/Manuals/TipsTroubleshooting.html)
10. [GeoBUGS User Manual, version 3.2.3](https://chjackson.github.io/openbugsdoc/GeoBUGS/Manuals/Manual.html)
11. [Alternatives To WinBUGS for Network Meta-Analysis, Value in Health](https://www.valueinhealthjournal.com/article/S1098-3015%2815%2904806-8/fulltext)
12. [A Beginner's Guide to Bayesian analysis in multilevel models, University of Bristol](https://www.bristol.ac.uk/cmm/media/migrated/1-0-1/manual-tree-beginners.pdf)
13. [Evaluation of software tools for Bayesian estimation on population models with count and continuous data, PAGE meeting](https://www.page-meeting.org/wp-content/uploads/pdf_abstracts/5486-PAOLOMAGNI_ELISA_BORELLA70X100.pdf)
14. [Gelman, Lee, Guo (2015). Stan. Journal of Educational and Behavioral Statistics](https://journals.sagepub.com/doi/10.3102/1076998615606113)
15. [Annual Review of Statistics and Its Application, full-text PDF](https://www.annualreviews.org/docserver/fulltext/statistics/10/1/annurev-statistics-122121-040905.pdf?accname=guest&checksum=50FAFB9374DB0FEBEF8D01D0B89BE9D6&expires=1776295468&id=id)

---
*Initially written Sep 17, 2026 · Reviewed: Oct 15, 2026 · Edited: Oct 11, 2026; Oct 15, 2026; Oct 25, 2026 · Last review: Oct 15, 2026*

Topic: 物质世界与数学 › 数学与统计学 › 统计学与概率论 › Bayesian statistics › Bayesian computation and software › Bayesian software › MCMC sampling libraries and engines

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/openbugs

English original: https://www.edgepedia.org/openbugs
