Child pages
  • WinBUGS OpenBUGS with applications, spring 2011

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0


Jukka Ranta


5 cu.


Kurssilla perehdytään WinBUGS/OpenBUGS ohjelmistoihin, jotka edustavat laajalti käytössä olevia bayesläisen tilastotieteen laskennallisia työkaluja. Jonkin verran käytetään myös R-ohjelmaa. Kurssilla keskitytään sovellusesimerkkien avulla aineistojen analysoimiseen ja mallintamiseen, datan muokkauksesta tulosten tulkintaan ja mallin arviointiin. Keskeisenä työvälineenä on WinBUGS-ohjelmointikieli ja sen avulla suoritettava simulointi ja simulointitulosten arviointi. Tavoitteena on oppia miten Bayes-malleja määritellään ja käytetään syklittömien suunnattujen graafien ja BUGSin formaalin syntaksin avulla, simulaatiotulosten analysointi sekä ohjelmien tiettyjen erikoisominaisuuksien hyödyntäminen. Bayes-päättelyn/tilastotieteen perusteet oletetaan esitietoina.

In this course, we will explore WinBUGS/OpenBUGS software which are widely used for computation in Bayesian statistics. Also, statistical software R will be briefly visited. The focus is mainly on analysing and modeling application examples, from formatting of the data to interpreting the results and model assessment. Central tool for this is the WinBUGS-programming language and assessing the simulations thus produced. The goal is to learn how to define and use Bayesian models with acyclic graphs using BUGS syntax, to analyse simulation results obtained, and to get familiar with some special features of the software. Some knowledge of the basic principles of Bayesian inference/statistics is assumed.


Basic understanding of the elements of Bayesian (and other) statistics, and probability calculus with random variables. Some familiarity with typical univariate and simple multivariate distributions, concepts such as conditional, joint and marginal distributions, and some idea of Monte Carlo simulation as an approximation method. Interest for analysing data with Bayesian computational methods. Some theory will be briefly revisited in the introduction, though.


III period

Monday 16-18, C124, Thursday 16-18 B120


9.3. (General examination day). The exam questions are closely related to possible application models implemented in BUGS-model-language and explanations of some frequently used concepts in bayesian models done with BUGS. A brief collection of Solutions here.

Second exam: 24.3. (General examination day). Solutions here.
Remember also to complete the written exercise by 1.4. It is 25% of the max points. (10+30).

Third exam: 17.5. (General examination day again).
Solutions here.

Lecture material

List of probability distributions from Gelman et al: distributions . The parametrizations according to this list will be used in notations, unless WinBUGS requires differently. 

Here is some bayesian background reading: part1 . (Also in a nutshell , and a note about uninformative improper prior for scale parameter). This is not meant to be discussed in detail over the lectures, because the aim is to get to BUGS and applications. However, we briefly browse it as a warm up, and you can use it as your reference material if needed, depending on how much you already know of bayesian theory. Also, some slides here from the 'Methods festival'.
Likewise, you may also study the lecture notes of Jukka Corander about bayesian theory and applications (spring 2010). Corander2010

Lecture notes, part2 & nutshell. (For those interested, here's the explanation of Metropolis-Hastings algorithm , although these details are not really meant to be part of this course).

Basics of BUGS: part3
BUGS and linear models: part4, softdrink example codeodc,codetxt. Note about standardization.
BUGS and ANOVA: part5.
BUGS and GLM: part6.
LM, ANOVA, ANCOVA, GLM in BUGS: summary.
BUGS and hierarchical models: part7. New figures added + complete R code for the example + mixture model example added. General idea.
A paper on variance component priors in hierarchical models.
Model assessment: part8.
Customed BUGS functions and distributions: WBDev. An example of a new function.

Some corrections and additions have been made to lecture notes, up to the last week (week 9). So, check that you have the latest.

Possible example problems for the homework project are now here. They contain some possible tasks you could do with each data, but you are invited to use imagination: some other things might be further estimated and produced from the same problem - to make it your individual analysis. And you can suggest your own data too. Deadline for returning the report: 1.4. (if that is ok with everybody?)

 WinBUGS article in 'Statistics in Medicine'


Did you forget to register? What to do.

Exercise groups

 Starting 28.1. Friday.
The section numbers refer to the sections in part1.pdf and part2.pdf. The exercises are just for practice. Points (max 10) are from the single 'project report' described above. Note that some probability distributions can have alternative parametrizations in the literature. In the notes and in the exercises, the parametrization is as shown in the list above, taken from Gelman et al book 'Bayesian data analysis'.
Exercise 1:
Section 2.1: exercise 7, but consider the situation with n variables. Discuss the advantages of conditional independence.
+Section 4.6: exercises 2,7,8.
+Section 6.6: exercise 5.
+Section 7.8: exercises 3,7,11,12.
Solutions here.
Exercise 2:
solutions here.
Exercise 3:
solutions here. Softdrink example codeodc,codetxt.
Exercise 4:
solutions here.
Exercise 5:
solutions here.
Exercise 6: here. If you are planning to come to the last session on Friday, please email me or Ali Thu evening latest.









C128 computer class

Ali Amiryousefi