LCE Homepage

S-114.600 Introduction to Bayesian Modeling

 

Hierarchical modeling with BUGS

Set up a

for a simple data set. We want to inspect the quality produced by 5 machines in a factory. Quality assessment is expensive so only 5 measurements were made with each machine. In addition to the five machines, we are also interested in the quality produced by a prospective sixth machine. One way of doing this is to add a sixth machine with 'NA' (Not Available) measurements to the data in BUGS.

Because the BUGS software is not too easy to use, the hierarchical model is given. You only have to modify it to produce the pooled and separate models. And run the simulations for the hierarchical model, of course.

You will need the following files:

In WinBUGS you can set up a model with Doodle or write the model directly. Using Doodle is not recommended. Use the given model as such and as the basis for the pooled and separate models. In WinBUGS you can run the model and save the results with a few mouse clicks.

Open the files with WINBUGS File->Open... and select 'Text' as the file format. Since x has missing values (NA), after 'load inits' you have to click 'gen inits' to generate the initial values for these.

Note that in BUGS the second parameter of the Gaussian distribution (dnorm) is precision, the inverse of the variance, instead of standard deviation. The conjugate prior on precision is the Gamma distribution (dgamma).

Return

Help files

The following function lets you read the results given by BUGS into Matlab for analysis (see also the example in bugs.m)
bugs2mat.m


This page is maintained by Toni.Tamminen@hut.fi
This page has been updated 9. 10. 2003
URL: http://www.lce.hut.fi/teaching/S-114.600/ex/bugs_en.html