WinBUGS User Manual
Version 2.10, April 2005
David Spiegelhalter
1
Andrew Thomas
2
Nicky Best
3
Dave Lunn
3
1
MRC Biostatistics Unit,
Institute of Public Health,
Robinson Way,
Cambridge CB2 2SR, UK
2
Dept of Mathematics & Statistics,
University of Helsinki
Helsinki
Finland
3
Department of Epidemiology & Public Health,
Imperial College School of Medicine,
Norfolk Place,
London W2 1PG, UK
e-mail:
bugs@mrc-bsu.cam.ac.uk [general]
ant@rni.helsinki.fi [technical]
internet: http://www.mrc-bsu.cam.ac.uk/bugs
This manual describes how to use the WinBUGS software.
Permission and Disclaimer
please click here to read the legal bit
More informally, potential users are reminded to be extremely careful if using this program for serious statistical analysis. We have tested the program on quite a wide set of examples, but be particularly careful with types of model that are currently not featured. If there is a problem,
WinBUGS
might just crash, which is not very good, but it might well carry on and produce answers that are wrong, which is even worse. Please let us know of any successes or failures.
Beware: MCMC sampling can be dangerous!
Contents
Introduction
Introduction to WinBUGS
Advice for new users
MCMC methods
How
WinBUGS
syntax differs from that of
ClassicBUGS
Changes from WinBUGS 1.3
Compound Documents
What is a compound document?
Working with compound documents
Editing compound documents
Compound documents and e-mail
Printing compound documents and Doodles
Reading in text files
Model Specification Language
Graphical models
Graphs as a formal language
The BUGS language: stochastic nodes
Censoring and truncation
Constraints on using certain distributions
Logical nodes
Arrays and indexing
Repeated structures
Data transformations
Nested indexing and mixtures
Formatting of data
DoodleBUGS: The Doodle Editor
General properties
Creating a node
Selecting a node
Deleting a node
Moving a node
Creating a plate
Selecting a plate
Deleting a plate
Moving a plate
Resizing a plate
Creating an edge
Deleting an edge
Moving a Doodle
Resizing a Doodle
Printing a Doodle
The Model Menu
General properties
Specification...
Update...
Monitor Metropolis
Save State
Seed...
Script
The Inference Menu
General properties
Samples...
Compare...
Correlations...
Summary...
Rank...
DIC...
The Info Menu
General properties
Open Log
Clear Log
Node info...
Components
The Options Menu
Output options...
Update options...
Batch-mode: Scripts
Tricks: Advanced Use of the BUGS Language
Specifying a new sampling distribution
Specifying a new prior distribution
Specifying a discrete prior on a set of values
Using pD and DIC
Mixtures of models of different complexity
Where the size of a set is a random quantity
Assessing sensitivity to prior assumptions
Modelling unknown denominators
Handling unbalanced datasets
Use of the "cut" function
WinBUGS Graphics
General properties
Margins
Axis Bounds
Titles
All Plots
Fonts
Specific properties (via
Special...
)
Density plot
Box plot
Caterpillar plot
Model fit plot
Scatterplot
Tips and Troubleshooting
Restrictions when modelling
Some error messages
Some Trap messages
The program hangs
Speeding up sampling
Improving convergence
Tutorial
Introduction
Specifying a model in the BUGS language
Running a model in WinBUGS
Monitoring parameter values
Checking convergence
How many iterations after convergence?
Obtaining summaries of the posterior distribution
Changing MCMC Defaults (advanced users only)
Defaults for numbers of iterations
Defaults for sampling methods
Distributions
Discrete Univariate
Continuous Univariate
Discrete Multivariate
Continuous Multivariate
References