The BUGS language

The BUGS language is described in detail in the NIMBLE User Manual, and in the relevant section of the BUGS manual.

An HTML version of the User Manual is also available.

Stochastic declarations

  • x ~ dgamma(shape, scale) (x follows a gamma distribution with parameters shape and scale)

Deterministic declarations

  • y <- 2 * x

For loops

for(i in 1:10) {
   lambda[i] <- exp(mu[i])
   y[i] ~ dpois(lambda[i])
}

 

Classic BUGS examples

There are lots of example models originally provided by the BUGS project:

We’ll see a variety of example models later today.

 

NIMBLE’s dialect of BUGS

 

A basic example

We’ll use the litters model example from the original BUGS examples, available with NIMBLE in the classic-bugs/vol1/litters directory of the installed package.

The data set describes the survival rates of rat pups in an experiment.

Here’s the original litters model.

 

Specifying the BUGS code for a model

Here we specify the litters model code directly in R. We can walk through some of details via the comments in the BUGS code.