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.
x ~ dgamma(shape, scale)
(x
follows a gamma distribution with parameters shape
and scale
)y <- 2 * x
for(i in 1:10) {
lambda[i] <- exp(mu[i])
y[i] ~ dpois(lambda[i])
}
There are lots of example models originally provided by the BUGS project:
We’ll see a variety of example models later today.
v[1:5]
, or X[1:N, 1:M]
x ~ T(dnorm(0, 0.001), 0, Inf)
x ~ dnorm(0, sd = 1000)
consts
), and model data values (data
).
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.
G=2
groups of rat litters, with N=16
litters (i.e., mothers) in each group, and a variable number of pups in each litter.p[i,j]
.
Here we specify the litters model code directly in R. We can walk through some of details via the comments in the BUGS code.