Bayesian Analysis with Stata  book cover
1st Edition

Bayesian Analysis with Stata

ISBN 9781597181419
Published May 6, 2014 by Stata Press
302 Pages

SAVE ~ $15.19
was $75.95
USD $60.76

Prices & shipping based on shipping country


Book Description

Bayesian Analysis with Stata is written for anyone interested in applying Bayesian methods to real data easily. The book shows how modern analyses based on Markov chain Monte Carlo (MCMC) methods are implemented in Stata both directly and by passing Stata datasets to OpenBUGS or WinBUGS for computation, allowing Stata’s data management and graphing capability to be used with OpenBUGS/WinBUGS speed and reliability.

The book emphasizes practical data analysis from the Bayesian perspective, and hence covers the selection of realistic priors, computational efficiency and speed, the assessment of convergence, the evaluation of models, and the presentation of the results. Every topic is illustrated in detail using real-life examples, mostly drawn from medical research.

The book takes great care in introducing concepts and coding tools incrementally so that there are no steep patches or discontinuities in the learning curve. The book's content helps the user see exactly what computations are done for simple standard models and shows the user how those computations are implemented. Understanding these concepts is important for users because Bayesian analysis lends itself to custom or very complex models, and users must be able to code these themselves.

Table of Contents

List of figures

List of tables



The problem of priors

Case study 1: An early phase vaccine trial

Bayesian calculations

Benefits of a Bayesian analysis

Selecting a good prior

Starting points


Evaluating the posterior


Case study 1: The vaccine trial revisited

Marginal and conditional distributions

Case study 2: Blood pressure and age

Case study 2: BP and age continued

General log posteriors

Adding distributions to logdensity

Changing parameterization

Starting points




The MH algorithm in Stata

The mhs commands

Case study 3: Polyp counts

Scaling the proposal distribution

The mcmcrun command

Multiparameter models

Case study 3: Polyp counts continued

Highly correlated parameters

Case study 3: Polyp counts yet again

Starting points


Gibbs sampling


Case study 4: A regression model for pain scores

Conjugate priors

Gibbs sampling with nonstandard distributions

The gbs commands

Case study 4 continued: Laplace regression

Starting points


Assessing convergence


Detecting early drift

Detecting too short a run

Running multiple chains

Convergence of functions of the parameters

Case study 5: Beta-blocker trials

Further reading


Validating the Stata code and summarizing the results


Case study 6: Ordinal regression

Validating the software

Numerical summaries

Graphical summaries

Further reading


Bayesian analysis with Mata


The basics of Mata

Case study 6: Revisited

Case study 7: Germination of broomrape

Further reading


Using WinBUGS for model fitting


Installing the software

Preparing a WinBUGS analysis

Case study 8: Growth of sea cows

Case study 9: Jawbone size

Advanced features of WinBUGS


Programming a series of Bayesian analyses

OpenBUGS under Linux

Debugging WinBUGS

Starting points


Model checking


Bayesian residual analysis

The mcmccheck command

Case study 10: Models for Salmonella assays

Residual checking with Stata

Residual checking with Mata

Further reading


Model selection


Case study 11: Choosing a genetic model

Calculating a BF

Calculating the BFs for the NTD case study

Robustness of the BF

Model averaging

Information criteria

DIC for the genetic models

Starting points


Further case studies


Case study 12: Modeling cancer incidence

Case study 13: Creatinine clearance

Case study 14: Microarray experiment

Case study 15: Recurrent asthma attacks


Writing Stata programs for specific Bayesian analysis


The Bayesian lasso

The Gibbs sampler

The Mata code

A Stata ado-file

Testing the code

Case study 16: Diabetes data

Extensions to the Bayesian lasso program


A Standard distributions


Author index

Subject index

View More



John Thompson is professor of genetic epidemiology at the University of Leicester and has many years experience working as a biostatistician on epidemiological projects.


"… the first comprehensive guide to employing Bayesian methods using Stata statistical software. … until this book, there has been no unified presentation of how to implement Bayesian methods using Stata. … A nice feature of the book is the use of real data … I recommend it for Stata users who wish to employ Bayesian modeling within the Stata environment."
International Statistical Review, 2015