Linbugs ( aka Openbugs or Winbugs)

From HPC

Revision as of 09:54, 7 May 2009 by Aitsswhi (Talk | contribs)
Jump to: navigation, search

BUGS (Bayesian inference Using Gibbs Sampling) is a piece of computer software for the Bayesian analysis of complex statistical models using Markov chain Monte Carlo (MCMC) methods. It has been developing and maturing over the years, and is probably best known in its WinBugs incarnations. The latest version can run on Windows and Linux, as well as from inside the R statistical package.

Linbugs is Openbugs 3.0.3 classic interface.

You can run your Winbugs\Openbugs work on the HPC cluster using Linbugs which is the classic interface version and can be used from a terminal.

Openbugs web site http://mathstat.helsinki.fi/openbugs/

Openbugs manual http://mathstat.helsinki.fi/openbugs/Manuals/Manual.html

Contents

Opening Linbugs

linbugs

Issues and Problems

The only issue know with the linux version is the command modelSaveLog('log.txt') cause the an error. This command should not be used, you will find that a file called run.out is create automatically which is the same as the log.

Example

Create the following files

data.txt

list(
  t = c( 9.43000E+01, 1.57000E+01, 6.29000E+01, 1.26000E+02, 
         5.24000E+00, 3.14000E+01, 1.05000E+00, 1.05000E+00, 
         2.10000E+00, 1.05000E+01 ), 
  x = c(  5, 1, 5, 14, 3, 19, 1, 1, 4, 22 ), 
  N = 10
)

model.txt

model
{
  for (i in 1 : N) {
    theta[i] ~ dgamma(alpha, beta)
    lambda[i] <- theta[i] * t[i]
    x[i] ~ dpois(lambda[i])
  }
  alpha ~ dexp(1)
  beta ~ dgamma(0.1, 1.0)
}

init1.txt

list(
  alpha = 1.00000E+00,
  beta = 1.00000E+00
)

Now open linbugs

linbugs

and enter the following commands (note, this script could be saved as a text file and run via the command 'linbugs < script.txt')

modelCheck('model.txt')
modelData('data.txt')
modelCompile(1)
modelInits('init1.txt', 1)
modelGenInits()
samplesBeg(501)
modelSetRN(314159)
modelUpdate(500, 1)
samplesSet(theta)
samplesSet(alpha)
samplesSet(beta)
samplesSet(deviance)
modelUpdate(500, 1)
samplesStats('*')
samplesCoda('*', 'coda')
modelQuit()

This will have create the following CODA files

codaCODAindex.txt
codaCODAchain1.txt

Using with R

Personal tools